/* ===== RESPONSIVE HEADER STYLES - HAMBURGER À 768px - CORRIGÉ ===== */

/* ==========================================
   DESKTOP OPTIMIZATIONS (768px et plus)
   Menu HORIZONTAL reste visible
   ========================================== */
@media (min-width: 768px) {
    /* S'assurer que le menu hamburger est TOUJOURS caché */
    .menu-toggle {
        display: none !important;
    }
    
    /* S'assurer que le menu est TOUJOURS visible et horizontal */
    nav {
        display: flex !important;
        order: initial !important;
        width: auto !important;
        flex: 1 !important;
        position: static !important;
        justify-content: center;
    }
    
    nav ul {
        display: flex !important;
        flex-direction: row !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        max-height: none !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow-y: visible !important;
        box-shadow: none !important;
        transform: none !important;
        gap: 2rem;
        align-items: center;
        list-style: none;
    }
    
    nav li {
        width: auto !important;
    }
    
    nav a {
        display: inline-block !important;
        padding: 0.5rem 1rem !important;
        border-bottom: none !important;
        border-left: none !important;
        width: auto !important;
        text-align: center !important;
        border-radius: var(--border-radius);
    }
    
    nav a.active {
        background: rgba(84, 175, 50, 0.1);
        color: var(--primary-color);
        font-weight: 600;
        border-left: none !important;
    }
    
    nav a.active::after {
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}

/* ==========================================
   Ajustements par plage de largeur
   ========================================== */

/* Zone 768px - 1199px */
@media (min-width: 768px) and (max-width: 1199px) {
    .header-content {
        gap: 1.5rem;
        padding: 0.75rem 0;
    }
    
    .logoimg {
        width: 220px;
        height: 46px;
    }
    
    .header-controls {
        gap: 0.75rem;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    /* Navigation horizontale visible */
    nav ul {
        gap: 1rem !important;
    }
    
    nav a {
        padding: 0.5rem 0.85rem !important;
        font-size: 0.9rem !important;
    }
}

/* Zone critique (1050px - 1199px) */
@media (min-width: 1050px) and (max-width: 1199px) {
    .container {
        padding: 0 15px;
    }
    
    .header-content {
        gap: 1rem;
    }
    
    .theme-toggle {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

/* Ajustements pour la zone basse (768px - 860px) */
@media (min-width: 768px) and (max-width: 860px) {
    .logoimg {
        width: 200px;
        height: 42px;
    }
    
    nav ul {
        gap: 0.75rem !important;
    }
    
    nav a {
        padding: 0.5rem 0.7rem !important;
        font-size: 0.875rem !important;
    }
    
    .header-content {
        gap: 1rem;
    }
}

/* ==========================================
   MOBILE - Hamburger actif
   Zone 0px - 767px
   ========================================== */
@media (max-width: 767px) {
    /* Empêcher le wrap */
    .header-content {
        flex-wrap: nowrap !important;
        gap: 0.5rem;
        align-items: center;
        padding: 0.5rem 0;
    }
    
    /* Logo flexible */
    .logo {
        flex-shrink: 1;
        min-width: 0;
        order: 1;
    }
    
    .logoimg {
        width: 200px;
        height: 42px;
        max-width: 100%;
        height: auto;
    }
    
    /* Menu hamburger VISIBLE en mobile */
    .menu-toggle {
        display: flex !important;
        flex-direction: column;
        cursor: pointer;
        gap: 5px;
        padding: 8px;
        border-radius: 8px;
        transition: all 0.3s ease;
        order: 2;
        flex-shrink: 0;
        margin-left: auto;
        z-index: 1001;
    }
    
    /* Contrôles */
    .header-controls {
        order: 3;
        gap: 0.5rem;
        flex-shrink: 0;
    }
    
    .theme-toggle {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
        flex-shrink: 0;
    }
    
    /* Navigation CACHÉE par défaut en mobile */
    nav {
        order: 4 !important;
        width: 100% !important;
        flex: 0 0 100% !important;
        position: absolute !important;
        left: 0;
        top: 100%;
    }
    
    nav ul {
        display: none !important;
        flex-direction: column !important;
        position: fixed !important;
        top: 70px;
        left: 0;
        width: 100% !important;
        max-height: calc(100vh - 70px) !important;
        background: var(--card-bg) !important;
        padding: 0 !important;
        margin: 0 !important;
        gap: 0 !important;
        overflow-y: auto !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
        z-index: 1000;
        transform: translateY(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    nav ul.active {
        display: flex !important;
        transform: translateY(0);
    }
    
    nav li {
        width: 100% !important;
    }
    
    nav a {
        display: block !important;
        padding: 0.875rem 1.5rem !important;
        border-bottom: 1px solid var(--border-color) !important;
        width: 100% !important;
        text-align: left !important;
        transition: all 0.2s ease;
    }
    
    nav li:last-child a {
        border-bottom: none !important;
    }
    
    nav a.active {
        background: rgba(84, 175, 50, 0.1);
        color: var(--primary-color);
        font-weight: 600;
        border-left: 4px solid var(--primary-color) !important;
        padding-left: calc(1.5rem - 4px) !important;
    }
    
    nav a:hover {
        background: rgba(84, 175, 50, 0.05);
    }
    
    nav a.active:hover {
        background: rgba(84, 175, 50, 0.15);
    }
    
    nav a::before,
    nav a::after {
        display: none !important;
    }
}

/* Réduction supplémentaire pour petits mobiles */
@media (max-width: 600px) {
    .logoimg {
        width: 180px;
        height: 38px;
    }
    
    .header-content {
        gap: 0.4rem;
    }
}

@media (max-width: 520px) {
    .logoimg {
        width: 160px;
        height: 34px;
    }
    
    .theme-toggle {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .menu-toggle {
        padding: 6px;
    }
}

@media (max-width: 450px) {
    .logoimg {
        width: 140px;
        height: 30px;
    }
    
    .header-content {
        gap: 0.3rem;
    }
    
    .theme-toggle {
        width: 34px;
        height: 34px;
    }
}

@media (max-width: 380px) {
    .logoimg {
        width: 120px;
        height: 26px;
    }
    
    .theme-toggle {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    .menu-toggle {
        padding: 5px;
    }
    
    .menu-toggle span {
        width: 22px;
        height: 2.5px;
    }
}

/* ==========================================
   OVERLAY
   ========================================== */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@media (min-width: 768px) {
    .menu-overlay {
        display: none !important;
    }
}

/* ==========================================
   DARK MODE ADJUSTMENTS
   ========================================== */
@media (max-width: 767px) {
    [data-theme="dark"] nav ul {
        background: var(--card-bg) !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    }
    
    [data-theme="dark"] nav a {
        border-bottom-color: var(--border-color);
        color: var(--text-color);
    }
    
    [data-theme="dark"] nav a.active {
        background: rgba(84, 175, 50, 0.15);
        border-left-color: var(--primary-color);
    }
    
    [data-theme="dark"] nav a:hover {
        background: rgba(84, 175, 50, 0.08);
    }
    
    [data-theme="dark"] nav a.active:hover {
        background: rgba(84, 175, 50, 0.2);
    }
}

/* ==========================================
   VERY LARGE SCREENS
   ========================================== */
@media (min-width: 1920px) {
    .header-content {
        gap: 2.5rem;
    }
    
    .header-controls {
        gap: 1.5rem;
    }
    
    .logoimg {
        width: 300px;
        height: 63px;
    }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    nav ul,
    .menu-overlay,
    nav a {
        transition: none !important;
    }
}
