{% extends "base.html" %}
{% load static %}

{% block content %}
<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card shadow-sm border-0">
                <div class="card-body p-5">
                    <h2 class="text-center mb-4">Login</h2>
                    <p class="text-muted text-center mb-4">Please log in to access the Grassroots Campaign Manager.</p>
                    
                    {% if form.errors %}
                        <div class="alert alert-danger">
                            Your username and password didn't match. Please try again.
                        </div>
                    {% endif %}

                    {% if next %}
                        {% if user.is_authenticated %}
                            <div class="alert alert-warning">
                                Your account doesn't have access to this page. To proceed,
                                please log in with an account that has access.
                            </div>
                        {% else %}
                            <div class="alert alert-info">
                                Please log in to see this page.
                            </div>
                        {% endif %}
                    {% endif %}

                    <form method="post" action="{% url 'login' %}">
                        {% csrf_token %}
                        <div class="mb-3">
                            <label for="id_username" class="form-label">Username</label>
                            <input type="text" name="username" autofocus maxlength="150" required id="id_username" class="form-control">
                        </div>
                        <div class="mb-3">
                            <label for="id_password" class="form-label">Password</label>
                            <input type="password" name="password" required id="id_password" class="form-control">
                        </div>
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary btn-lg">Login</button>
                        </div>
                        <input type="hidden" name="next" value="{{ next }}">
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
