{% extends 'base.html' %}

{% block title %}{{ title }} - Benutzerverwaltung - van Hees-Theyssen-Vogel'sche Stiftung{% endblock %}

{% block content %}

    <div class="row">
        <div class="col-12">
            <div class="d-sm-flex align-items-center justify-content-between mb-4">
                <h1 class="h3 mb-0 text-gray-800">
                    <i class="fas fa-key me-2"></i>{{ title }}
                </h1>
                <a href="{% url 'stiftung:user_detail' user_obj.pk %}" class="btn btn-outline-secondary">
                    <i class="fas fa-arrow-left me-1"></i>Zurück zum Benutzer
                </a>
            </div>
        </div>
    </div>

    <div class="row justify-content-center">
        <div class="col-lg-6">
            <div class="card shadow">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary">
                        <i class="fas fa-lock me-2"></i>Neues Passwort festlegen
                    </h6>
                </div>
                <div class="card-body">
                    {% if form.errors %}
                    <div class="alert alert-danger">
                        <h6><i class="fas fa-exclamation-triangle me-2"></i>Fehler beim Speichern:</h6>
                        {% for field, errors in form.errors.items %}
                            {% for error in errors %}
                                <div>{{ error }}</div>
                            {% endfor %}
                        {% endfor %}
                    </div>
                    {% endif %}

                    <div class="alert alert-info">
                        <i class="fas fa-info-circle me-2"></i>
                        <strong>Hinweis:</strong> Das neue Passwort wird sofort wirksam. Der Benutzer wird beim nächsten Login das neue Passwort verwenden müssen.
                    </div>

                    <form method="post">
                        {% csrf_token %}
                        
                        <div class="form-group mb-3">
                            <label for="{{ form.new_password1.id_for_label }}" class="form-label">
                                {{ form.new_password1.label }}
                                <span class="text-danger">*</span>
                            </label>
                            {{ form.new_password1 }}
                            {% if form.new_password1.help_text %}
                            <div class="form-text">{{ form.new_password1.help_text }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="form-group mb-3">
                            <label for="{{ form.new_password2.id_for_label }}" class="form-label">
                                {{ form.new_password2.label }}
                                <span class="text-danger">*</span>
                            </label>
                            {{ form.new_password2 }}
                            {% if form.new_password2.help_text %}
                            <div class="form-text">{{ form.new_password2.help_text }}</div>
                            {% endif %}
                        </div>

                        <hr>
                        <div class="d-flex justify-content-between">
                            <a href="{% url 'stiftung:user_detail' user_obj.pk %}" class="btn btn-outline-secondary">
                                <i class="fas fa-times me-1"></i>Abbrechen
                            </a>
                            <button type="submit" class="btn btn-warning">
                                <i class="fas fa-key me-1"></i>Passwort ändern
                            </button>
                        </div>
                    </form>
                </div>
            </div>

            <!-- Passwort-Sicherheitshinweise -->
            <div class="card shadow mt-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary">
                        <i class="fas fa-shield-alt me-2"></i>Passwort-Sicherheit
                    </h6>
                </div>
                <div class="card-body">
                    <h6>Richtlinien für sichere Passwörter:</h6>
                    <ul class="list-unstyled">
                        <li><i class="fas fa-check text-success me-2"></i>Mindestens 8 Zeichen lang</li>
                        <li><i class="fas fa-check text-success me-2"></i>Kombination aus Groß- und Kleinbuchstaben</li>
                        <li><i class="fas fa-check text-success me-2"></i>Mindestens eine Zahl</li>
                        <li><i class="fas fa-check text-success me-2"></i>Mindestens ein Sonderzeichen</li>
                        <li><i class="fas fa-check text-success me-2"></i>Keine persönlichen Informationen</li>
                        <li><i class="fas fa-check text-success me-2"></i>Nicht in anderen Systemen verwendet</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

{% endblock %}
