/* ========================================
   MODERN SIDEBAR - Design Moderne & Responsive
   ======================================== */

:root {
    /* --sidebar-width: 280px; */
    --sidebar-width-minimized: 80px;
    --sidebar-bg-gradient: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --sidebar-bg-gradient-hover: linear-gradient(180deg, #334155 0%, #1e293b 100%);
    --sidebar-accent-color: #3b82f6;
    --sidebar-accent-hover: #2563eb;
    --sidebar-text-primary: #f8fafc;
    --sidebar-text-secondary: #cbd5e1;
    --sidebar-text-muted: #94a3b8;
    --sidebar-border-color: rgba(255, 255, 255, 0.1);
    --sidebar-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    --sidebar-shadow-hover: 0 15px 50px rgba(59, 130, 246, 0.2);
    --sidebar-transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), margin 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --sidebar-transition-fast: width 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), padding 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ========================================
   LAYOUT - Sidebar et Header côte à côte
   ======================================== */

/* Sidebar fixée à gauche, pleine hauteur */
@media (min-width: 992px) {
    [data-kt-app-sidebar-fixed=true] .app-sidebar,
    .app-sidebar {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        height: 100vh !important;
        z-index: 110 !important;
    }

    /* Header commence après la sidebar - avec transition synchronisée */
    [data-kt-app-header-fixed=true] .app-header {
        /* left: var(--sidebar-width, 280px) !important; */
        /* width: calc(100% - var(--sidebar-width, 280px)) !important; */
        z-index: 100 !important;
        height: var(--bs-app-header-height, 70px) !important;
        min-height: var(--bs-app-header-height, 70px) !important;
        max-height: var(--bs-app-header-height, 70px) !important;
        transition: left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), margin-left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    }

    /* Header s'adapte quand sidebar minimisée */
    [data-kt-app-sidebar-minimize=on] .app-header {
        left: var(--sidebar-width-minimized, 80px) !important;
        width: calc(100% - var(--sidebar-width-minimized, 80px)) !important;
    }
}

/* ========================================
   SIDEBAR PRINCIPALE
   ======================================== */

#kt_app_sidebar {
    background: var(--sidebar-bg-gradient) !important;
    border-right: 1px solid var(--sidebar-border-color) !important;
    box-shadow: var(--sidebar-shadow) !important;
    width: var(--sidebar-width) !important;
    transition: var(--sidebar-transition) !important;
    position: relative;
    overflow: visible !important;
    will-change: width;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Optimisation pour la transition du wrapper principal */
.app-wrapper {
    transition: margin-left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), padding-left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    will-change: margin-left, padding-left;
}

.app-main {
    transition: margin-left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), padding-left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    will-change: margin-left, padding-left;
}

#kt_app_content {
    transition: margin-left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), padding-left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    will-change: margin-left, padding-left;
}

#kt_app_sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    background-size: 200% 100%;
    animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Logo Section */
.app-sidebar-logo {
    padding: 1rem 1.25rem !important;
    border-bottom: 1px solid var(--sidebar-border-color) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    backdrop-filter: blur(10px);
    position: relative;
    height: var(--bs-app-header-height, 70px) !important;
    min-height: var(--bs-app-header-height, 70px) !important;
    max-height: var(--bs-app-header-height, 70px) !important;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    transition: padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

[data-kt-app-sidebar-minimize="on"] .app-sidebar-logo {
    padding: 1rem 0.75rem !important;
    justify-content: center;
}

.app-sidebar-logo-text {
    transition: opacity 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s, width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), max-width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-width: 160px;
    overflow: hidden;
}

/* Nom de l'entreprise - ne pas déborder */
.sidebar-company-name {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Type de l'entreprise - ne pas déborder */
.sidebar-company-type {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

[data-kt-app-sidebar-minimize="on"] .app-sidebar-logo-text {
    opacity: 0;
    width: 0;
    max-width: 0;
    overflow: hidden;
    transition: opacity 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94), width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), max-width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.app-sidebar-logo::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--sidebar-accent-color), transparent);
}

/* Toggle Button */
#kt_app_sidebar_toggle,
.app-sidebar-toggle {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    border: 2px solid #60a5fa !important;
    backdrop-filter: blur(10px);
    transition: var(--sidebar-transition) !important;
    z-index: 120 !important;
    position: relative;
}

#kt_app_sidebar_toggle svg,
.app-sidebar-toggle svg {
    color: #ffffff !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

#kt_app_sidebar_toggle:hover,
.app-sidebar-toggle:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    border-color: #93c5fd !important;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6), 0 0 0 4px rgba(59, 130, 246, 0.3) !important;
}

/* Menu Wrapper */
.app-sidebar-menu {
    padding: 1rem 0 !important;
    overflow: hidden;
    transition: padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

.app-sidebar-wrapper {
    padding: 0 0.75rem !important;
    overflow-y: auto;
    overflow-x: hidden;
    transition: padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

[data-kt-app-sidebar-minimize="on"] .app-sidebar-wrapper {
    padding: 0 0.5rem !important;
}

/* Menu Headings (Titles) */
.menu-heading {
    color: var(--sidebar-text-muted) !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.15em !important;
    text-transform: uppercase !important;
    padding: 1rem 1rem 0.5rem 1rem !important;
    margin-bottom: 0.5rem !important;
    position: relative;
}

.menu-heading::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 12px;
    background: var(--sidebar-accent-color);
    border-radius: 0 2px 2px 0;
    transform: translateY(-50%);
}

/* Menu Items */
.menu-item {
    margin-bottom: 0.25rem !important;
    border-radius: 12px !important;
    overflow: hidden;
    transition: margin 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

.menu-link {
    padding: 0.875rem 1rem !important;
    border-radius: 12px !important;
    color: var(--sidebar-text-secondary) !important;
    transition: padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), justify-content 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), color 0.3s ease, background 0.3s ease, transform 0.3s ease !important;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: transparent !important;
    border: 1px solid transparent !important;
}

.menu-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: var(--sidebar-accent-color);
    border-radius: 0 4px 4px 0;
    transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.menu-link:hover {
    color: var(--sidebar-text-primary) !important;
    background: rgba(59, 130, 246, 0.1) !important;
    border-color: rgba(59, 130, 246, 0.2) !important;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.menu-link:hover::before {
    width: 4px;
}

.menu-link.active,
.menu-link[aria-current="page"] {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.05)) !important;
    color: var(--sidebar-text-primary) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.menu-link.active::before,
.menu-link[aria-current="page"]::before {
    width: 4px;
}

/* Menu Icons */
.menu-icon {
    width: 24px !important;
    height: 24px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: margin 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.3s ease, color 0.3s ease !important;
}

.menu-link:hover .menu-icon {
    transform: scale(1.1);
    color: var(--sidebar-accent-color) !important;
}

.menu-link.active .menu-icon,
.menu-link[aria-current="page"] .menu-icon {
    color: var(--sidebar-accent-color) !important;
}

/* Menu Title */
.menu-title {
    font-size: 0.95rem !important;
    font-weight: 500 !important;
    flex: 1;
    transition: var(--sidebar-transition) !important;
}

/* Menu Arrow (for accordions) */
.menu-arrow {
    transition: var(--sidebar-transition) !important;
    color: var(--sidebar-text-muted) !important;
}

/* Submenu */
.menu-sub {
    padding: 0.1rem 0 0.1rem 0.7rem !important;
}

.menu-sub .menu-link {
    padding: 0.625rem 1rem !important;
    font-size: 0.875rem !important;
    border-radius: 8px !important;
}

.menu-sub .menu-link:hover {
    background: rgba(59, 130, 246, 0.08) !important;
    transform: translateX(2px);
}

.menu-bullet {
    width: 6px !important;
    height: 6px !important;
}

.bullet-dot {
    background: var(--sidebar-text-muted) !important;
    border-radius: 50% !important;
}

.menu-sub .menu-link:hover .bullet-dot {
    background: var(--sidebar-accent-color) !important;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

/* Active Indicator */
.menu-link.active .badge-circle,
.menu-link[aria-current="page"] .badge-circle {
    background: var(--sidebar-accent-color) !important;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* ========================================
   SIDEBAR MINIMIZED STATE
   ======================================== */

[data-kt-app-sidebar-minimize="on"] #kt_app_sidebar {
    width: var(--sidebar-width-minimized) !important;
}

/* Masquer le texte immédiatement lors de la fermeture */
[data-kt-app-sidebar-minimize="on"] .menu-title,
[data-kt-app-sidebar-minimize="on"] .menu-heading,
[data-kt-app-sidebar-minimize="on"] .menu-arrow {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94), width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), max-width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

/* Afficher le texte avec délai lors de l'ouverture */
.menu-title,
.menu-heading,
.menu-arrow {
    transition: opacity 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s, width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), max-width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

[data-kt-app-sidebar-minimize="on"] .menu-link {
    justify-content: center;
    padding: 0.875rem !important;
    transition: padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), justify-content 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

.menu-link {
    transition: padding 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), justify-content 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

[data-kt-app-sidebar-minimize="on"] .menu-icon {
    margin: 0 !important;
    transition: margin 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

.menu-icon {
    transition: margin 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Mobile (≤767px) */
@media (max-width: 767px) {
    #kt_app_sidebar {
        width: 100% !important;
        max-width: 320px !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4) !important;
    }

    .app-sidebar-logo {
        padding: 1.25rem 1rem !important;
        min-height: 70px;
    }

    .menu-link {
        padding: 1rem !important;
        font-size: 0.95rem !important;
    }

    .menu-sub {
        padding-left: 2rem !important;
    }
}

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    #kt_app_sidebar {
        width: 260px !important;
    }

    .menu-link {
        padding: 0.75rem 0.875rem !important;
    }
}

/* Small Desktop (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    #kt_app_sidebar {
        width: 270px !important;
    }
}

/* Large Desktop (≥1200px) */
@media (min-width: 1200px) {
    #kt_app_sidebar {
        width: var(--sidebar-width) !important;
    }

    /* Hover effect on desktop */
    #kt_app_sidebar:hover {
        box-shadow: var(--sidebar-shadow-hover) !important;
    }
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

.app-sidebar-wrapper::-webkit-scrollbar {
    width: 6px;
}

.app-sidebar-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.app-sidebar-wrapper::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.app-sidebar-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.5);
}

/* ========================================
   ANIMATIONS & TRANSITIONS
   ======================================== */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.menu-item {
    animation: slideIn 0.3s ease-out backwards;
}

.menu-item:nth-child(1) { animation-delay: 0.05s; }
.menu-item:nth-child(2) { animation-delay: 0.1s; }
.menu-item:nth-child(3) { animation-delay: 0.15s; }
.menu-item:nth-child(4) { animation-delay: 0.2s; }
.menu-item:nth-child(5) { animation-delay: 0.25s; }
.menu-item:nth-child(6) { animation-delay: 0.3s; }

/* ========================================
   ACCESSIBILITY & FOCUS STATES
   ======================================== */

.menu-link:focus {
    outline: 2px solid var(--sidebar-accent-color);
    outline-offset: 2px;
    border-radius: 12px;
}

.menu-link:focus-visible {
    background: rgba(59, 130, 246, 0.15) !important;
}

/* ========================================
   DARK MODE SUPPORT (if needed)
   ======================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --sidebar-bg-gradient: linear-gradient(180deg, #0f172a 0%, #020617 100%);
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    #kt_app_sidebar {
        display: none !important;
    }
}

