{% extends 'base.html' %}
{% load static i18n %}

{% block title %}{% trans "Login" %} - {{ site_settings.business_name }}{% endblock %}

{% block content %}
<div class="container h-100 d-flex align-items-center justify-content-center">
    <div class="card glass-card border-0 shadow-lg p-4" style="max-width: 400px; width: 100%;">
        <div class="text-center mb-4">
            <h2 class="fw-bold text-primary">{% trans "Welcome Back" %}</h2>
            <p class="text-muted small">{% trans "Please login to access your dashboard" %}</p>
        </div>

        {% if form.errors %}
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            {% trans "Your username and password didn't match. Please try again." %}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
        {% endif %}

        <form method="post" action="{% url 'login' %}">
            {% csrf_token %}
            <div class="mb-3">
                <label for="id_username" class="form-label small fw-bold">{% trans "Username" %}</label>
                <div class="input-group">
                    <span class="input-group-text bg-light border-0"><i class="bi bi-person text-muted"></i></span>
                    <input type="text" name="username" autofocus maxlength="150" required id="id_username" class="form-control bg-light border-0" placeholder="{% trans 'Enter username' %}">
                </div>
            </div>
            <div class="mb-4">
                <label for="id_password" class="form-label small fw-bold">{% trans "Password" %}</label>
                <div class="input-group">
                    <span class="input-group-text bg-light border-0"><i class="bi bi-lock text-muted"></i></span>
                    <input type="password" name="password" required id="id_password" class="form-control bg-light border-0" placeholder="{% trans 'Enter password' %}">
                </div>
            </div>
            <button type="submit" class="btn btn-primary w-100 py-2 fw-bold shadow-sm">
                {% trans "Sign In" %}
            </button>
            <input type="hidden" name="next" value="{{ next }}">
        </form>

        <div class="mt-4 text-center">
            <p class="small text-muted mb-0">{% trans "Need help? Contact your administrator." %}</p>
        </div>
    </div>
</div>

<style>
    /* Center the login box specifically since we're using the base template with sidebar */
    #sidebar { display: none !important; }
    #content { margin-left: 0 !important; width: 100%; height: 100vh; background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); }
    .top-navbar { display: none !important; }
    main { padding: 0 !important; height: 100%; display: flex; align-items: center; justify-content: center; }
</style>
{% endblock %}
