/**
 * GHA Header, Footer & Bottom Nav Bar Mobile
 *
 * Styling global pour la navigation du site Global Health Academy.
 * Utilise le design system V2 (couleurs, espacements, typographie).
 *
 * Sections :
 *   1. Header Desktop — sticky, ombre au scroll
 *   2. Boutons connexion / inscription (déconnectés)
 *   3. Lien "Mes formations" (connectés)
 *   4. Cacher l'ancien CTA "Getting Started"
 *   5. Dropdown utilisateur — polish
 *   6. Panier — badge style
 *   7. Bottom Nav Bar Mobile
 *   8. Header Mobile — compact
 *   9. Footer — positionnement et nettoyage
 *
 * Breakpoint mobile : 991px (identique au thème)
 * Primary : #1e40af | Text : #1e293b | Muted : #94a3b8
 * Background : #ffffff | Border : #e2e8f0 | Hover bg : #f1f5f9
 */


/* ==========================================================================
   1. Header Desktop — sticky avec ombre au scroll
   ========================================================================== */

.header-default {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000;
    background: #ffffff;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    box-shadow: none;
}

/* Ombre ajoutée au scroll via JS (.gha-scrolled) */
.header-default.gha-scrolled {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Masquer le header au scroll vers le bas (mobile uniquement) */
.header-default.gha-header-hidden {
    transform: translateY(-100%);
}


/* ==========================================================================
   2. Boutons Se connecter / S'inscrire (visiteurs déconnectés)
   ========================================================================== */

.gha-header-login {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Bouton "Se connecter" — style texte discret */
.gha-header-login .gha-btn-login {
    color: #1e293b;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.gha-header-login .gha-btn-login:hover {
    color: #1e40af;
    background: #eff6ff;
}

/* Bouton "S'inscrire" — style plein primary */
.gha-header-login .gha-btn-signup {
    display: inline-block;
    background: #1e40af;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 8px;
    text-decoration: none;
    border: 2px solid #1e40af;
    transition: all 0.2s ease;
}

.gha-header-login .gha-btn-signup:hover {
    background: transparent;
    color: #1e40af;
}


/* ==========================================================================
   3. Lien "Mes formations" dans la navigation (utilisateurs connectés)
   ========================================================================== */

.gha-nav-my-courses a {
    color: #1e40af !important;
    font-weight: 600 !important;
}


/* ==========================================================================
   4. Cacher l'ancien bouton CTA du Customizer ("Getting Started")
   ========================================================================== */

.header-default .utils-btn {
    display: none !important;
}


/* ==========================================================================
   5. Dropdown utilisateur — hover, fluide, moderne
   ========================================================================== */

.tutor-header-profile-menu-items {
    position: relative;
}

/* Bouton profil — déclencheur du dropdown */
.tutor-header-profile-content span[role="button"] {
    font-size: 14px !important;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background-color 0.15s ease;
}

.tutor-header-profile-content span[role="button"]:hover {
    background: #f1f5f9;
}

/* Chevron rotation quand ouvert */
.tutor-header-profile-menu-items.gha-dropdown-open span[role="button"] svg {
    transform: rotate(180deg);
}

.tutor-header-profile-content span[role="button"] svg {
    transition: transform 0.2s ease;
}

/* Menu déroulant — carte flottante */
.tutor-header-submenu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08),
                0 4px 6px -4px rgba(0, 0, 0, 0.05);
    padding: 6px 0;
    min-width: 200px;
    z-index: 110;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

/* Affichage du dropdown — hover ou classe active */
.tutor-header-profile-menu-items.gha-dropdown-open .tutor-header-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Liste de liens du dropdown */
.tutor-submenu-links ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tutor-submenu-links ul li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: #475569;
    text-decoration: none;
    background: none;
    transition: color 0.15s ease;
}

.tutor-submenu-links ul li a:hover {
    color: #0f172a;
    background: none;
}

/* Icônes des items */
.tutor-submenu-links ul li a span[class*="tutor-icon"] {
    color: #94a3b8;
    transition: color 0.15s ease;
    font-size: 16px;
}

.tutor-submenu-links ul li a:hover span[class*="tutor-icon"] {
    color: #475569;
}

/* Icône de déconnexion — rouge */
.tutor-submenu-links ul li a .tutor-icon-signout {
    color: #dc2626;
}

.tutor-submenu-links ul li a:hover .tutor-icon-signout {
    color: #b91c1c;
}

/* Cacher le premier avatar (celui en dehors du dropdown) */
.tutor-header-profile-photo {
    display: none;
}


/* ==========================================================================
   6. Panier — icône et badge de quantité
   ========================================================================== */

/* Conteneur panier */
.navbar-utils .utils-cart,
.navbar-utils .cart-contents {
    position: relative;
    display: flex;
    align-items: center;
}

/* Icône SVG du panier */
.navbar-utils .btn-cart svg {
    width: 20px;
    height: 20px;
    fill: #1e293b;
    transition: fill 0.15s ease;
}

.navbar-utils .btn-cart:hover svg {
    fill: #1e40af;
}

/* Badge nombre d'articles — pastille rouge */
.navbar-utils .tutor_native_cart_count {
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    background: #dc2626;
    border-radius: 10px;
    padding: 1px 6px;
    position: absolute;
    top: -6px;
    right: -10px;
    line-height: 1.3;
}

/* Cacher le badge si le panier est vide */
.navbar-utils .tutor_native_cart_count:empty {
    display: none;
}


/* ==========================================================================
   7. Bottom Nav Bar Mobile — barre de navigation fixe en bas
   ========================================================================== */

/* Cachée sur desktop */
.gha-bottom-nav {
    display: none;
}

@media (max-width: 991px) {

    /* Affichage de la barre — fixe en bas de l'écran */
    .gha-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
        padding: 6px 0;
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    }

    /* Items — répartition en tiers égaux (compense les labels de longueur différente) */
    .gha-bottom-nav-items {
        display: flex;
        align-items: center;
        width: 100%;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .gha-bottom-nav-items li {
        flex: 1;
        display: flex;
        justify-content: center;
    }

    /* Item individuel — icône + label */
    .gha-bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        text-decoration: none;
        color: #94a3b8;
        font-size: 11px;
        font-weight: 500;
        padding: 4px 8px;
        min-width: 64px;
        transition: color 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .gha-bottom-nav-item:hover,
    .gha-bottom-nav-item:active {
        color: #1e40af;
    }

    /* Item actif — page courante */
    .gha-bottom-nav-item.active {
        color: #1e40af;
    }

    /* Icônes SVG */
    .gha-bottom-nav-item svg {
        width: 26px;
        height: 26px;
        flex-shrink: 0;
    }

    /* Label texte sous l'icône */
    .gha-bottom-nav-item span {
        line-height: 1.2;
    }

    /* Compenser la hauteur de la bottom nav sur le body */
    body {
        padding-bottom: 64px !important;
    }
}


/* Brevo chat widget — décaler au-dessus de la bottom nav sur mobile */
/* On utilise la même hauteur que la bottom nav (64px + safe-area) + 10px de marge */
@media (max-width: 991px) {
    #brevo-conversations,
    .brevo-conversations,
    [class*="brevo-conversations"] {
        bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 10px) !important;
        transition: bottom 0.2s ease !important;
    }
}

/* Toggle vue admin — décaler au-dessus de la bottom nav sur mobile */
@media (max-width: 991px) {
    .gha-admin-view-toggle-footer {
        bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 10px) !important;
    }
}


/* ==========================================================================
   8. Header Mobile — compact (logo + panier uniquement)
   ========================================================================== */

@media (max-width: 991px) {

    /* Cacher le hamburger — remplacé par la bottom nav */
    .header-default .navbar-toggler {
        display: none !important;
    }

    /* Cacher les liens texte de navigation sur mobile */
    .header-default .navbar-nav {
        display: none !important;
    }

    /* Cacher le dropdown profil sur mobile (présent dans la bottom nav) */
    .header-default .tutor-header-profile-menu-items {
        display: none !important;
    }

    /* Header compact : logo + panier seulement */
    .header-default .navbar {
        padding: 8px 16px;
        min-height: 52px;
    }

    .header-default .navbar-brand {
        flex: 1;
    }

    /* Cacher les boutons login/signup sur mobile (dans la bottom nav) */
    .header-default .gha-header-login {
        display: none !important;
    }

    /* Afficher le panier en mobile */
    .header-default .navbar-utils {
        display: flex;
        align-items: center;
    }

    /* Masquer le header au scroll vers le bas */
    .header-default.gha-header-hidden {
        transform: translateY(-100%);
    }
}


/* ==========================================================================
   9. Footer — positionnement et nettoyage
   ========================================================================== */

/* Anti-débordement horizontal — clip ne casse PAS position: sticky */
body {
    overflow-x: clip !important;
}

/* Layout flex pour coller le footer en bas sans hack JS */
#page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: clip;
}

#content {
    flex: 1;
}

/* Le footer reste en bas naturellement grâce au flex */
.site-footer {
    margin-top: auto;
}

/* Espacement avec la bottom nav sur mobile */
@media (max-width: 991px) {
    .site-footer {
        padding-bottom: 64px;
    }
}

/* Menu footer — flex wrap pour mobile */
.footer-menu .menu-footer-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 24px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-menu .menu-footer-menu li a {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.15s ease;
}

.footer-menu .menu-footer-menu li a:hover {
    color: #ffffff;
}


/* ==========================================================================
   10. Footer Mobile — stack vertical + centrage
   ========================================================================== */

@media (max-width: 991px) {

    /* Stack les colonnes du footer verticalement */
    .footer-bottom-container {
        flex-direction: column !important;
        align-items: center !important;
        gap: 16px !important;
        text-align: center;
        padding: 20px 16px !important;
    }

    /* Centrer le bloc social media */
    .footer-bottom-container .site-info {
        display: flex;
        justify-content: center;
        width: 100%;
    }

    /* Centrer les liens du menu */
    .footer-bottom-container .footer-menu {
        width: 100%;
    }

    .footer-menu .menu-footer-menu {
        justify-content: center;
        gap: 6px 16px;
    }

    /* Centrer le copyright */
    .footer-bottom-container .copyright-container {
        width: 100%;
        text-align: center;
    }

    .footer-bottom-container .copyright {
        font-size: 13px;
        opacity: 0.8;
    }

    /* Footer six variant — même traitement */
    .footer-bottom-container.footer-six {
        flex-direction: column !important;
        align-items: center !important;
        gap: 16px !important;
    }

    .footer-six .site-info-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
}
