{% load static %}
{% load i18n %}
{% load navactive %}

{# ---------- Inline chips — shown when they fit on one row (xl and up) ---------- #}
<li class="nav-item d-none d-xl-block">
    <a href="{% url 'buybackprogram:index' %}" class="nav-link bbp-nav-link">
        <span class="bbp-nav-btn bbp-nav-btn-nav"><i class="fas fa-store"></i> {% trans "Programs" %}</span>
    </a>
</li>

{% if request.user.is_authenticated %}
    <li class="nav-item d-none d-xl-block">
        <a href="{% url 'buybackprogram:my_stats' %}" class="nav-link bbp-nav-link">
            <span class="bbp-nav-btn bbp-nav-btn-nav"><i class="fas fa-chart-line"></i> {% trans "My Statistics" %}</span>
        </a>
    </li>

    {% if perms.buybackprogram.manage_programs or perms.buybackprogram.manage_all_programs %}
        <li class="nav-item d-none d-xl-block">
            <a href="{% url 'buybackprogram:program_stats' %}" class="nav-link bbp-nav-link">
                <span class="bbp-nav-btn bbp-nav-btn-nav"><i class="fas fa-chart-bar"></i> {% trans "My Program Statistics" %}</span>
            </a>
        </li>
    {% endif %}

    {% if perms.buybackprogram.see_all_statics or perms.buybackprogram.manage_all_programs %}
        <li class="nav-item d-none d-xl-block">
            <a href="{% url 'buybackprogram:program_stats_all' %}" class="nav-link bbp-nav-link">
                <span class="bbp-nav-btn bbp-nav-btn-nav"><i class="fas fa-chart-pie"></i> {% trans "All Program Statistics" %}</span>
            </a>
        </li>
    {% endif %}

    <li class="nav-item d-none d-xl-block">
        <a href="{% url 'buybackprogram:faq' %}" class="nav-link bbp-nav-link">
            <span class="bbp-nav-btn bbp-nav-btn-nav"><i class="fas fa-question-circle"></i> {% trans "FAQ" %}</span>
        </a>
    </li>

    <li class="nav-item d-none d-xl-block">
        <a href="{% url 'buybackprogram:user_settings_edit' %}" class="nav-link bbp-nav-link">
            <span class="bbp-nav-btn bbp-nav-btn-primary"><i class="fas fa-cog"></i> {% trans "My Settings" %}</span>
        </a>
    </li>
{% endif %}

{# ---------- Collapsed dropdown — shown when the chips would wrap (below xl) ---------- #}
<li class="nav-item dropdown d-xl-none">
    <a href="#" class="nav-link bbp-nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-expanded="false">
        <span class="bbp-nav-btn bbp-nav-btn-nav"><i class="fas fa-bars"></i> {% trans "Menu" %} <i class="fas fa-caret-down ms-1"></i></span>
    </a>
    <ul class="dropdown-menu bbp-nav-dropdown">
        <li>
            <a class="dropdown-item" href="{% url 'buybackprogram:index' %}">
                <i class="fas fa-store fa-fw me-2"></i>{% trans "Programs" %}
            </a>
        </li>
        {% if request.user.is_authenticated %}
            <li>
                <a class="dropdown-item" href="{% url 'buybackprogram:my_stats' %}">
                    <i class="fas fa-chart-line fa-fw me-2"></i>{% trans "My Statistics" %}
                </a>
            </li>
            {% if perms.buybackprogram.manage_programs or perms.buybackprogram.manage_all_programs %}
                <li>
                    <a class="dropdown-item" href="{% url 'buybackprogram:program_stats' %}">
                        <i class="fas fa-chart-bar fa-fw me-2"></i>{% trans "My Program Statistics" %}
                    </a>
                </li>
            {% endif %}
            {% if perms.buybackprogram.see_all_statics or perms.buybackprogram.manage_all_programs %}
                <li>
                    <a class="dropdown-item" href="{% url 'buybackprogram:program_stats_all' %}">
                        <i class="fas fa-chart-pie fa-fw me-2"></i>{% trans "All Program Statistics" %}
                    </a>
                </li>
            {% endif %}
            <li><hr class="dropdown-divider"></li>
            <li>
                <a class="dropdown-item" href="{% url 'buybackprogram:faq' %}">
                    <i class="fas fa-question-circle fa-fw me-2"></i>{% trans "FAQ" %}
                </a>
            </li>
            <li>
                <a class="dropdown-item" href="{% url 'buybackprogram:user_settings_edit' %}">
                    <i class="fas fa-cog fa-fw me-2"></i>{% trans "My Settings" %}
                </a>
            </li>
        {% endif %}
    </ul>
</li>
