{% extends "base.html" %}

{% block content %}
<div class="auth-page d-flex align-items-center justify-content-center min-vh-100 position-relative overflow-hidden">
    <!-- Decorative 3D-like shapes -->
    <div class="shape shape-sphere top-left"></div>
    <div class="shape shape-cube bottom-right"></div>
    
    <div class="container py-5 z-1">
        <div class="row justify-content-center">
            <div class="col-md-5 col-lg-4">
                <div class="card glass-card border-0 text-center p-4 p-md-5">
                    <!-- Admin specific title -->
                    <h2 class="mb-4 fw-bold text-dark">
                        {% if site_header %}{{ site_header }}{% else %}Admin Login{% endif %}
                    </h2>
                    
                    {% if form.errors and not form.non_field_errors %}
                        <p class="errornote text-danger small mb-3">
                        {% if form.errors.items|length == 1 %}Please correct the error below.{% else %}Please correct the errors below.{% endif %}
                        </p>
                    {% endif %}

                    {% if form.non_field_errors %}
                        {% for error in form.non_field_errors %}
                            <p class="errornote text-danger small mb-3">{{ error }}</p>
                        {% endfor %}
                    {% endif %}

                    {% if user.is_authenticated %}
                        <p class="errornote text-danger small mb-3">
                            You are authenticated as {{ username }}, but are not authorized to access this page. Would you like to login to a different account?
                        </p>
                    {% endif %}
                    
                    <form method="post" id="login-form" class="auth-form text-start">
                        {% csrf_token %}
                        <div class="form-row mb-3">
                            {{ form.username.errors }}
                            <label for="id_username" class="form-label text-muted small fw-bold text-uppercase">{{ form.username.label }}</label>
                            {{ form.username }}
                        </div>
                        <div class="form-row mb-3">
                            {{ form.password.errors }}
                            <label for="id_password" class="form-label text-muted small fw-bold text-uppercase">{{ form.password.label }}</label>
                            {{ form.password }}
                            <input type="hidden" name="next" value="{{ next }}">
                        </div>
                        
                        <div class="submit-row mt-4">
                            <button type="submit" class="btn btn-dark w-100 py-3 btn-glass fw-bold shadow-sm">Log In</button>
                        </div>
                    </form>
                    
                    <div class="mt-4 pt-3 border-top">
                        <p class="mb-0 text-muted small"><a href="{% url 'home' %}" class="fw-bold text-secondary text-decoration-none">&larr; Back to Site</a></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
