/* ============================================
   SIDEBAR PRO - DESIGN PREMIUM UX/UI LIGHT
   Transport Fleet Management System
   ============================================ */

:root {
    /* Couleurs catégories */
    --color-missions: #3B82F6;      /* Bleu */
    --color-maintenance: #F97316;   /* Orange */
    --color-flotte: #06B6D4;        /* Cyan */
    --color-finance: #8B5CF6;       /* Violet */
    --color-dashboard: #EAB308;     /* Jaune */
    --color-reporting: #10B981;     /* Vert */
    --color-comptabilite: #EC4899;  /* Rose */
    --color-conformite: #14B8A6;    /* Teal */
    --color-settings: #6B7280;      /* Gris */
    
    /* Couleurs base - LIGHT THEME */
    --sidebar-bg: #FFFFFF;
    --sidebar-bg-light: #F8FAFC;
    --sidebar-text: #1E293B;
    --sidebar-text-muted: #64748B;
    --sidebar-hover: #F1F5F9;
    --sidebar-active: #3B82F6;
    --sidebar-border: #E2E8F0;
    --sidebar-width: 280px;
    --sidebar-collapsed: 72px;
}

/* ============================================
   BASE SIDEBAR
   ============================================ */
.sidebar-pro {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
    border-right: 1px solid var(--sidebar-border);
}

/* ============================================
   TOGGLE BUTTON
   ============================================ */
.sidebar-toggle {
    position: absolute;
    right: -12px;
    top: 24px;
    width: 24px;
    height: 24px;
    background: var(--sidebar-active);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1051;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.sidebar-toggle:hover {
    transform: scale(1.1);
    background: #2563EB;
}

.sidebar-toggle i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

/* ============================================
   BRAND / LOGO
   ============================================ */
.sidebar-brand {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-logo-full {
    max-width: 160px;
    height: auto;
    transition: opacity 0.3s ease;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    display: none;
    transition: opacity 0.3s ease;
    background: linear-gradient(135deg, var(--sidebar-active), #2563EB);
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    color: white;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* ============================================
   NAVIGATION
   ============================================ */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-border) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--sidebar-text-muted);
}

/* ============================================
   CATEGORY
   ============================================ */
.nav-category {
    margin-bottom: 4px;
}

.nav-category-header {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    gap: 12px;
}

.nav-category-header:hover {
    background: var(--sidebar-hover);
}

.nav-category-header:focus {
    outline: none;
    background: var(--sidebar-hover);
}

.nav-category-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

/* ============================================
   ICON COLORS BY CATEGORY
   ============================================ */
.nav-category-icon.missions { 
    background: rgba(59, 130, 246, 0.15); 
    color: var(--color-missions); 
}
.nav-category-icon.maintenance { 
    background: rgba(249, 115, 22, 0.15); 
    color: var(--color-maintenance); 
}
.nav-category-icon.flotte { 
    background: rgba(6, 182, 212, 0.15); 
    color: var(--color-flotte); 
}
.nav-category-icon.finance { 
    background: rgba(139, 92, 246, 0.15); 
    color: var(--color-finance); 
}
.nav-category-icon.dashboard { 
    background: rgba(234, 179, 8, 0.15); 
    color: var(--color-dashboard); 
}
.nav-category-icon.reporting { 
    background: rgba(16, 185, 129, 0.15); 
    color: var(--color-reporting); 
}
.nav-category-icon.comptabilite { 
    background: rgba(236, 72, 153, 0.15); 
    color: var(--color-comptabilite); 
}
.nav-category-icon.conformite { 
    background: rgba(20, 184, 166, 0.15); 
    color: var(--color-conformite); 
}
.nav-category-icon.settings { 
    background: rgba(107, 114, 128, 0.15); 
    color: var(--color-settings); 
}

/* ============================================
   CATEGORY TITLE & ARROW
   ============================================ */
.nav-category-title {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-category-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
    color: var(--sidebar-text-muted);
}

.nav-category-header[aria-expanded="true"] .nav-category-arrow {
    transform: rotate(180deg);
}

/* ============================================
   BADGE
   ============================================ */
.nav-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: #EF4444;
    color: white;
    margin-left: auto;
    margin-right: 8px;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============================================
   CATEGORY MENU
   ============================================ */
.nav-category-menu {
    padding-left: 48px;
    padding-right: 12px;
    display: none;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease-out;
}

.nav-category-menu.show {
    display: block;
}

/* ============================================
   ACTIVE CATEGORY STYLES
   ============================================ */

/* Category containing active item */
.nav-category.has-active {
    position: relative;
}

.nav-category.has-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--sidebar-active);
    border-radius: 0 3px 3px 0;
}

/* Header of category with active child */
.nav-category.has-active > .nav-category-header {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.08), transparent);
    color: var(--sidebar-text);
}

.nav-category.has-active > .nav-category-header .nav-category-title {
    color: var(--sidebar-active);
    font-weight: 600;
}

.nav-category.has-active > .nav-category-header .nav-category-icon {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Category open state */
.nav-category.is-open > .nav-category-header {
    background: var(--sidebar-hover);
}

/* ============================================
   MENU ITEMS
   ============================================ */
.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin: 2px 0;
    color: var(--sidebar-text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.2s ease;
    gap: 10px;
    position: relative;
}

.nav-item:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-hover);
    transform: translateX(4px);
    text-decoration: none;
}

.nav-item.active {
    color: white;
    background: linear-gradient(135deg, var(--sidebar-active), #2563EB);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    transform: translateX(2px);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: white;
    border-radius: 2px;
}

.nav-item.active i {
    transform: scale(1.1);
}

.nav-item.active:hover {
    background: linear-gradient(135deg, var(--sidebar-active), #2563EB);
    transform: translateX(2px);
}

.nav-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   FOOTER
   ============================================ */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--sidebar-bg-light);
    border-radius: 12px;
    border: 1px solid var(--sidebar-border);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--sidebar-active), #2563EB);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    display: block;
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    color: var(--sidebar-text-muted);
    font-size: 12px;
}

.logout-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sidebar-text-muted);
    border-radius: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.logout-btn:hover {
    background: #EF4444;
    color: white;
}

/* ============================================
   ACTIVE CATEGORY STYLES
   ============================================ */
.nav-category.has-active > .nav-category-header {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), transparent);
    color: var(--sidebar-active);
    font-weight: 600;
}

.nav-category.has-active > .nav-category-header .nav-category-icon {
    transform: scale(1.05);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.nav-category.has-active > .nav-category-header .nav-category-arrow {
    color: var(--sidebar-active);
    font-weight: 600;
}

/* Highlight parent category when a child item is active */
.nav-category-header.has-active-child {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.08), transparent);
}

/* ============================================
   COLLAPSED MODE
   ============================================ */
.sidebar-pro.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-pro.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

.sidebar-pro.collapsed .sidebar-logo-full {
    display: none;
}

.sidebar-pro.collapsed .sidebar-logo-icon {
    display: flex;
    margin: 0 auto;
}

.sidebar-pro.collapsed .nav-category-title,
.sidebar-pro.collapsed .nav-category-arrow,
.sidebar-pro.collapsed .nav-badge,
.sidebar-pro.collapsed .user-info {
    display: none;
}

.sidebar-pro.collapsed .nav-category-header {
    justify-content: center;
    padding: 12px;
}

.sidebar-pro.collapsed .nav-category-icon {
    margin: 0;
}

.sidebar-pro.collapsed .nav-category-menu {
    position: absolute;
    left: var(--sidebar-collapsed);
    top: 0;
    width: 220px;
    background: var(--sidebar-bg);
    border-radius: 0 12px 12px 0;
    padding: 8px;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--sidebar-border);
    z-index: 1052;
}

.sidebar-pro.collapsed .nav-category {
    position: relative;
}

.sidebar-pro.collapsed .user-profile {
    justify-content: center;
    padding: 8px;
}

.sidebar-pro.collapsed .logout-btn {
    display: none;
}

/* Tooltip for collapsed mode */
.sidebar-pro.collapsed .nav-category-header[data-category]:hover::after {
    content: attr(data-category);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 1053;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--sidebar-border);
    text-transform: capitalize;
}

/* ============================================
   MAIN CONTENT ADJUSTMENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
}

.sidebar-pro.collapsed ~ .main-content,
body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* ============================================
   MOBILE & RESPONSIVE
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    background: var(--sidebar-active);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 24px;
    z-index: 1030;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: #2563EB;
    transform: scale(1.05);
}

@media (max-width: 991.98px) {
    .sidebar-pro {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    
    .sidebar-pro.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding-top: 70px;
    }
}

@media (max-width: 575.98px) {
    .sidebar-pro {
        width: 100%;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.nav-category-menu.show .nav-item {
    animation: slideIn 0.2s ease forwards;
}

.nav-category-menu.show .nav-item:nth-child(1) { animation-delay: 0.02s; }
.nav-category-menu.show .nav-item:nth-child(2) { animation-delay: 0.04s; }
.nav-category-menu.show .nav-item:nth-child(3) { animation-delay: 0.06s; }
.nav-category-menu.show .nav-item:nth-child(4) { animation-delay: 0.08s; }
.nav-category-menu.show .nav-item:nth-child(5) { animation-delay: 0.1s; }
.nav-category-menu.show .nav-item:nth-child(6) { animation-delay: 0.12s; }
.nav-category-menu.show .nav-item:nth-child(7) { animation-delay: 0.14s; }
.nav-category-menu.show .nav-item:nth-child(8) { animation-delay: 0.16s; }

/* Hover effects on icons */
.nav-category-header:hover .nav-category-icon {
    transform: scale(1.1);
}

/* Active category highlight */
.nav-category.has-active > .nav-category-header .nav-category-icon {
    box-shadow: 0 0 0 2px currentColor;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.nav-category-header:focus-visible,
.nav-item:focus-visible {
    outline: 2px solid var(--sidebar-active);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .sidebar-pro,
    .nav-category-arrow,
    .nav-category-icon,
    .nav-item,
    .sidebar-toggle i,
    .nav-category-menu.show .nav-item {
        transition: none;
        animation: none;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .sidebar-pro,
    .sidebar-overlay,
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}
