/**
 * ============================================
 * NAV FIXES - Corrections définitives
 * CHARGER CE FICHIER EN DERNIER !
 * ============================================
 * 
 * Ce fichier corrige les conflits entre :
 * - nav.css (nouveau système : .nav-desktop, .nav-mobile)
 * - theme-lorcana.css (ancien système : .nav, .header-inner)
 * - app.css / mobile-sidebar.css
 *
 * Le HTML utilise : .header > .header-container > 
 *   .logo + .nav-desktop + .header-actions(
 *     .theme-switcher, .lang-selector, .menu-toggle
 *   )
 *   + .nav-mobile (sidebar)
 */

/* ============================================
   1. HEADER - Sticky + overflow fix
   Lorcana has overflow:hidden AND overflow:visible!
   in multiple places. Force consistent behavior.
   ============================================ */
.header,
[data-theme="lorcana"] .header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    overflow: visible !important;
}
/* Compenser la hauteur du header fixe */
body {
    padding-top: 60px !important;
}

/* header-inner doesn't exist in new HTML but Lorcana targets it */
[data-theme="lorcana"] .header-inner {
    overflow: visible !important;
}

/* ============================================
   2. SKIP LINK - Invisible unless focused
   ============================================ */
.skip-link {
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.skip-link:focus {
    position: fixed !important;
    top: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    padding: 0.75rem 1.5rem !important;
    background: var(--accent-purple, #7c3aed) !important;
    color: white !important;
    font-weight: 600 !important;
    border-radius: 0 0 8px 8px !important;
    z-index: 99999 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
}

/* ============================================
   3. MOBILE NAV SIDEBAR - Hidden by default
   ============================================ */
.nav-mobile {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 300px !important;
    max-width: 85vw !important;
    transform: translateX(100%) !important;
    visibility: hidden !important;
    z-index: 1002 !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 0.3s !important;
}

.nav-mobile.active {
    transform: translateX(0) !important;
    visibility: visible !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 0s !important;
}

[data-theme="lorcana"] .nav-mobile {
    background: #1E2140 !important;
    border-left: 1px solid rgba(211, 186, 132, 0.25) !important;
}

/* ============================================
   4. OVERLAY - Hidden by default
   ============================================ */
.nav-overlay {
    position: fixed !important;
    inset: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    z-index: 1001 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease,
                visibility 0s linear 0.3s !important;
}

.nav-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: opacity 0.3s ease,
                visibility 0s linear 0s !important;
}

[data-theme="lorcana"] .nav-overlay {
    background: rgba(28, 28, 26, 0.75) !important;
}

/* ============================================
   5. DESKTOP (1024px+)
   Show: nav-desktop, user-menu, auth-buttons,
         logout, theme-switcher, lang-selector
   Hide: hamburger
   ============================================ */
@media (min-width: 1024px) {
    .nav-desktop,
    [data-theme="lorcana"] .nav-desktop {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: static !important;
        transform: none !important;
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        width: auto !important;
        height: auto !important;
        flex: 1 !important;
        justify-content: center !important;
    }

    .menu-toggle,
    [data-theme="lorcana"] .menu-toggle {
        display: none !important;
    }

    .user-menu,
    .auth-buttons {
        display: flex !important;
    }

    .logout-form {
        display: block !important;
    }

    .theme-switcher {
        display: flex !important;
        visibility: visible !important;
    }

    .lang-selector {
        display: flex !important;
        visibility: visible !important;
    }
}

/* ============================================
   6. MOBILE & TABLET (< 1024px)
   ============================================
   Hide: nav-desktop, user-menu, auth-buttons,
         logout, theme-switcher, lang-selector
   Show: hamburger (full size!)
   
   theme-lorcana.css has these conflicting rules:
   
   Line 2011 (NO media query!):
     [data-theme="lorcana"] .theme-switcher { 
       display: flex !important;
       visibility: visible !important;
     }
   
   Line 1582 (@media 768px-1023px):
     [data-theme="lorcana"] .menu-toggle { 
       display: none !important; 
     }
   
   To beat these, we use HIGHER SPECIFICITY selectors.
   ============================================ */
@media (max-width: 1023px) {

    /* --- Hide desktop nav --- */
    .nav-desktop,
    [data-theme="lorcana"] .nav-desktop {
        display: none !important;
    }

    /* --- Hide desktop-only elements --- */
    .user-menu,
    [data-theme="lorcana"] .user-menu,
    .auth-buttons,
    [data-theme="lorcana"] .auth-buttons,
    .logout-form,
    [data-theme="lorcana"] .logout-form {
        display: none !important;
    }

    /* --- THEME SWITCHER: Force hidden ---
       4-level specificity to beat the non-media-query
       [data-theme="lorcana"] .theme-switcher rule */
    .theme-switcher {
        display: none !important;
    }
    html[data-theme="lorcana"] .header .header-actions .theme-switcher {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        flex: 0 0 0 !important;
        min-width: 0 !important;
    }

    /* --- LANG SELECTOR: Force hidden --- */
    .lang-selector {
        display: none !important;
    }
    html[data-theme="lorcana"] .header .header-actions .lang-selector {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        flex: 0 0 0 !important;
        min-width: 0 !important;
    }

    /* --- HAMBURGER: Force visible & full size ---
       Beat the 768-1023 hide rule from Lorcana */
    .menu-toggle {
        display: flex !important;
    }
    html[data-theme="lorcana"] .header .header-actions .menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        flex-shrink: 0 !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        cursor: pointer !important;
        pointer-events: auto !important;
    }

    /* Hamburger lines - MUST be full-width bars, not dots */
    .hamburger {
        position: relative !important;
        width: 22px !important;
        height: 16px !important;
        display: block !important;
    }

    html[data-theme="lorcana"] .menu-toggle .hamburger {
        width: 22px !important;
        height: 16px !important;
    }

    .hamburger span,
    html[data-theme="lorcana"] .menu-toggle .hamburger span {
        position: absolute !important;
        left: 0 !important;
        width: 22px !important;
        height: 2px !important;
        border-radius: 2px !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .hamburger span:nth-child(1),
    html[data-theme="lorcana"] .hamburger span:nth-child(1) { 
        top: 0 !important; 
        bottom: auto !important;
    }
    .hamburger span:nth-child(2),
    html[data-theme="lorcana"] .hamburger span:nth-child(2) { 
        top: 7px !important; 
        bottom: auto !important;
    }
    .hamburger span:nth-child(3),
    html[data-theme="lorcana"] .hamburger span:nth-child(3) { 
        top: 14px !important; 
        bottom: auto !important;
    }
    
    /* Hamburger to X animation (when open) */
    .menu-toggle[aria-expanded="true"] .hamburger span:nth-child(1) {
        top: 7px !important;
        transform: rotate(45deg) !important;
    }
    .menu-toggle[aria-expanded="true"] .hamburger span:nth-child(2) {
        opacity: 0 !important;
    }
    .menu-toggle[aria-expanded="true"] .hamburger span:nth-child(3) {
        top: 7px !important;
        transform: rotate(-45deg) !important;
    }

    /* --- Logo: clean, no button look --- */
    .logo,
    [data-theme="lorcana"] .logo {
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    .logo-icon,
    [data-theme="lorcana"] .logo-icon {
        background: none !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* --- Header actions: flex container --- */
    .header-actions,
    [data-theme="lorcana"] .header-actions {
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem !important;
        flex-shrink: 0 !important;
    }
}

/* ============================================
   7. LORCANA THEME - Visual-only (not layout)
   ============================================ */
[data-theme="lorcana"] .header {
    background: linear-gradient(180deg, 
        rgba(55, 59, 112, 0.98) 0%, 
        rgba(42, 45, 84, 0.96) 100%) !important;
    border-bottom: 2px solid #B89D5E !important;
}

[data-theme="lorcana"] .user-btn,
[data-theme="lorcana"] .lang-toggle,
[data-theme="lorcana"] .logout-btn {
    background: rgba(55, 59, 112, 0.6) !important;
    border-color: rgba(211, 186, 132, 0.25) !important;
}

[data-theme="lorcana"] .user-btn:hover,
[data-theme="lorcana"] .lang-toggle:hover {
    background: rgba(211, 186, 132, 0.15) !important;
}

[data-theme="lorcana"] .theme-switcher {
    background: rgba(55, 59, 112, 0.6) !important;
    border-color: rgba(211, 186, 132, 0.25) !important;
}

[data-theme="lorcana"] .theme-btn.active {
    background: linear-gradient(135deg, #D3BA84, #B89D5E) !important;
    color: #1C1C1A !important;
}

[data-theme="lorcana"] .logout-btn:hover {
    background: rgba(231, 76, 60, 0.2) !important;
    border-color: rgba(231, 76, 60, 0.4) !important;
    color: #ff6b6b !important;
}

/* Hamburger bars color */
[data-theme="lorcana"] .hamburger span {
    background: var(--parchment, #E3CAA8) !important;
}

[data-theme="lorcana"] .menu-toggle:hover {
    background: rgba(211, 186, 132, 0.15) !important;
}

/* ============================================
   8. Z-INDEX HIERARCHY
   ============================================ */
.nav-overlay { z-index: 1001 !important; }
.nav-mobile { z-index: 1002 !important; }
.lang-dropdown { z-index: 1003 !important; }
.toast-container { z-index: 1100 !important; }
.lorcana-spinner-overlay { z-index: 1200 !important; }
.cookie-banner, #cookie-consent { z-index: 999 !important; }

/* ============================================
   9. BODY SCROLL LOCK
   ============================================ */
body.nav-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* ============================================
   10. STARS NAV BADGE
   ============================================ */
[data-theme="lorcana"] .nav-star-badge,
[data-theme="lorcana"] .stars-nav-badge {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}