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

{% load static %}


                    {% block form %}
                    <div class="card-header bg-primary text-white">
                        <h3 class="mb-0"><i class="bi bi-box-arrow-in-right 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.username_or_email.id_for_label }}" class="form-label">
                                <i class="bi bi-person-badge me-1"></i>用户名/邮箱
                            </label>
                            <input type="text" 
                                   name="{{ form.username_or_email.name }}" 
                                   class="form-control form-control-lg {% if form.username_or_email.errors %}is-invalid{% endif %}" 
                                   id="{{ form.username_or_email.id_for_label }}"
                                   required>
                            {% for error in form.username_or_email.errors %}
                                <div class="invalid-feedback">{{ error }}</div>
                            {% endfor %}
                        </div>

                        <!-- 密码 -->
                        <div class="mb-3">
                            <label for="{{ form.password.id_for_label }}" class="form-label">
                                <i class="bi bi-lock me-1"></i>密码
                            </label>
                            <input type="password" 
                                   name="{{ form.password.name }}" 
                                   class="form-control form-control-lg {% if form.password.errors %}is-invalid{% endif %}" 
                                   id="{{ form.password.id_for_label }}"
                                   required>
                            {% for error in form.password.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|safe }}
                                {% 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-box-arrow-in-right me-2"></i>立即登录
                            </button>
                        </div>

                        <div class="mt-4 text-center">
                            <a href="{% url 'users:forgot_password' %}" class="text-decoration-none me-3">
                                <i class="bi bi-question-circle me-1"></i>忘记密码？
                            </a>
                            <a href="{% url 'users:register' %}" class="text-decoration-none">
                                <i class="bi bi-person-plus me-1"></i>注册新账号
                            </a>
                        </div>
                    </form>
                </div>
                    {% endblock %}


