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

{% block title %}{% trans "Login" %} | masarX{% endblock %}

{% block content %}
<section class="py-5 bg-light" style="min-height: 80vh; display: flex; align-items: center;">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-6 col-lg-5">
                <div class="card shadow-sm border-0 rounded-4">
                    <div class="card-body p-4 p-md-5">
                        
                        <!-- Logo or Brand Name -->
                        <div class="text-center mb-4">
                            {% if platform_profile.logo %}
                                <img src="{{ platform_profile.logo.url }}" alt="{{ platform_profile.name }}" height="70" class="mb-3">
                            {% else %}
                                <h2 class="fw-bold text-masarx-primary mb-3">{{ platform_profile.name|default:"masarX" }}</h2>
                            {% endif %}
                            <h4 class="fw-bold">{% trans "Welcome Back" %}</h4>
                            <p class="text-muted small">{% trans "Please login with your username and password" %}</p>
                        </div>

                        <form method="post">
                            {% csrf_token %}
                            {% for field in form %}
                                <div class="mb-3">
                                    <label class="form-label fw-medium">{{ field.label }}</label>
                                    {{ field }}
                                    {% if field.errors %}
                                        <div class="text-danger small mt-1">{{ field.errors }}</div>
                                    {% endif %}
                                </div>
                            {% endfor %}
                            
                            <div class="d-flex justify-content-between align-items-center mb-4">
                                <div class="form-check">
                                    <!-- Optional: Remember Me logic could go here later -->
                                </div>
                                <a href="{% url 'password_reset' %}" class="text-decoration-none text-muted small hover-orange">
                                    {% trans "Forgot Password?" %}
                                </a>
                            </div>

                            <button type="submit" class="btn btn-masarx-primary w-100 py-2 fw-bold mb-3">{% trans "Login" %}</button>
                        </form>
                        
                        <div class="text-center border-top pt-3 mt-2">
                            <span class="text-muted small">{% trans "Don't have an account?" %}</span>
                            <a href="{% url 'register' %}" class="text-masarx-orange text-decoration-none fw-bold ms-1">{% trans "Register" %}</a>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<style>
    .form-control {
        border-radius: 8px;
        padding: 12px 15px;
        border-color: #dee2e6;
    }
    .form-control:focus {
        border-color: var(--accent-orange);
        box-shadow: 0 0 0 0.25rem rgba(255, 126, 21, 0.15);
    }
    .btn-masarx-primary {
        background-color: var(--accent-orange);
        border-color: var(--accent-orange);
        color: white;
        border-radius: 8px;
        transition: all 0.3s;
    }
    .btn-masarx-primary:hover {
        background-color: #e66a00;
        border-color: #e66a00;
        color: white;
    }
    .text-masarx-orange {
        color: var(--accent-orange);
    }
    .hover-orange:hover {
        color: var(--accent-orange) !important;
    }
</style>
{% endblock %}
