{# ══════════════════════════════════════════════════════════════
   templates/partials/_login_dropdown.html.twig
   Bouton + dropdown formulaire de connexion
   ══════════════════════════════════════════════════════════════ #}

<div class="header-wrapper" id="loginWrapper"
     data-controller="header-dropdown"
     data-header-dropdown-target="wrapper">

    {# Bouton déclencheur #}
    <button class="login-btn" id="loginToggle"
            aria-haspopup="true" aria-expanded="false"
            data-header-dropdown-target="toggle">
        {% if app.user.globalURLpp is not null %}
            <img src="{{ asset(app.user.globalURLpp) }}" alt="Photo de profil de {{ app.user.pseudo }}" class="profile-pic">
        {% else %}
            <svg width="15" height="15" viewBox="0 0 24 24"
                 fill="none" stroke="currentColor" stroke-width="2"
                 stroke-linecap="round" stroke-linejoin="round">
                <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>
                <circle cx="12" cy="7" r="4"/>
            </svg>
        {% endif %}
        {{ app.user.pseudo }}
    </button>

    {# Dropdown #}
    <div class="header-dropdown" id="headerDropdown"
         role="dialog" aria-label="Formulaire de connexion"
         data-header-dropdown-target="dropdown">

        <span class="dropdown-title">Bonjour {{ app.user.pseudo }}</span>

        {% if is_granted("ROLE_ADMIN") %}
            <a href="{{ path('app_admin') }}"
               class="dropdown-link {{ current_route == 'app_administration' ? 'active' }}">
                Administration
            </a>
        {% endif %}

        <a href="{{ path('app_settings') }}"
           class="dropdown-link {{ current_route == 'app_home' ? 'active' }}">
            Parametre
        </a>
        <form action="{{ path('app_logout') }}" method="post" >
            <input type="hidden"
                   name="_csrf_token"
                   value="{{ csrf_token('authenticate') }}">

            {# Retenir la page courante pour y revenir en cas d'erreur #}
            <input type="hidden"
                   name="_failure_path"
                   value="{{ app.request.uri }}">

            <button class="submit-btn" type="submit">Se déconnecter</button>

        </form>



    </div>
</div>
