/* ===================================
   SIDEBAR PREMIUM 3D - VERSION FINALE
   AlphaVault AI - Corrections Finales
   =================================== */

:root {
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 75px;
    --sidebar-bg: rgba(15, 20, 31, 0.95);
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --sidebar-text: #e4e6eb;
    --sidebar-text-secondary: #b0b3b8;
    --sidebar-text-light: #ffffff;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --transition-speed: 0.25s;
    --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 20px 60px rgba(0, 0, 0, 0.3), 
                      0 0 40px rgba(102, 126, 234, 0.1);
}

/* ===================================
   LAYOUT WRAPPER - FOND BLANC
   =================================== */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
    background: #f5f7fa;
    padding: 20px;
    position: relative;
}

body.dark-mode .layout-wrapper {
    background: #0f172a;
}

/* ===================================
   MAIN CONTENT - FOND BLANC
   =================================== */
.main-content {
    flex: 1;
    margin-left: calc(var(--sidebar-width) + 20px);
    transition: margin-left var(--transition-speed) var(--transition-smooth);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.sidebar.collapsed ~ .main-content {
    margin-left: calc(var(--sidebar-collapsed-width) + 20px);
}

body.dark-mode .main-content {
    background: #1e293b;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ===================================
   SIDEBAR - FLOTTANTE + GLASSMORPHISM
   =================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    color: var(--sidebar-text);
    position: fixed;
    left: 20px;
    top: 20px;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-speed) var(--transition-smooth);
    z-index: 1000;
    box-shadow: var(--shadow-premium);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* ===================================
   SIDEBAR HEADER - LOGO 3D
   =================================== */
.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 85px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.02);
}

/* Logo Container */
.logo-container {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
    transition: opacity var(--transition-speed) var(--transition-smooth);
}

/* Logo 3D */
.logo-3d {
    width: 42px;
    height: 42px;
    position: relative;
    flex-shrink: 0;
    transition: transform 0.2s ease, 
                opacity var(--transition-speed) var(--transition-smooth);
}

.logo-3d:hover {
    transform: scale(1.08);
}

.logo-svg {
    width: 100%;
    height: 100%;
}

.logo-gradient-1 {
    stop-color: #667eea;
}

.logo-gradient-2 {
    stop-color: #764ba2;
}

/* Brand Text */
.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    transition: opacity var(--transition-speed) var(--transition-smooth), 
                width var(--transition-speed) var(--transition-smooth);
}

.brand-name {
    font-size: 19px;
    font-weight: 700;
    color: var(--sidebar-text-light);
    letter-spacing: 0.3px;
    background: linear-gradient(135deg, #ffffff 0%, #667eea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    margin: 0;
    line-height: 1.2;
}

.brand-tagline {
    font-size: 10px;
    font-weight: 500;
    color: var(--accent-primary);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0.8;
}

/* ✅ Masquer complètement le logo en mode collapsed */
.sidebar.collapsed .logo-container {
    display: none;
    opacity: 0;
    pointer-events: none;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .brand-text {
    opacity: 0;
    width: 0;
}

/* ✅ Toggle Button */
.sidebar-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
    font-size: 16px;
    cursor: pointer;
    padding: 9px;
    border-radius: 10px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.4);
    transform: scale(1.05);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

.sidebar-toggle i {
    transition: transform 0.2s ease;
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* ✅ CORRECTION : Centrer le toggle parfaitement en mode collapsed */
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    align-items: center;
    padding: 25px 0;
    gap: 0;
}

/* ===================================
   SIDEBAR NAVIGATION
   =================================== */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 126, 234, 0.3) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Navigation Section */
.nav-section {
    margin-bottom: 4px;
    position: relative;
}

/* ✅ CORRECTION : Navigation Folder - Plus d'espace pour la flèche */
.nav-folder {
    width: 100%;
    background: none;
    border: none;
    color: var(--sidebar-text);
    padding: 13px 18px 13px 20px; /* ✅ Réduction du padding-right */
    display: flex;
    align-items: center;
    gap: 12px; /* ✅ Réduction du gap */
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 15px;
    font-weight: 500;
    position: relative;
    text-align: left;
}

/* Barre latérale */
.nav-folder::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 60%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 0 3px 3px 0;
    transition: width 0.15s ease;
    z-index: 1;
}

.nav-folder:hover::before {
    width: 3px;
}

.nav-folder.active::before {
    width: 4px;
}

.nav-folder:hover {
    background: var(--sidebar-hover);
}

.nav-folder.active {
    background: rgba(102, 126, 234, 0.12);
    color: var(--sidebar-text-light);
}

/* Icon */
.nav-folder i:first-child {
    font-size: 20px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.nav-folder:hover i:first-child {
    transform: scale(1.1);
    color: var(--accent-primary);
}

.nav-folder.active i:first-child {
    color: var(--accent-primary);
}

/* ✅ CORRECTION : Label avec plus d'espace à droite */
.nav-folder span {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-speed) var(--transition-smooth);
    min-width: 0; /* ✅ Important pour text-overflow */
    margin-right: 4px; /* ✅ Espace minimal */
}

/* ✅ CORRECTION : Arrow avec largeur fixe et alignée à droite */
.nav-folder .arrow {
    font-size: 11px;
    transition: transform 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
    opacity: 0.6;
    width: 16px; /* ✅ Largeur fixe */
    text-align: center;
    margin-left: auto; /* ✅ Poussé à droite */
}

.nav-folder:hover .arrow {
    opacity: 1;
}

.nav-folder.active .arrow {
    transform: rotate(180deg);
    color: var(--accent-primary);
}

/* Mode collapsed */
.sidebar.collapsed .nav-folder {
    justify-content: center;
    padding: 15px 0;
}

.sidebar.collapsed .nav-folder span,
.sidebar.collapsed .nav-folder .arrow {
    opacity: 0;
    width: 0;
    display: none;
}

/* TOOLTIPS en mode collapsed */
.sidebar.collapsed .nav-folder {
    position: relative;
}

.sidebar.collapsed .nav-folder::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 15px);
    top: 50%;
    transform: translateY(-50%) translateX(-10px);
    background: rgba(15, 20, 31, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 10000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(102, 126, 234, 0.3);
}

/* Flèche du tooltip */
.sidebar.collapsed .nav-folder::before {
    content: '';
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 7px 6px 0;
    border-color: transparent rgba(15, 20, 31, 0.95) transparent transparent;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10001;
}

.sidebar.collapsed .nav-folder:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.sidebar.collapsed .nav-folder:hover::before {
    opacity: 1;
}

/* Indicateur actif plus visible en mode collapsed */
.sidebar.collapsed .nav-folder.active {
    background: rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    margin: 4px 8px;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

.sidebar.collapsed .nav-folder.active i:first-child {
    color: var(--accent-primary);
    filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.6));
}

/* ===================================
   NAVIGATION SUBMENU
   =================================== */
.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    background: rgba(0, 0, 0, 0.15);
}

.nav-section.active .nav-submenu {
    max-height: 500px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 20px 11px 54px;
    color: var(--sidebar-text-secondary);
    text-decoration: none;
    transition: all 0.15s ease;
    font-size: 14px;
    position: relative;
    border-left: 2px solid transparent;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    background: rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    padding-left: 58px;
    border-left-color: rgba(102, 126, 234, 0.3);
}

.nav-link:hover::before {
    background: var(--accent-primary);
    transform: translateY(-50%) scale(1.2);
}

.nav-link.active {
    background: rgba(102, 126, 234, 0.08);
    color: var(--accent-primary);
    font-weight: 500;
    border-left-color: var(--accent-primary);
}

.nav-link.active::before {
    background: var(--accent-primary);
}

.nav-link i {
    font-size: 15px;
    width: 17px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-link:hover i,
.nav-link.active i {
    opacity: 1;
}

.sidebar.collapsed .nav-submenu {
    display: none;
}

/* ===================================
   SIDEBAR FOOTER
   =================================== */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 18px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.02);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--sidebar-text-secondary);
    font-size: 14px;
    transition: all 0.2s ease;
    padding: 9px;
    border-radius: 11px;
    cursor: pointer;
    position: relative;
}

.user-info:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-text);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.25);
    position: relative;
}

.user-avatar i {
    font-size: 18px;
    color: white;
}

.user-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 9px;
    height: 9px;
    background: #10b981;
    border: 2px solid var(--sidebar-bg);
    border-radius: 50%;
}

.user-details {
    flex: 1;
    overflow: hidden;
    transition: opacity var(--transition-speed) var(--transition-smooth), 
                width var(--transition-speed) var(--transition-smooth);
}

.user-name {
    font-weight: 600;
    color: var(--sidebar-text-light);
    font-size: 14px;
    margin-bottom: 2px;
}

.user-role {
    font-size: 12px;
    color: var(--accent-primary);
    opacity: 0.8;
}

/* Mode collapsed - Centrer l'avatar */
.sidebar.collapsed .user-details {
    opacity: 0;
    width: 0;
    display: none;
}

.sidebar.collapsed .user-info {
    justify-content: center;
    padding: 9px 0;
}

/* Tooltip pour l'avatar en mode collapsed */
.sidebar.collapsed .user-info::after {
    content: attr(data-user);
    position: absolute;
    left: calc(100% + 15px);
    top: 50%;
    transform: translateY(-50%) translateX(-10px);
    background: rgba(15, 20, 31, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 10000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.sidebar.collapsed .user-info:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* ===================================
   TOP HEADER
   =================================== */
.top-header {
    background: white;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 20px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

body.dark-mode .top-header {
    background: #1e293b;
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-left h1 {
    font-size: 24px;
    color: #1a1d29;
    font-weight: 600;
    margin: 0;
}

body.dark-mode .header-left h1 {
    color: var(--sidebar-text-light);
}

.mobile-toggle {
    display: none;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 22px;
    color: #1a1d29;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.mobile-toggle:hover {
    background: rgba(102, 126, 234, 0.1);
}

body.dark-mode .mobile-toggle {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.last-update {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 14px;
}

body.dark-mode .last-update {
    color: var(--sidebar-text-secondary);
}

.last-update i {
    color: var(--accent-primary);
}

/* ===================================
   CONTAINER
   =================================== */
.container {
    flex: 1;
    padding: 30px 40px;
}

.container .content {
    width: 100%;
}

/* ===================================
   RESPONSIVE - MOBILE
   =================================== */
@media (max-width: 1024px) {
    .layout-wrapper {
        padding: 0;
    }
    
    .sidebar {
        transform: translateX(-100%);
        left: 0;
        top: 0;
        height: 100vh;
        border-radius: 0;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
        border-radius: 0;
        box-shadow: none;
    }
    
    .mobile-toggle {
        display: flex;
    }
    
    .sidebar-toggle {
        display: flex;
    }

    .top-header {
        padding: 18px 20px;
    }

    .container {
        padding: 20px;
    }
}

/* Overlay mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ===================================
   OPTIMISATION PERFORMANCE
   =================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

.sidebar,
.logo-3d,
.nav-folder,
.nav-link {
    transform: translateZ(0);
    backface-visibility: hidden;
}