{% extends 'public/base.html' %}

{% load i18n %}

{# Override the outer container so we can render both the card and split layouts
   without being constrained by base.html's fixed <div class="container">. #}
{% block outer_container %}
<div class="aac-login-root{% if not AA_CUSTOMIZER.login_spa_enabled %}{% if AA_CUSTOMIZER.login_layout == 'split' or AA_CUSTOMIZER.login_layout == 'split-right' %} aac-split{% endif %}{% if AA_CUSTOMIZER.login_layout == 'split-right' %} aac-split-right{% endif %}{% endif %}">

    {# Background panel — hidden in card mode, shown in split on large screens #}
    <div class="aac-login-left">
        <div class="aac-split-overlay-text aac-split-text-{{ AA_CUSTOMIZER.login_split_text_position }}">
            {% if AA_CUSTOMIZER.login_split_show_overlay_text %}
                <h1 class="aac-split-site-name fw-bold">
                    {% if AA_CUSTOMIZER.login_split_overlay_text %}
                        {{ AA_CUSTOMIZER.login_split_overlay_text }}
                    {% else %}
                        {{ SITE_NAME }}
                    {% endif %}
                </h1>
            {% endif %}
        </div>
    </div>

    {# Login panel — always visible, full-width in card mode, right column in split #}
    <div class="aac-login-right">
        <div class="aac-login-inner">

            {% if messages %}
                {% for message in messages %}
                    <div class="alert alert-{{ message.level_tag }}">{{ message }}</div>
                {% endfor %}
            {% endif %}

            <div class="card card-login border-secondary p-3">
                <div class="card-body">
                    {% if user.is_authenticated %}
                        <div class="alert alert-info">
                            <p class="mb-0">
                                {% translate "You are already logged in as" %} {{ user.username }}.
                            </p>
                        </div>

                        <div class="aa-callout aa-callout-info mb-3">
                            <p class="mb-0">
                                {% translate "You are seeing this page because you either opened a direct link to the login or to a page you don't have access to." %}
                            </p>
                        </div>

                        <div>
                            <a href="{% url 'authentication:dashboard' %}" class="btn text-bg-primary mb-3">
                                <i class="fas fa-tachometer-alt fa-fw"></i>
                                {% translate "Go to Dashboard" %}
                            </a>

                            <form class="float-sm-end" method="post" action="{% url 'logout' %}">
                                {% csrf_token %}

                                <button type="submit" class="btn btn-link text-bg-danger text-decoration-none">
                                    <i class="fa-solid fa-right-from-bracket fa-fw"></i>
                                    {% translate 'Sign Out' %}
                                </button>
                            </form>
                        </div>
                    {% else %}
                        <div class="text-center">
                            {% block middle_box_content %}{% endblock %}
                        </div>
                    {% endif %}
                </div>

                {% include 'public/lang_select.html' %}

                {# CCP footer links — hidden in split layout via CSS #}
                <div class="aac-ccp-footer">
                    <p class="text-center mt-3">
                        {% translate "For information on SSO, ESI and security read the CCP Dev Blog" %}<br>
                        <a class="text-reset" href="https://www.eveonline.com/news/view/introducing-esi" target="_blank" rel="noopener noreferrer">
                            {% translate "Introducing ESI - A New API For EVE Online" %}
                        </a>
                    </p>
                    <p class="text-center">
                        <a class="text-reset" href="https://developers.eveonline.com/authorized-apps" target="_blank" rel="noopener noreferrer">
                            {% translate "Manage ESI Applications" %}
                        </a>
                    </p>
                </div>

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

</div>
{% endblock outer_container %}

{% block extra_include %}
    {% include 'bundles/bootstrap-js-bs5.html' %}
{% endblock %}
