{% extends "base.html" %}
{% block title %}Login | Fox Fitt{% endblock %}

{% block content %}
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-5">
            <div class="card shadow-sm border-0">
                <div class="card-body p-5">
                    <div class="text-center mb-4">
                        <h2 class="fw-bold heading-font"><span style="color: var(--accent-color);">Fox</span> Fitt</h2>
                        <p class="text-muted">Sign in to manage work & payroll</p>
                    </div>

                    {% 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 login with an account that has access.
                        </div>
                        {% else %}
                        <div class="alert alert-info">
                            Please login 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 fw-medium text-secondary">Username</label>
                            <input type="text" name="username" autofocus maxlength="150" required id="id_username" class="form-control" placeholder="Enter your username">
                        </div>
                        <div class="mb-4">
                            <label for="id_password" class="form-label fw-medium text-secondary">Password</label>
                            <input type="password" name="password" required id="id_password" class="form-control" placeholder="Enter your password">
                        </div>
                        
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-accent py-2 fw-bold">Login</button>
                        </div>
                        
                        <input type="hidden" name="next" value="{{ next }}">
                    </form>
                </div>
            </div>
            
            <div class="text-center mt-4">
                <p class="text-muted small">Forgot your password? Please contact your administrator.</p>
            </div>
        </div>
    </div>
</div>
{% endblock %}
