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

{% load i18n %}

{% block content %}
    <div class="row justify-content-center">
        <div class="col-sm-10 col-md-8 col-lg-6">
            {% 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 mb-3">
                            {% block middle_box_content %}
                            {% endblock %}
                        </div>

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

                        <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>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
{% endblock %}

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