{% extends "base.html" %}

{% block title %}Changer le mot de passe - {{ user.full_name }}{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="row">
        <div class="col-md-8 mx-auto">
            <div class="card">
                <div class="card-header">
                    <h3>🔐 Changer le mot de passe de {{ user.full_name }}</h3>
                    <p class="text-muted mb-0">Administrateur: {{ current_user.full_name }}</p>
                </div>
                <div class="card-body">
                    <form method="POST">
                        {{ form.hidden_tag() }}
                        
                        <div class="mb-3">
                            <label for="current_password" class="form-label">Votre mot de passe actuel (confirmation)</label>
                            {{ form.current_password(class="form-control") }}
                            {% if form.current_password.errors %}
                                <div class="text-danger">
                                    {% for error in form.current_password.errors %}
                                        <small>{{ error }}</small>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                        
                        <div class="mb-3">
                            <label for="new_password" class="form-label">Nouveau mot de passe</label>
                            {{ form.new_password(class="form-control") }}
                            {% if form.new_password.errors %}
                                <div class="text-danger">
                                    {% for error in form.new_password.errors %}
                                        <small>{{ error }}</small>
                                    {% endfor %}
                                </div>
                            {% endif %}
                            <div class="form-text">Le mot de passe doit contenir au moins 6 caractères.</div>
                        </div>
                        
                        <div class="mb-3">
                            <label for="confirm_password" class="form-label">Confirmer le nouveau mot de passe</label>
                            {{ form.confirm_password(class="form-control") }}
                            {% if form.confirm_password.errors %}
                                <div class="text-danger">
                                    {% for error in form.confirm_password.errors %}
                                        <small>{{ error }}</small>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                        
                        <div class="d-flex justify-content-between">
                            <a href="{{ url_for('auth.list_users') }}" class="btn btn-secondary">
                                <i class="fas fa-arrow-left"></i> Retour
                            </a>
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-save"></i> Changer le mot de passe
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}