/* ==========================================================================
   1. BASES & LAYOUT DE L'APPLICATION
   ========================================================================== */
   * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Merriweather', Georgia, serif;
    background-color: #f8fafc;
    color: #1e293b;
    display: flex;
    min-height: 100vh;
    margin: 0;
}

/* Zone de contenu à droite du menu (Reste fixe à 70px) */
main {
    flex-grow: 1;
    padding: 0;
    margin-left: 70px; 
    min-height: 100vh;
    background-color: #f8fafc;
}

/* ==========================================================================
   2. LE HEADER / SIDEBAR LATÉRALE
   ========================================================================== */
header {
    width: 70px;
    background-color: #1e1b4b;
    color: #f1f5f9;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow-x: hidden;
    overflow-y: hidden;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
}

/* Déploiement au survol */
header:hover {
    width: 280px;
    overflow-y: auto;
}

/* Personnalisation de la scrollbar pour garder la finesse */
header::-webkit-scrollbar {
    width: 4px;
}
header::-webkit-scrollbar-track {
    background: #1e1b4b;
}
header::-webkit-scrollbar-thumb {
    background: #312e81;
    border-radius: 10px;
}

/* ==========================================================================
   3. ZONE LOGO (HAUT DE SIDEBAR)
   ========================================================================== */
.sidebar-logo {
    padding: 15px 10px;
    background-color: #110e3d;
    width: 100%;
    height: 75px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo img {
    width: auto;
    height: auto;
    max-width: 55px;
    max-height: 50px;
    display: block;
    object-fit: contain;
    transition: max-width 0.2s ease;
}

header:hover .sidebar-logo img {
    max-width: 180px;
    max-height: 55px;
}

/* ==========================================================================
   4. ZONE UTILISATEUR (AVATAR & INFOS)
   ========================================================================== */
.sidebar-user-box {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #312e81;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background-color: #6366f1;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.sidebar-user-box .user-info {
    display: flex;
    flex-direction: column; /* Force l'affichage sur deux lignes distinctes */
    gap: 2px;
}

.sidebar-user-box .user-name {
    font-size: 14px;
    font-weight: bold;
    color: #ffffff;
}

.sidebar-user-box .user-role {
    font-size: 12px;
    color: #94a3b8;
}

/* ==========================================================================
   5. NAVIGATION & LIENS DU MENU
   ========================================================================== */
.sidebar-nav ul { 
    list-style: none; 
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 22px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    width: 100%;
}

.nav-link:hover {
    background-color: #312e81;
    color: white;
}

.nav-icon {
    font-size: 18px;
    margin-right: 25px;
    flex-shrink: 0;
    text-align: center;
    width: 20px;
}

.nav-text {
    flex-grow: 1; /* Pousse tout ce qui suit (badge et picto externe) vers l'extrémité droite */
}

.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    color: #64748b;
    padding: 15px 22px 5px 22px;
}

.nav-divider {
    height: 1px;
    background-color: #312e81;
    margin: 10px 15px;
}

/* ==========================================================================
   6. BADGES, NOTIFICATIONS & ICONES EXTERNES
   ========================================================================== */
.nav-badge {
    background-color: #ef4444;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto; /* Sécurité alignement droite */
}

.nav-external-icon {
    font-size: 12px;
    color: #94a3b8;
    margin-left: auto; /* Aligne l'icône tout à droite de la ligne */
    opacity: 0;
    transition: opacity 0.2s ease;
}

header:hover .nav-external-icon {
    opacity: 1;
}

/* ==========================================================================
   7. ANIMATIONS DE TRANSITION (AFFICHAGE AU HOVER)
   ========================================================================== */
.user-info, 
.nav-text, 
.nav-section-title, 
.nav-badge {
    opacity: 0;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

header:hover .user-info, 
header:hover .nav-text, 
header:hover .nav-section-title, 
header:hover .nav-badge {
    opacity: 1;
}

/* ==========================================================================
   8. COMPOSANTS INTERNES (IFRAMES)
   ========================================================================== */
.app-iframe-container {
    width: 100%;
    height: calc(100vh - 80px);
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    background: #fff;
}

/* ==========================================================================
   CHARTE GRAPHIQUE : HOVER & ÉTAT SÉLECTIONNÉ (.selected)
   ========================================================================== */

/* --- ÉTAT HOVER (SURVOL) --- */
.nav-link:hover {
    background-color: #2e2a72; /* Fond légèrement plus clair que le bleu nuit */
    color: #ffde00; /* Le texte passe en jaune ERE au survol */
}

/* Les icônes s'illuminent en jaune ERE au survol */
.nav-link:hover .nav-icon i,
.nav-link:hover .nav-external-icon i {
    color: #ffde00;
}

/* Cas particulier pour la déconnexion : on garde un rouge d'alerte */
.logout-link:hover,
.logout-link:hover .nav-icon i {
    color: #f87171 !important;
}


/* --- ÉTAT SELECTED (PAGE ACTIVE) --- */
.nav-link.selected {
    background-color: #110e3d; /* Fond plus sombre (comme la zone logo) pour marquer l'ancrage */
    color: #ffde00; /* Texte en jaune ERE */
    border-left: 4px solid #ffde00; /* Barre verticale jaune ERE à gauche */
    padding-left: 18px; /* On réduit légèrement le padding pour compenser l'épaisseur de la bordure (22px - 4px) */
    font-weight: 600;
}

/* L'icône de la page sélectionnée reste jaune ERE par défaut */
.nav-link.selected .nav-icon i {
    color: #ffde00;
}

/* ==========================================================================
   TITRES DE SECTION & SÉPARATEURS (GESTION REPLIÉE)
   ========================================================================== */

/* --- Titres de section (IDR, Suivi, Raccourcis...) --- */
.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    color: #64748b;
    padding: 15px 22px 5px 22px;
    
    /* Par défaut, quand le menu est replié : on masque complètement et on supprime l'espace */
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* On l'affiche uniquement au survol du header */
header:hover .nav-section-title {
    display: block;
    opacity: 1;
}

/* ==========================================================================
   LIGNES DE SÉPARATION (.nav-divider) VISIBLES TOUT LE TEMPS
   ========================================================================== */
   .nav-divider {
    display: block; /* Toujours visible */
    height: 1px;
    background-color: #312e81; /* Ta couleur bleu-violet */
    
    /* Marges très fines par défaut quand le menu est replié (5px haut/bas, 15px gauche/droite) */
    margin: 5px 15px; 
    transition: margin 0.25s ease;
}

/* Quand le menu s'ouvre, on redonne un peu d'espace pour aérer le texte */
header:hover .nav-divider {
    margin: 12px 15px;
}