{% extends 'base.html' %}

{% block title %}Login - Task Manager{% endblock %}

{% block content %}
<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h4 class="mb-0">Login to Your Account</h4>
                </div>
                <div class="card-body">
                    {% 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">Email</label>
                            <input type="email" name="username" class="form-control" id="id_username" required autofocus>
                        </div>
                        <div class="mb-3">
                            <label for="id_password" class="form-label">Password</label>
                            <input type="password" name="password" class="form-control" id="id_password" required>
                        </div>
                        <div class="d-flex justify-content-between align-items-center mb-3">
                            <div class="form-check">
                                <input type="checkbox" class="form-check-input" id="remember_me" name="remember_me">
                                <label class="form-check-label" for="remember_me">Remember me</label>
                            </div>
                            <a href="{% url 'password_reset' %}">Forgot password?</a>
                        </div>
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">Login</button>
                        </div>
                        <input type="hidden" name="next" value="{{ next }}">
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
