/* static/css/sidebar.css */
/* Sidebar Collapsible au Hover - Financial Precision */

/* === CSS LAYOUT VARIABLES === */
:root {
    --sidebar-width: 80px;
}

/* En locked-open : la variable passe à 250px → main-content et top-bar s'ajustent automatiquement */
body[data-sidebar-state="locked-open"] {
    --sidebar-width: 250px;
}

/* --- RESET & BASE --- */
body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: var(--bg-body);
}

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* --- SIDEBAR COLLAPSIBLE --- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 80px; /* Collapsed width */
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    transition: width 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    z-index: 1000;
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.1);
}

/* Expanded state géré par data-attributes — voir bloc STATE MACHINE en bas */

/* --- SIDEBAR HEADER --- */
.sidebar-header {
    padding: 0 24px 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    min-height: 48px;
}

.logo-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.sidebar-logo-img {
    width: 32px;
    height: 32px;
    border-radius: 0;
    object-fit: contain;
    flex-shrink: 0;
}

.logo-link:hover .logo {
    opacity: 0.8;
}

.sidebar-header .logo {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    color: white;
    white-space: nowrap;
    letter-spacing: -0.04em;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

/* Logo visible — géré par data-attributes STATE MACHINE */

/* Logo icon (always visible) — remplacé par .sidebar-logo-img */

/* margin-right logo icon — géré par data-attributes STATE MACHINE */

/* --- NAVIGATION --- */
.sidebar-nav {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 16px;
}

.nav-item {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    transition: background var(--transition-base), color var(--transition-base), box-shadow var(--transition-base);
    display: flex;
    align-items: center;
    gap: 16px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    position: relative;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* Icônes personnalisées */
.nav-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.7);
    transition: color var(--transition-base), transform var(--transition-base);
}

/* Text label (hidden when collapsed) */
.nav-item span {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

/* Nav labels visibles — géré par data-attributes STATE MACHINE */

/* Hover state */
.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
}

.nav-item:hover .nav-icon {
    color: rgba(255, 255, 255, 1);
    transform: scale(1.08);
}

/* Active state */
.nav-item.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(30, 58, 138, 0.3);
}

.nav-item.active .nav-icon {
    color: white;
}

/* Active indicator */
.nav-item.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background: white;
    border-radius: 0 4px 4px 0;
}


/* --- SIDEBAR BOTTOM - Zone Configuration --- */
.sidebar-bottom {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Items secondaires (zone basse) - légèrement plus discrets */
.sidebar-bottom .nav-item {
    opacity: 0.7;
    padding: 12px 16px;
}

.sidebar-bottom .nav-item .nav-icon {
    width: 20px;
    height: 20px;
}

.sidebar-bottom .nav-item:hover {
    opacity: 1;
}

.sidebar-bottom .nav-item.active {
    opacity: 1;
}

/* --- MAIN CONTENT AREA --- */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100vw - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease-in-out, width 0.3s ease-in-out;
    box-sizing: border-box;
    min-width: 0;
}

/* Top Bar */
.top-bar {
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    width: calc(100vw - var(--sidebar-width));
    z-index: 100;
    padding: 12px 24px;
    height: 64px;
    transition: left 0.3s ease-in-out, width 0.3s ease-in-out;
    box-sizing: border-box;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform var(--transition-slow);
}

/* Shift géré par transition left sur .top-bar — voir STATE MACHINE */

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 24px;
}

/* Dark mode toggle switch */
.dark-mode-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    margin-right: 12px;
    display: flex;
    align-items: center;
}

.dmt-track {
    position: relative;
    display: flex;
    align-items: center;
    width: 62px;
    height: 34px;
    border-radius: 17px;
    border: 1px solid var(--border-color);
    background: transparent;
    box-sizing: border-box;
}

.dmt-thumb {
    position: absolute;
    top: 50%;
    left: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transform: translateY(-50%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

.dmt-icon {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.dmt-icon svg {
    width: 14px;
    height: 14px;
}

/* Light mode: soleil actif, lune estompée */
.dmt-sun  { color: var(--text-main);   opacity: 1;    }
.dmt-moon { color: var(--text-muted);  opacity: 0.4;  }

.page-title {
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
    letter-spacing: -0.03em;
    white-space: nowrap;
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary-light) 0%, #dbeafe 100%);
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
    font-family: 'Inter', sans-serif;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.user-avatar:hover {
    transform: scale(1.08);
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.15);
}

/* Dropdown plan badge */
.dropdown-plan {
    display: block;
    margin-top: 4px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

.badge-pro {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
}

.badge-free {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Content Wrapper — padding strictement symétrique, jamais de max-width ni margin: auto */
.content-wrapper {
    padding-top: 80px;
    padding-bottom: 2rem;
    padding-left: 2rem;
    padding-right: 2rem;
    width: 100%;
    box-sizing: border-box;
}

/* Upload Section */
.upload-section {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
    transition: box-shadow var(--transition-base);
}

.upload-section:hover {
    box-shadow: var(--shadow-lg);
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
    /* Une seule variable suffit : force 80px quel que soit l'état sidebar */
    body {
        --sidebar-width: 80px;
    }

    .sidebar {
        width: 80px;
    }

    .sidebar-header .logo,
    .nav-item span {
        display: none;
    }

    .top-bar {
        padding: 20px;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .content-wrapper {
        padding-top: 80px;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        padding-bottom: 1.5rem;
    }
}

/* --- BOTTOM NAV MOBILE (≤ 480px — style Instagram) --- */
@media (max-width: 480px) {
    /* Sidebar passe en barre de navigation en bas */
    body {
        --sidebar-width: 0px;
    }

    body[data-sidebar-state="locked-open"] {
        --sidebar-width: 0px;
    }

    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100% !important;
        height: 58px;
        flex-direction: row;
        padding: 0;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.25);
        transition: none;
        overflow: visible;
    }

    /* Masquer le header (logo) */
    .sidebar-header {
        display: none;
    }

    /* Masquer les items secondaires (Paramètres, Ressources, Contact) */
    .sidebar-bottom {
        display: none;
    }

    /* Masquer l'item Abonnement (moins utile au quotidien) */
    .sidebar-nav .nav-item:first-child {
        display: none;
    }

    /* Nav horizontale */
    .sidebar-nav {
        flex-direction: row;
        flex-grow: 1;
        padding: 0;
        gap: 0;
        justify-content: space-around;
        align-items: stretch;
    }

    /* Chaque item : colonne icône + label */
    .nav-item {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 3px;
        padding: 8px 4px;
        border-radius: 0;
        white-space: nowrap;
    }

    /* Afficher les labels sous les icônes — petits */
    .nav-item span {
        display: block;
        opacity: 1;
        transform: none;
        font-size: 9px;
        font-weight: 500;
        color: rgba(255, 255, 255, 0.6);
        letter-spacing: 0;
    }

    .nav-item.active span {
        color: white;
    }

    .nav-icon {
        width: 20px;
        height: 20px;
    }

    /* Active indicator : trait en haut */
    .nav-item.active {
        background: transparent;
        box-shadow: none;
        border-top: 2px solid var(--primary-color);
    }

    /* Contenu principal : pleine largeur + padding bas pour la barre */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding-bottom: 68px;
    }

    /* Masquer le bouton hamburger de la topbar */
    .sidebar-toggle-btn {
        display: none;
    }

    /* Topbar : pleine largeur */
    .top-bar {
        left: 0 !important;
        width: 100% !important;
        padding: 0 16px;
    }
}

/* --- SIDEBAR TOGGLE BUTTON --- */
.sidebar-toggle-btn {
    background: none;
    border: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: background var(--transition-fast), color var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn:hover {
    background: var(--bg-subtle);
    color: var(--primary-color);
}

.sidebar-toggle-btn svg {
    transition: transform var(--transition-fast);
}

.sidebar-toggle-btn:hover svg {
    transform: scale(1.1);
}

/* --- SIDEBAR STATE MACHINE (CSS piloté par data-attributes JS) --- */

/* États HOVERED (survol en mode default) et LOCKED-OPEN */
body[data-sidebar-state="default"][data-sidebar-hovered="true"] .sidebar,
body[data-sidebar-state="locked-open"] .sidebar {
    width: 250px;
    box-shadow: 8px 0 10px rgba(15, 23, 42, 0.2);
}

/* Shift layout géré par --sidebar-width CSS variable (voir :root / body[locked-open] en haut) */

/* Logo texte visible */
body[data-sidebar-state="default"][data-sidebar-hovered="true"] .sidebar .sidebar-header .logo,
body[data-sidebar-state="locked-open"] .sidebar .sidebar-header .logo {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.1s;
}

/* Labels nav visibles */
body[data-sidebar-state="default"][data-sidebar-hovered="true"] .sidebar .nav-item span,
body[data-sidebar-state="locked-open"] .sidebar .nav-item span {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.1s;
}

/* Icône logo : marge droite quand élargie */
body[data-sidebar-state="default"][data-sidebar-hovered="true"] .sidebar .sidebar-header::before,
body[data-sidebar-state="locked-open"] .sidebar .sidebar-header::before {
    margin-right: 12px;
}

/* État LOCKED-CLOSED : pas de règle additionnelle → sidebar reste à 80px (base CSS) */
