/*
 * =======================================
 *          STYLES SURCHARGÉS POUR LE HEADER
 * =======================================
 * Ce fichier contient les nouvelles règles pour le menu principal.
 * Il est chargé après style.css pour en surcharger les règles.
 */

/* --- Réinitialisation et ajustements des styles du header original --- */
header {
    padding: 10px 25px;
}
.logo-container {
    gap: 15px;
}
.logo-container img {
    margin-right: 0;
}
.logo-container h1 {
    font-size: 22px;
}

/* --- Conteneurs Flexbox --- */
.nav-and-controls,
.header-controls,
.user-info,
.user-info .profile-link,
.lang-switcher {
    display: flex;
    align-items: center;
}

.nav-and-controls {
    gap: 30px;
}
.main-nav ul {
    gap: 25px;
}
.header-controls {
    gap: 20px;
}
.user-info {
    gap: 12px;
}
.user-info .profile-link {
    gap: 10px;
}
.lang-switcher {
    gap: 5px;
}

/* --- Styles des éléments du header --- */
.main-nav a::after {
    left: 50%;
    transform: translateX(-50%);
}
.user-info span {
    margin-right: 0;
    font-size: 0.9rem;
}
.user-info .header-avatar {
    width: 38px;
    height: 38px;
}
.logout-link {
    font-size: 0.85rem;
    opacity: 0.7;
    border: none;
    padding: 0;
    border-radius: 0;
    background-color: transparent;
    transition: opacity 0.2s;
}
.logout-link:hover {
    opacity: 1;
    background-color: transparent;
    color: var(--couleur-texte);
    border-color: transparent;
}
.theme-switcher {
    background-color: transparent;
    border: 1px solid var(--couleur-bordure);
    line-height: 1;
    padding: 6px 10px;
}
.hamburger, .close-menu {
    display: none;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--couleur-texte);
    z-index: 1001;
}


/*
 * =======================================
 *          DESIGN RESPONSIVE DU HEADER
 * =======================================
 */

/* --- Écrans moyens (tablettes) --- */
@media (max-width: 1200px) {
    .user-info span {
        display: none; /* Cache le "Bonjour, ..." */
    }
    .nav-and-controls { gap: 20px; }
    .main-nav ul { gap: 20px; }
}

/* --- Petits écrans (mobiles) --- */
@media (max-width: 992px) {
    /* --- Style du bouton Hamburger --- */
    .hamburger {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 30px;
        height: 24px;
        padding: 0;
        z-index: 1001; /* Au-dessus du contenu, mais sous le menu */
    }
    .hamburger span {
        width: 100%;
        height: 3px;
        background-color: var(--couleur-texte);
        border-radius: 3px;
        transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    }

    /* --- Masque le menu par défaut sur mobile --- */
    .nav-and-controls {
        display: none;
    }

    /* --- Quand le menu est ouvert --- */
    header.menu-is-open .nav-and-controls {
        /* --- Style du menu en plein écran (Overlay) --- */
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        padding: 20px;
        gap: 2.5rem; /* Espace entre la nav et les contrôles */

        /* --- Effet visuel moderne (Glassmorphism) --- */
        background-color: rgba(255, 255, 255, 0.85); /* Fond blanc semi-transparent */
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);

        /* --- Animation d'apparition --- */
        animation: fadeInMenu 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    }
    
    /* --- Adaptation pour le mode sombre --- */
    .dark-mode header.menu-is-open .nav-and-controls {
        background-color: rgba(45, 55, 72, 0.85); /* Fond sombre semi-transparent */
    }

    /* --- Animation du bouton hamburger en croix --- */
    header.menu-is-open .hamburger {
        position: fixed; /* Garde la croix au même endroit */
        top: 28px; /* Ajustement pour aligner avec le padding du header */
        right: 25px;
    }
    header.menu-is-open .hamburger span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }
    header.menu-is-open .hamburger span:nth-child(2) {
        opacity: 0;
    }
    header.menu-is-open .hamburger span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }

    /* --- On n'utilise plus le bouton 'X' textuel --- */
    .close-menu {
        display: none;
    }

    /* --- Style des liens de navigation --- */
    .nav-and-controls .main-nav,
    .nav-and-controls .main-nav ul {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        gap: 0.5rem;
        margin: 0;
        padding: 0;
    }

    .main-nav a {
        display: block;
        width: 100%;
        max-width: 350px;
        padding: 12px 20px;
        font-size: 1.3rem; /* Police "moyenne" */
        font-weight: 400;
        text-align: center;
        border-radius: 8px;
        color: var(--couleur-texte);
        transition: background-color 0.2s, color 0.2s;
    }
    .main-nav a::after { display: none; }

    .main-nav a.active {
        font-weight: 600;
        background-color: #f38500;
    }
    .dark-mode .main-nav a.active {
        background-color: rgb(46, 44, 128);;
    }

    /* --- Conteneur des contrôles du bas --- */
    .header-controls {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        width: 100%;
        max-width: 350px;
        margin-top: auto; /* Pousse en bas */
        padding-bottom: 1rem;
    }

    /* --- Infos utilisateur (pour éviter tout overflow) --- */
    .user-info {
        display: flex;
        flex-direction: column; /* Empile l'avatar/nom et la déconnexion */
        align-items: center;
        gap: 1rem;
        width: 100%;
    }
    .user-info .profile-link {
        gap: 12px;
        font-size: 1rem;
    }
    .user-info span {
        display: inline-block; /* Ré-affiche le nom */
    }
    .logout-link { font-size: 0.9rem; opacity: 0.8; }

    /* --- Switcher de langue et thème --- */
    .lang-switcher { font-size: 1.2rem; }
    .notification-icon { font-size: 24px; }
    .theme-switcher {
        width: auto;
        padding: 8px 15px;
        border-radius: 20px;
    }

    /* --- Animation d'apparition du menu --- */
    @keyframes fadeInMenu {
        from { opacity: 0; transform: scale(0.98); }
        to { opacity: 1; transform: scale(1); }
    }
}

/* -------------------------------
   FIX MENU MOBILE — insérer dans header.css ou style.css
   Ne pas créer de nouveau fichier CSS.
   Commentaires en français.
   ------------------------------- */

/* Conteneur mobile : occupe toute la hauteur, gestion par flex */
@media (max-width: 992px) {
    header.menu-is-open .nav-and-controls {
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        justify-content: space-between; /* espace entre navigation et section user */
        height: 100vh; /* occupe toute la fenêtre */
        padding: 0.6rem 0.9rem;
        overflow: hidden; /* pas de scroll inutile (on gère le contenu) */
    }

    /* Partie liens : colonne principale, prend tout l'espace disponible */
    header.menu-is-open .nav-and-controls .main-nav {
        display: flex;
        flex-direction: column;
        gap: 0.85rem; /* espacement entre éléments, réduit si petit écran */
        flex: 1 1 auto;
        align-items: center;
        justify-content: center;
        padding-top: 0.3rem;
    }

    /* Liens : taille et alignement */
    header.menu-is-open .nav-and-controls .main-nav a {
        display: block;
        width: 100%;
        text-align: center;
        padding: 0.6rem 0.5rem;
        font-size: 1rem; /* lisible */
        line-height: 1.1;
        white-space: nowrap; /* éviter wrapping qui casse l'alignement */
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Section utilisateur en bas (cloche / langue / avatar / déconnect) */
    header.menu-is-open .nav-and-controls .header-controls {
        display: flex;
        flex-direction: column;
        gap: 0.45rem;
        align-items: center;
        justify-content: flex-end;
        padding-bottom: 0.6rem;
    }

    /* Icônes et avatar : taille raisonnable */
    header.menu-is-open .nav-and-controls .header-controls .header-avatar {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        object-fit: cover; /* garder le crop circulaire */
    }

    /* Indicateur / cloche */
    header.menu-is-open .nav-and-controls .header-controls .notification-icon {
        width: 34px;
        height: 34px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}


/* Réduction d'espacement sur très petits écrans */
@media (max-width: 380px) {
  header.menu-is-open .nav-and-controls {
    padding: 0.4rem 0.6rem;
  }
  header.menu-is-open .nav-and-controls .main-nav a {
    font-size: 0.94rem;
    padding: 0.5rem 0.3rem;
  }
  header.menu-is-open .nav-and-controls .header-controls .header-avatar { width: 42px; height: 42px; }
}

/* Si l'écran très étroit : diminuer légèrement les gaps sans scroller */
@media (max-width: 340px) {
  header.menu-is-open .nav-and-controls .main-nav { gap: 0.6rem; }
  header.menu-is-open .nav-and-controls .main-nav a { font-size: 0.9rem; padding: 0.45rem 0.2rem; }
}

/* S'assurer qu'aucun élément ne provoque un overflow horizontal */
header.menu-is-open .nav-and-controls {
  min-width: 0;
  max-width: 100%;
}

/* Si malgré tout le contenu dépasse (rare), réduire le padding du haut en dernier recours */
@media (max-height: 600px) and (orientation: portrait) {
  header.menu-is-open .nav-and-controls { padding-top: 0.2rem; padding-bottom: 0.4rem; }
}

/* FIN du bloc menu mobile — commentaires en français pour tracer les modifications */