
{% extends "users/login/base.html" %}

{% block form %}
<div class="card-header bg-primary text-white">
    <h3 class="mb-0"><i class="bi bi-shield-lock me-2"></i>重置密码</h3>
</div>
<div class="card-body p-4">
    <form method="post" class="needs-validation" novalidate>
        {% csrf_token %}

        <!-- 全局错误提示 -->
        {% if form.non_field_errors %}
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            {% for error in form.non_field_errors %}
            {{ error }}
            {% endfor %}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
        {% endif %}

        <!-- 新密码 -->
        <div class="mb-3">
            <label for="{{ form.new_password1.id_for_label }}" class="form-label">
                <i class="bi bi-lock me-1"></i>新密码
            </label>
            <input type="password" 
                   name="{{ form.new_password1.name }}"
                   class="form-control form-control-lg {% if form.new_password1.errors %}is-invalid{% endif %}"
                   id="{{ form.new_password1.id_for_label }}"
                   required>
            {% for error in form.new_password1.errors %}
            <div class="invalid-feedback">{{ error }}</div>
            {% endfor %}
        </div>

        <!-- 确认密码 -->
        <div class="mb-3">
            <label for="{{ form.new_password2.id_for_label }}" class="form-label">
                <i class="bi bi-lock-fill me-1"></i>确认密码
            </label>
            <input type="password" 
                   name="{{ form.new_password2.name }}"
                   class="form-control form-control-lg {% if form.new_password2.errors %}is-invalid{% endif %}"
                   id="{{ form.new_password2.id_for_label }}"
                   required>
            {% for error in form.new_password2.errors %}
            <div class="invalid-feedback">{{ error }}</div>
            {% endfor %}
        </div>

        <!-- 验证码 -->
        <div class="mb-3">
            <label class="form-label">
                <i class="bi bi-shield-check me-1"></i>验证码
            </label>
            <div class="d-flex align-items-center gap-3">
                <div class="flex-grow-1">
                    {{ form.captcha }}
                </div>
            </div>
            {% if form.captcha.errors %}
            <div class="invalid-feedback d-block">
                {% for error in form.captcha.errors %}
                {{ error }}
                {% endfor %}
            </div>
            {% endif %}
        </div>

        <div class="d-grid gap-2 mt-4">
            <button type="submit" class="btn btn-primary btn-lg">
                <i class="bi bi-check-circle me-2"></i>提交新密码
            </button>
        </div>

        <div class="mt-4 text-center">
            <a href="{% url 'user:login' %}" class="text-decoration-none">
                <i class="bi bi-arrow-left-circle me-1"></i>返回登录
            </a>
        </div>
    </form>
</div>
{% endblock %}
