{% extends 'allianceauth/base-bs5.html' %}

{% load i18n static %}

{% block page_title %}
    {% translate "Industry Plugin" %}
{% endblock %}

{% block extra_css %}
    {{ block.super }}
    {% include 'bundles/datatables-css-bs5.html' %}
    <link rel="stylesheet" href="{% static 'industry_reforged/css/industry.css' %}?v=2">
{% endblock %}

{% block header_nav_brand %}
    {% translate "Industry Plugin" %}
{% endblock header_nav_brand %}

{% block content %}
    <div class="allianceauth-industry-plugin">
        <!-- Tabs removed in favor of separate main menu items -->
        {% block details %}{% endblock %}

        <!-- Global Loading Overlay -->
        <div id="industry-loading-overlay" class="industry-loading-overlay" style="display: none;">
            <div class="industry-spinner-container">
                <div class="industry-spinner"></div>
                <h4 class="mt-3 text-primary">Processing Request...</h4>
                <p class="text-muted small">Communicating with EVE Online servers.<br>This may take a few moments.</p>
            </div>
        </div>
    </div>
{% endblock %}

{% block extra_javascript %}
    {{ block.super }}
    {% include 'bundles/datatables-js-bs5.html' %}
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Show overlay on clicking links with show-loader class
            const loaderLinks = document.querySelectorAll('a.show-loader');
            loaderLinks.forEach(link => {
                link.addEventListener('click', function(e) {
                    // Don't show if it's opening in a new tab
                    if (this.target !== '_blank') {
                        document.getElementById('industry-loading-overlay').style.display = 'flex';
                    }
                });
            });

            // Show overlay on submitting forms with show-loader class
            const loaderForms = document.querySelectorAll('form.show-loader');
            loaderForms.forEach(form => {
                form.addEventListener('submit', function() {
                    document.getElementById('industry-loading-overlay').style.display = 'flex';
                });
            });
        });
    </script>
{% endblock %}
