/* 
   HEADER - Styles du header unifié
   Navigation, authentification, sélecteur de langue
*/

/* Header principal - Dark Sparkly */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(26, 31, 58, 0.95);
    box-shadow: var(--shadow), 0 0 20px rgba(230, 57, 70, 0.15);
    height: var(--header-height);
    opacity: 1;
    border-bottom: 1px solid rgba(255, 195, 0, 0.1);
}

.header-container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1rem;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Logo Sparkly - Visible et lumineux ✨ */
.logo {
    font-size: 1.75rem;
    font-weight: 700;
    color: #FFD93D; /* Golden Glow - Sparkly brand */
    text-decoration: none;
    transition: var(--transition);
    text-shadow: 
        0 0 10px rgba(255, 217, 61, 0.3),
        0 0 20px rgba(255, 107, 157, 0.2);
    letter-spacing: 0.5px;
    font-family: 'Poppins', sans-serif;
}


.logo:hover {
    color: #FF6B9D; /* Sparkly Pink on hover */
    text-shadow: 
        0 0 15px rgba(255, 107, 157, 0.5),
        0 0 30px rgba(255, 217, 61, 0.3);
    transform: scale(1.05);
}

/* Navigation centrale */
.header-nav {
    display: flex;
    gap: 0.5rem;
}

/* Navigation invité - Style bouton moderne */
.nav-guest {
    display: flex;
    gap: 0.75rem;
}

.nav-guest a {
    font-weight: 600;
    color: #FFD93D;
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    background: transparent;
    transition: var(--transition);
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
    text-align: center;
    white-space: nowrap;
}

.nav-guest a:hover {
    color: #ffeb3b;
    background: linear-gradient(135deg, #FF7F89, #E56B75);
    border-color: #FFD93D;
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-red);
}

.nav-guest a:active {
    transform: translateY(0);
}

/* Bouton de navigation actif (page courante) */
.nav-guest a.active {
    color: #ffffff;
    background: linear-gradient(135deg, #FF7F89, #E56B75);
    border-color: #FFD93D;
    box-shadow: var(--shadow-glow-red);
    font-weight: 700;
}

.nav-guest a.active:hover {
    background: linear-gradient(135deg, #E56B75, #FF7F89);
    border-color: var(--sparkly-gold);
}

/* Navigation utilisateur connecté - Style unifié avec nav-guest */
.nav-user {
    display: flex;
    gap: 0.75rem;
}

.nav-user a {
    font-weight: 600;
    color: #FFD93D;
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    background: transparent;
    transition: var(--transition);
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
    text-align: center;
    white-space: nowrap;
}

.nav-user a:hover {
    color: #ffeb3b;
    background: linear-gradient(135deg, #FF7F89, #E56B75);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-red);
}

.nav-user a:active {
    transform: translateY(0);
}

/* Lien actif en mode connecté */
.nav-user a.active {
    color: #ffffff;
    background: linear-gradient(135deg, #FF7F89, #E56B75);
    border-color: #FFD93D;
    box-shadow: var(--shadow-glow-red);
    font-weight: 700;
}

.nav-user a.active:hover {
    background: linear-gradient(135deg, #E56B75, #FF7F89);
    border-color: var(--sparkly-gold);
}

/* Actions du header */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Bouton contact dans le header */
.contact-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    min-width: 35px;
    min-height: 35px;
    flex-shrink: 0;
    padding: 0;
    background: linear-gradient(145deg, #ff6b6b, #ff8787);
    border: none;
    cursor: pointer;
    border-radius: 50%;
    font-size: 1.5rem;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.3),
                inset 0 -2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    font-weight: bold;
    animation: contactPulse 2.5s ease-in-out infinite;
}

.contact-icon-btn span {
    position: relative;
    z-index: 1;
    display: inline-block;
    animation: contactBounce 2.5s ease-in-out infinite;
}

.contact-icon-btn:hover {
    background: linear-gradient(145deg, #ff5252, #ff6b6b);
    box-shadow: 0 12px 32px rgba(255, 107, 107, 0.45),
                inset 0 -2px 4px rgba(0, 0, 0, 0.15);
    transform: scale(1.12) translateY(-2px);
}

.contact-icon-btn:hover span {
    animation: none;
    transform: scale(1.2) rotate(10deg);
}

.contact-icon-btn:active {
    transform: scale(0.98);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3),
                inset 0 2px 4px rgba(0, 0, 0, 0.2);
}
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3),
                inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Animation de pulse */
@keyframes contactPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.6),
                    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(255, 107, 107, 0),
                    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0),
                    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
    }
}

/* Animation de bounce/rebond */
@keyframes contactBounce {
    0%, 100% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-3px);
    }
    50% {
        transform: translateY(0);
    }
    75% {
        transform: translateY(-2px);
    }
}

/* Sélecteur de langue */
.language-selector {
    position: relative;
}

.language-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
    width: 40px;
    height: 40px;
}

.language-toggle:hover {
    background: rgba(255, 195, 0, 0.1);
    box-shadow: 0 0 10px rgba(255, 195, 0, 0.2);
}

.flag-icon {
    width: 24px;
    height: 18px;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.language-dropdown {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: auto;
    background: rgba(26, 31, 58, 0.95);
    border: 1px solid rgba(255, 195, 0, 0.2);
    border-radius: 8px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    min-width: 60px;
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    z-index: 1001;
}

.language-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    gap: 0;
}

.language-option .fi {
    flex-shrink: 0;
}

.language-option:hover {
    background: rgba(255, 195, 0, 0.1);
}

.language-option:first-child {
    border-radius: 8px 8px 0 0;
}

.language-option:last-child {
    border-radius: 0 0 8px 8px;
}

/* Boutons d'authentification */
.auth-buttons {
    display: flex;
    gap: 0.75rem;
}

.auth-buttons .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-width: 85px;
    text-align: center;
    white-space: nowrap;
}

/* Info utilisateur connecté */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-greeting {
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
}

.user-info .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-width: auto;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    z-index: 10;
}

.user-info .btn-icon {
    display: none; /* Caché par défaut sur desktop */
    font-size: 1.2rem;
    line-height: 1;
}

/* Mode compact pour le bouton déconnexion sur écrans intermédiaires ou chargés */
@media (max-width: 1100px) {
    .user-info .btn {
        padding: 0;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        min-width: 0;
        background: rgba(255, 127, 137, 0.15); /* Fond rouge léger */
        color: #FF7F89; /* Icône rouge */
        border: 1px solid rgba(255, 127, 137, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
    }
    
    .user-info .btn:hover {
        background: #FF7F89;
        color: white;
        transform: scale(1.05);
        box-shadow: 0 0 12px rgba(255, 127, 137, 0.5);
        border-color: #FF7F89;
    }
    
    .user-info .btn-text {
        display: none;
    }
    
    .user-info .btn-icon {
        display: block;
    }
    
    .user-greeting {
        display: none; /* Optionnel : masquer aussi le bonjour si vraiment serré ? */
    }
    
    /* On garde le bonjour mais on le cache si < 900px */
    @media (max-width: 900px) {
        .user-greeting {
            display: none;
        }
    }
}

/* Menu burger mobile */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #ffffff;
    padding: 0.5rem;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
    position: relative;
}

.mobile-menu-toggle:hover {
    background: #050814;
}

.mobile-menu-toggle:active {
    background: rgba(255, 195, 0, 0.15);
}

/* Animation du burger quand le menu est ouvert */
.mobile-nav.active ~ .header .mobile-menu-toggle {
    color: #FF7F89;
    background: #050814;
}

/* Navigation mobile */
.mobile-nav {
    display: none; /* Hide by default */
    position: fixed;
    top: 70px; /* Fallback for variable */
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* CRITICAL: Prevent clicks when hidden */
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-nav.active {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Re-enable clicks when active */
}

.mobile-nav-content {
    background: rgba(26, 31, 58, 0.95);
    padding: 1.5rem;
    margin: 0;
    box-shadow: var(--shadow-lg), var(--shadow-glow-red);
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    border: 1px solid rgba(255, 195, 0, 0.2);
}

.mobile-nav.active .mobile-nav-content {
    transform: translateY(0);
}

.mobile-nav .header-nav {
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    display: flex;
}

.mobile-nav .nav-guest {
    flex-direction: column;
    gap: 0.75rem;
    display: flex;
}

/* Masquer nav-guest quand hidden par JS */
.mobile-nav .nav-guest[style*="display: none"],
.mobile-nav .nav-guest[style*="visibility: hidden"] {
    display: none !important;
    visibility: hidden !important;
}

.mobile-nav .nav-guest a {
    padding: 1rem 1.5rem;
    margin: 0;
    text-align: center;
    font-weight: 700;
    border-radius: var(--border-radius);
    font-size: 1.5rem;
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 1px;
    display: block;
}

.mobile-nav .nav-user {
    flex-direction: column;
    gap: 0.75rem;
    display: flex;
}

/* Masquer nav-user quand hidden par JS */
.mobile-nav .nav-user[style*="display: none"],
.mobile-nav .nav-user[style*="visibility: hidden"] {
    display: none !important;
    visibility: hidden !important;
}

.mobile-nav .nav-user a {
    padding: 1rem 1.5rem;
    text-align: center;
    font-weight: 700;
    border-radius: var(--border-radius);
    font-size: 1.5rem;
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 1px;
    display: block;
}

.mobile-nav .auth-buttons {
    flex-direction: column;
    gap: 0.75rem;
    display: flex;
}

.mobile-nav .auth-buttons .btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
}

.mobile-nav .user-info {
    flex-direction: row; /* Horizontal layout to save space */
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
}

.mobile-nav .user-greeting {
    text-align: left;
    font-size: 1.3rem;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    padding: 0;
    flex-grow: 1;
}

.mobile-nav .user-info .btn {
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 1.2rem; /* Larger icon */
    border-radius: 50%; /* Rounded button */
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 44px;
    min-height: 44px;
    line-height: 1;
}

.mobile-nav .user-info .btn:hover {
    background: #FF7F89; /* Red for logout */
    border-color: #FF7F89;
    color: white;
}

/* Responsive */

/* Tablettes en mode paysage */
@media (max-width: 1024px) and (min-width: 769px) {
    .header-container {
        padding: 0 1.5rem;
    }
    
    .header-nav {
        gap: 0.25rem;
    }
    
    .nav-guest a,
    .nav-user a {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .auth-buttons .btn {
        padding: 0.45rem 0.9rem;
        font-size: 0.85rem;
        min-width: 75px;
    }
    
    .user-greeting {
        font-size: 0.9rem;
    }
}

/* Tablettes et mobiles */
@media (max-width: 768px) {
    /* Masquer la navigation desktop uniquement (pas celle dans mobile-nav) */
    .header-container > .header-nav,
    .header-actions > .auth-buttons,
    .header-actions > .user-info {
        display: none !important;
    }
    
    /* Afficher le menu burger */
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    /* S'assurer que le contenu du menu mobile est géré par flex SAUF s'il est caché par JS */
    .mobile-nav .header-nav {
        display: flex;
        flex-direction: column;
    }
    
    .mobile-nav .nav-guest:not([style*="display: none"]):not([style*="visibility: hidden"]) {
        display: flex;
        flex-direction: column;
    }
    
    .mobile-nav .nav-user:not([style*="display: none"]):not([style*="visibility: hidden"]) {
        display: flex;
        flex-direction: column;
    }
    
    .mobile-nav .auth-buttons:not([style*="display: none"]) {
        display: flex;
        flex-direction: column;
    }
    
    .mobile-nav .user-info:not([style*="display: none"]) {
        display: flex;
        flex-direction: column;
    }
    
    /* Ajuster le header container */
    .header-container {
        padding: 0 1rem;
        gap: 0.5rem;
    }
    
    /* Dropdown langue centré sur mobile */
    .language-dropdown {
        right: 0;
        left: auto;
    }
    
    /* Header actions plus compact */
    .header-actions {
        gap: 0.5rem;
    }
    
    /* Logo légèrement plus petit */
    .logo {
        font-size: 1.35rem;
    }
}

/* Petits mobiles */
@media (max-width: 480px) {
    /* Forcer l'affichage du burger et masquer la nav DESKTOP uniquement */
    .header-container > .header-nav,
    .header-actions > .auth-buttons,
    .header-actions > .user-info {
        display: none !important;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    /* S'assurer que le contenu du menu mobile est géré par flex SAUF s'il est caché par JS */
    .mobile-nav .header-nav {
        display: flex;
        flex-direction: column;
    }
    
    .mobile-nav .nav-guest:not([style*="display: none"]):not([style*="visibility: hidden"]) {
        display: flex;
        flex-direction: column;
    }
    
    .mobile-nav .nav-user:not([style*="display: none"]):not([style*="visibility: hidden"]) {
        display: flex;
        flex-direction: column;
    }
    
    .mobile-nav .auth-buttons:not([style*="display: none"]) {
        display: flex;
        flex-direction: column;
    }
    
    .mobile-nav .user-info:not([style*="display: none"]) {
        display: flex;
        flex-direction: column;
    }
    
    /* Container ultra-compact */
    .header-container {
        padding: 0 0.75rem;
    }
    
    /* Logo encore plus petit */
    .logo {
        font-size: 1.2rem;
    }
    
    /* Bouton langue plus compact */
    .language-toggle {
        padding: 0.3rem;
        width: 36px;
        height: 36px;
    }
    
    /* Drapeaux un peu plus petits */
    .language-toggle .fi {
        width: 20px;
        height: 15px;
    }
    
    /* Menu burger plus petit */
    .mobile-menu-toggle {
        font-size: 1.3rem;
        padding: 0.3rem;
        width: 40px;
        height: 40px;
    }
    
    /* Menu mobile full screen sur petit écran */
    .mobile-nav-content {
        padding: 1rem;
    }
    
    .mobile-nav .nav-guest a,
    .mobile-nav .nav-user a {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }
    
    .mobile-nav .auth-buttons .btn {
        padding: 0.875rem;
        font-size: 0.95rem;
    }
}

/* Styles pour les drapeaux flag-icons */
.language-selector .fi {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    display: inline-block;
}

/* Emojis drapeaux - Remplacement de flag-icons */
/* Flag-icons pour drapeaux SVG colorés */
.language-toggle .fi {
    width: 32px;
    height: 24px;
    display: inline-block;
}

.language-option .fi {
    width: 32px;
    height: 24px;
    display: inline-block;
}

/* Grands écrans - Plus d'espace et meilleure visibilité */
@media (min-width: 1440px) {
    .header-container {
        max-width: 1400px;
        padding: 0 2rem;
    }
    
    .logo {
        font-size: 3.6rem;
    }
    
    .nav-guest a,
    .nav-user a {
        padding: 0.65rem 1.3rem;
        font-size: 1rem;
    }
    
    .auth-buttons .btn {
        padding: 0.55rem 1.1rem;
        font-size: 0.95rem;
        min-width: 90px;
    }
}

/* Très grands écrans */
@media (min-width: 1920px) {
    .header-container {
        max-width: 1600px;
    }
}