/* ========================================
   LAYOUT (Sidebar & Main Content)
   ======================================== */

/* --- SIDEBAR (Fixe à gauche) --- */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 240px; /* Largeur par défaut */
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden; 
}

/* ÉTAT RÉDUIT (Géré via la classe sur HTML pour éviter le flash) */
html.sidebar-collapsed .app-sidebar,
.app-sidebar.collapsed {
    width: 72px;
}

/* Header Logo */
.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0;
}

.app-logo-text {
    font-weight: 700;
    font-size: 18px;
    margin-left: 12px;
    color: var(--text-primary);
    transition: opacity 0.2s ease;
    opacity: 1;
}

html.sidebar-collapsed .app-logo-text,
.app-sidebar.collapsed .app-logo-text {
    opacity: 0;
    pointer-events: none;
}

/* --- ZONE NAVIGATION (SCROLLABLE) --- */
.sidebar-nav { 
    flex: 1; /* Prend tout l'espace libre */
    padding: 16px 12px; 
    display: flex; 
    flex-direction: column; 
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar invisible/fine */
.sidebar-nav::-webkit-scrollbar { width: 0px; background: transparent; }

.nav-item {
    display: flex; align-items: center; padding: 12px;
    color: var(--text-secondary); text-decoration: none;
    border-radius: 10px; transition: all 0.2s ease;
    white-space: nowrap; overflow: hidden; 
    min-height: 48px; flex-shrink: 0;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: rgba(59, 130, 246, 0.1); color: var(--accent-blue); border: 1px solid rgba(59, 130, 246, 0.2); }

.nav-icon { font-size: 20px; min-width: 24px; text-align: center; display: flex; justify-content: center; }
.nav-text { margin-left: 12px; font-weight: 500; font-size: 14px; transition: opacity 0.2s ease; opacity: 1; }

html.sidebar-collapsed .nav-text,
.app-sidebar.collapsed .nav-text { opacity: 0; width: 0; margin-left: 0; }

/* --- ZONE PARAMÈTRES (FIXE BAS) --- */
/* Ceci corrige le bug de positionnement de "Migration" */
.sidebar-settings {
    padding: 0 12px 16px 12px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0; /* Ne rétrécit jamais */
    background: var(--bg-secondary);
}

.settings-title {
    padding: 16px 0 8px 12px;
    font-size: 11px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px; opacity: 0.8;
    white-space: nowrap; overflow: hidden;
    transition: opacity 0.2s ease;
}

html.sidebar-collapsed .settings-title,
.app-sidebar.collapsed .settings-title {
    opacity: 0; height: 0; padding: 0; margin: 0; /* Cache le titre "Paramètres" en mode réduit */
}

/* --- FOOTER (TOGGLE) --- */
.sidebar-footer { 
    padding: 16px; 
    border-top: 1px solid var(--border-color); 
    display: flex; justify-content: flex-end; 
    background: var(--bg-secondary);
    flex-shrink: 0;
    z-index: 2;
}

html.sidebar-collapsed .sidebar-footer,
.app-sidebar.collapsed .sidebar-footer { justify-content: center; }

#sidebar-toggle {
    background: transparent; border: 1px solid var(--border-color); color: var(--text-muted);
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
#sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    margin-left: 240px; 
    width: calc(100% - 240px);
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
    display: flex; flex-direction: column;
}

html.sidebar-collapsed .main-content {
    margin-left: 72px;
    width: calc(100% - 72px);
}

.container { width: 100%; max-width: 1400px; margin: 0 auto; padding: 24px; }

/* Responsive */
@media (max-width: 768px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; width: 100% !important; }
}