{% extends 'base.html' %}

{% block title %}Вход{% endblock %}

{% block content %}
<div class="container d-flex align-items-center justify-content-center" style="min-height: 70vh;">
    <div class="card shadow-sm" style="max-width: 420px; width: 100%;">
        <div class="card-body p-4">
            <!-- Заголовок -->
            <div class="text-center mb-4">
                <h3 class="fw-bold mb-2">Добро пожаловать</h3>
                <p class="text-muted mb-0">Войдите в систему</p>
            </div>

            <!-- Сообщения об ошибках -->
            {% if messages %}
                {% for message in messages %}
                    {% if 'danger' in message.tags or 'error' in message.tags %}
                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
                            {{ message }}
                            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                        </div>
                    {% endif %}
                {% endfor %}
            {% endif %}

            <!-- Форма входа -->
            <form method="post" action="{% url 'accounts:login' %}">
                {% csrf_token %}
                <div class="mb-3">
                    <label for="email" class="form-label">Email</label>
                    <input type="email" class="form-control" id="email" name="email" required autofocus>
                </div>
                {% include 'accounts/password_input.html' with field_name='password' field_label='Пароль' required=True %}
                
                <button type="submit" class="btn btn-primary w-100 py-2 mb-3">Войти</button>
                
                <!-- Ссылка "Забыли пароль?" -->
                <div class="text-center">
                    <a href="{% url 'accounts:password_reset' %}" class="text-decoration-none text-muted">
                        <small>Забыли пароль?</small>
                    </a>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}