{% extends 'admin/base.html' %}

{% block login_content %}
<div class="login-page">
    <div class="login-card">
        <div class="login-logo mb-4 text-center">
            <img src="{{ url_for('static', filename='img/gmpl_logo.png') }}" alt="GMPL Logo" class="img-fluid" style="max-height: 100px;">
            <h4 class="mt-3">Administration</h4>
        </div>
        
        <!-- Flash Messages -->
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
                        {{ message }}
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                    </div>
                {% endfor %}
            {% endif %}
        {% endwith %}
        
        <form method="post" action="{{ url_for('admin.login') }}">
            {{ form.hidden_tag() }}
            
            <div class="form-group mb-3">
                {{ form.username.label(class="form-label") }}
                {{ form.username(class="form-control" + (" is-invalid" if form.username.errors else "")) }}
                {% if form.username.errors %}
                    <div class="invalid-feedback">
                        {% for error in form.username.errors %}
                            {{ error }}
                        {% endfor %}
                    </div>
                {% endif %}
            </div>
            
            <div class="form-group mb-3">
                {{ form.password.label(class="form-label") }}
                {{ form.password(class="form-control" + (" is-invalid" if form.password.errors else "")) }}
                {% if form.password.errors %}
                    <div class="invalid-feedback">
                        {% for error in form.password.errors %}
                            {{ error }}
                        {% endfor %}
                    </div>
                {% endif %}
            </div>
            
            <div class="form-group mb-4">
                <div class="form-check">
                    {{ form.remember_me(class="form-check-input") }}
                    {{ form.remember_me.label(class="form-check-label") }}
                </div>
            </div>
            
            <div class="d-grid">
                {{ form.submit(class="btn btn-primary btn-lg") }}
            </div>
        </form>
        
        <div class="mt-4 text-center">
            <a href="{{ url_for('main.index') }}">Retour au site</a>
        </div>
    </div>
</div>
{% endblock %}
