/**
 * MENU RESPONSIVE PROFESSIONNEL
 * Mobile-first design avec hamburger menu
 * Compatible tous appareils (320px à 4K)
 */

/* ============================================
   VARIABLES
   ============================================ */
:root {
    --header-height-mobile: 64px;
    --header-height-desktop: 80px;
    --menu-width-mobile: 85%;
    --menu-max-width: 360px;
    --transition-speed: 0.3s;
    --overlay-color: rgba(0, 0, 0, 0.7);
}

/* ============================================
   MENU HAMBURGER (Mobile)
   ============================================ */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 2px solid rgba(110, 231, 183, 0.3);
    border-radius: 8px;
    cursor: pointer;
    padding: 8px;
    z-index: 10002;
    transition: all 0.3s ease;
    position: relative;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex !important;
    }
}

.mobile-menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background: #6ee7b7;
    border-radius: 3px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.mobile-menu-toggle:hover {
    border-color: rgba(110, 231, 183, 0.6);
    background: rgba(110, 231, 183, 0.05);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* Animation hamburger -> X */
.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translateY(10px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translateY(-10px);
}

/* ============================================
   OVERLAY
   ============================================ */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-color);
    z-index: 10000;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* ============================================
   HEADER - Desktop par défaut
   ============================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(110, 231, 183, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.site-header .container.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    gap: 1rem;
}

.site-header .logo {
    flex-shrink: 0;
    margin-right: 1rem;
}

/* ============================================
   MENU - Desktop
   ============================================ */
.header-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.header-menu .menu-item,
.header-menu .btn {
    white-space: nowrap;
}

/* En-tête mobile (caché sur desktop) */
.mobile-menu-header {
    display: none;
}

/* Avatar profil desktop */
.avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(110, 231, 183, 0.5);
    background: linear-gradient(135deg, rgba(110, 231, 183, 0.2), rgba(96, 165, 250, 0.2));
    transition: all 0.3s ease;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.avatar-btn:hover {
    border-color: #6ee7b7;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(110, 231, 183, 0.4);
}

.avatar-btn .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-btn .avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #6ee7b7;
    background: linear-gradient(135deg, rgba(110, 231, 183, 0.2), rgba(96, 165, 250, 0.2));
}

/* Classes de visibilité */
.hide-on-mobile {
    display: flex;
}

.show-on-mobile {
    display: none;
}

/* ============================================
   DROPDOWNS - Desktop
   ============================================ */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-trigger {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.nav-dropdown-trigger:hover {
    color: #6ee7b7;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 200px;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(110, 231, 183, 0.2);
    border-radius: 8px;
    padding: 0.5rem 0;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1002;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Afficher au hover avec délai */
.nav-dropdown:hover .nav-dropdown-menu {
    display: block;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
    animation: dropdown-appear 0.2s ease forwards;
    transition-delay: 0.1s;
}

/* Garder ouvert quand on survole le menu */
.nav-dropdown-menu:hover {
    display: block;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
}

/* Garder ouvert plus longtemps */
.nav-dropdown:hover {
    /* Reste ouvert tant qu'on survole le trigger OU le menu */
}

.nav-dropdown.active .nav-dropdown-menu {
    display: block;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
}

@keyframes dropdown-appear {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-dropdown-menu a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #e6eef6;
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-dropdown-menu a:hover {
    background: rgba(110, 231, 183, 0.1);
    color: #6ee7b7;
}

/* ============================================
   TABLETTE (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .site-header .container.nav {
        padding: 0.75rem 1.5rem;
    }
    
    .header-menu {
        gap: 0.5rem;
    }
    
    .header-menu .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

/* ============================================
   Cacher "Bienvenue" sur mobile
   ============================================ */
.welcome-user.hide-mobile {
    display: inline-flex;
    align-items: center;
}

/* ============================================
   MOBILE (< 768px)
   ============================================ */
@media (max-width: 767px) {
    /* Cacher le bienvenue sur mobile */
    .welcome-user.hide-mobile {
        display: none !important;
    }
    
    /* Gestion visibilité avatar vs texte */
    .hide-on-mobile {
        display: none !important;
    }
    
    /* Sur mobile, afficher tous les boutons menu normalement */
    .header-menu .menu-item {
        display: flex;
    }
    
    /* Header fixe sur mobile */
    .site-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--header-height-mobile);
    }
    
    .site-header .container.nav {
        padding: 0.75rem 1rem;
        height: 100%;
    }
    
    /* Logo réduit */
    .logo {
        font-size: 1rem;
    }
    
    .logo-img {
        max-height: 36px;
    }
    
    .logo-text {
        display: none; /* Masquer le texte sur très petit écran */
    }
    
    /* Afficher le bouton hamburger */
    .mobile-menu-toggle {
        display: flex;
    }
    
    /* Afficher l'overlay */
    .mobile-menu-overlay {
        display: block;
    }
    
    /* Menu latéral mobile */
    .header-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: var(--menu-width-mobile);
        max-width: var(--menu-max-width);
        height: 100vh;
        background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
        backdrop-filter: blur(16px);
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
        z-index: 10001;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        transition: right var(--transition-speed) ease;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0;
        padding-bottom: 100px;
        border-left: 1px solid rgba(110, 231, 183, 0.2);
    }
    
    .header-menu.mobile-open {
        right: 0;
    }
    
    /* En-tête du menu mobile */
    .mobile-menu-header {
        display: block;
        padding: 1.5rem 1rem;
        background: linear-gradient(135deg, rgba(110, 231, 183, 0.1), rgba(96, 165, 250, 0.1));
        border-bottom: 1px solid rgba(110, 231, 183, 0.2);
    }
    
    .mobile-user-info {
        display: flex;
        align-items: center;
        gap: 1rem;
    }
    
    .mobile-user-avatar,
    .mobile-user-avatar-placeholder {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid #6ee7b7;
        flex-shrink: 0;
    }
    
    .mobile-user-avatar-placeholder {
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, rgba(110, 231, 183, 0.2), rgba(96, 165, 250, 0.2));
        color: #6ee7b7;
        font-weight: 700;
        font-size: 1.2rem;
    }
    
    .mobile-user-name {
        font-weight: 700;
        font-size: 1.1rem;
        margin-bottom: 0.25rem;
        text-shadow: 0 0 8px currentColor;
    }
    
    .mobile-user-role {
        font-size: 0.8rem;
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    /* Items du menu mobile */
    .header-menu > a,
    .header-menu > .menu-item,
    .header-menu .btn:not(.nav-dropdown-trigger) {
        width: 100%;
        margin: 0;
        padding: 1rem 1.25rem;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        text-align: left;
        justify-content: flex-start;
        gap: 0.75rem;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
    }
    
    /* Dropdowns sur mobile - ne pas appliquer les styles généraux */
    .header-menu .nav-dropdown {
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .header-menu .btn i {
        min-width: 20px;
        text-align: center;
    }
    
    .header-menu .btn:hover,
    .header-menu .btn:active {
        background: rgba(110, 231, 183, 0.1);
        border-color: rgba(110, 231, 183, 0.2);
    }
    
    /* Bouton Messages avec badge */
    .messages-btn {
        position: relative;
    }
    
    .message-badge {
        position: static !important;
        margin-left: auto;
    }
    
    /* Dropdowns sur mobile */
    .nav-dropdown {
        width: 100%;
        flex-direction: column;
        position: relative;
        isolation: isolate;
        display: flex;
    }
    
    .nav-dropdown-trigger {
        width: 100%;
        padding: 1rem 1.25rem;
        justify-content: space-between;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        position: relative;
        z-index: 2;
        flex-shrink: 0;
        align-items: center;
    }
    
    /* Ajuster l'alignement des icônes et texte dans les dropdowns */
    .nav-dropdown-trigger i {
        min-width: 20px;
        text-align: center;
        margin-right: 0.75rem;
    }
    
    .nav-dropdown-trigger .fa-chevron-down {
        margin-right: 0;
        margin-left: auto;
    }
    
    .nav-dropdown.active .nav-dropdown-trigger {
        background: rgba(110, 231, 183, 0.1);
        border-bottom-color: transparent;
    }
    
    /* Reset complet des dropdowns en mobile */
    .header-menu .nav-dropdown-menu {
        position: relative !important;
        width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        background: rgba(0, 0, 0, 0.3) !important;
        padding: 0 !important;
        margin: 0 !important;
        top: 0 !important;
        left: 0 !important;
        opacity: 0 !important;
        transform: none !important;
        transition: max-height 0.3s ease, opacity 0.3s ease !important;
        pointer-events: none !important;
        /* Caché par défaut */
        display: block !important;
        visibility: hidden !important;
        max-height: 0 !important;
        overflow: hidden !important;
        z-index: 1 !important;
        order: 2;
    }
    
    .header-menu .nav-dropdown.active .nav-dropdown-menu {
        visibility: visible !important;
        max-height: 500px !important;
        overflow: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    
    .header-menu .nav-dropdown-menu a {
        padding: 0.875rem 1.25rem 0.875rem 2.5rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.03);
        display: block !important;
        color: #e2e8f0 !important;
        text-decoration: none;
        pointer-events: auto !important;
        cursor: pointer !important;
        position: relative !important;
    }
    
    .header-menu .nav-dropdown-menu a:hover,
    .header-menu .nav-dropdown-menu a:active {
        background: rgba(110, 231, 183, 0.1);
    }
    
    /* Avatar bouton */
    .avatar-btn {
        order: -1; /* Placer en haut */
        padding: 1rem 1.25rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .avatar-img {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
    
    /* Bouton déconnexion en bas */
    .header-menu a[href="logout.php"] {
        margin-top: auto;
        background: rgba(239, 68, 68, 0.1);
        border-top: 2px solid rgba(239, 68, 68, 0.3);
    }
    
    /* Padding body pour header fixe */
    body {
        padding-top: var(--header-height-mobile);
    }
    
    /* Empêcher scroll du body quand menu ouvert */
    body.menu-open {
        overflow: hidden;
    }
}

/* ============================================
   PETIT MOBILE (< 375px)
   ============================================ */
@media (max-width: 374px) {
    .mobile-menu-toggle {
        width: 40px;
        height: 40px;
    }
    
    .header-menu {
        width: 95%;
    }
    
    .mobile-user-avatar,
    .mobile-user-avatar-placeholder {
        width: 40px;
        height: 40px;
    }
}

/* ============================================
   WIDGETS SOCIAUX (Twitch/YouTube)
   ============================================ */
.social-widgets {
    position: fixed;
    left: 14px;
    top: calc(var(--site-header-height, 80px) + 10px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 998;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.social-widgets.hidden {
    transform: translateX(-120px);
    opacity: 0;
    pointer-events: none;
}

.widget-close-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: rgba(239, 68, 68, 0.9);
    border: 1.5px solid rgba(15, 23, 42, 0.8);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    z-index: 10;
    transition: all 0.2s ease;
}

.widget-close-btn:hover {
    background: rgba(239, 68, 68, 1);
    transform: scale(1.1);
}

.widget-toggle-btn {
    position: fixed;
    left: 14px;
    top: calc(var(--site-header-height, 80px) + 10px);
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #9146ff, #7c3aed);
    border: 2px solid rgba(145, 70, 255, 0.5);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 998;
    box-shadow: 0 4px 12px rgba(145, 70, 255, 0.4);
    transition: all 0.3s ease;
}

.widget-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(145, 70, 255, 0.6);
}

.widget-toggle-btn.hidden {
    display: none;
}

/* Masquer widgets sur mobile par défaut */
@media (max-width: 767px) {
    .social-widgets,
    .widget-toggle-btn,
    .widget-close-btn {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

/* Tablette : garder mais plus petit */
@media (min-width: 768px) and (max-width: 1024px) {
    .social-widgets {
        left: 8px;
        top: calc(var(--site-header-height, 80px) + 8px);
    }
    
    .twitch-widget,
    .youtube-widget {
        width: 70px;
    }
    
    .twitch-widget img,
    .youtube-widget img {
        width: 50px !important;
        height: 50px !important;
        max-width: 50px !important;
        max-height: 50px !important;
    }
}

/* ============================================
   GRAND ÉCRAN (> 1440px)
   ============================================ */
@media (min-width: 1440px) {
    .site-header .container.nav {
        padding: 1.25rem 3rem;
    }
    
    .header-menu {
        gap: 1rem;
    }
}
