/**
 * Professional Sidebar Menu Enhancement
 * Modern, clean sidebar design
 */

/* Sidebar Container - High Specificity - Light Theme */
aside.app-sidebar.sidebar-scroll,
.app-sidebar.sidebar-scroll,
.app-sidebar {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
    background-color: #f8fafc !important;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05) !important;
    color: #334155 !important;
    border-right: 1px solid #e2e8f0 !important;
}

/* Override any dark background */
.app-sidebar,
aside.app-sidebar {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
    background-color: #f8fafc !important;
}

/* Sidebar Header - Light Theme */
.main-sidebar-header,
.app-sidebar .main-sidebar-header {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%) !important;
    background-color: #f8fafc !important;
    padding: 20px !important;
    border-bottom: 2px solid #e2e8f0 !important;
}

.main-sidebar-header .main-logo {
    filter: none !important;
}

/* User Profile Section - Light Theme */
.app-sidebar__user,
.app-sidebar .app-sidebar__user {
    background: white !important;
    border-radius: 10px !important;
    padding: 20px !important;
    margin: 15px !important;
    border: 1px solid #e2e8f0 !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

.app-sidebar__user:hover {
    background: #f8fafc !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.app-sidebar__user .avatar {
    border: 3px solid #e2e8f0 !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
}

.app-sidebar__user h4,
.app-sidebar__user .user-info h4,
.app-sidebar .app-sidebar__user h4 {
    color: #1e293b !important;
    font-weight: 700 !important;
    margin-top: 10px !important;
}

.app-sidebar__user .text-muted,
.app-sidebar__user .mb-0.text-muted,
.app-sidebar .app-sidebar__user .text-muted {
    color: #64748b !important;
    font-size: 13px !important;
}

/* Category Headers - Light Theme */
.side-item-category,
.side-menu .side-item-category,
.app-sidebar .side-item-category {
    color: #64748b !important;
    font-weight: 700 !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 1.5px !important;
    padding: 15px 20px 10px !important;
    margin-top: 10px !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

/* Menu Items - Light Theme */
.side-menu__item,
.side-menu .side-menu__item,
.app-sidebar .side-menu__item,
.app-sidebar ul.side-menu li a.side-menu__item {
    color: #475569 !important;
    padding: 12px 20px !important;
    border-radius: 10px !important;
    margin: 4px 10px !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    text-decoration: none !important;
    position: relative !important;
    overflow: hidden !important;
}

.side-menu__item::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    transition: width 0.3s ease;
    z-index: 0;
}

.side-menu__item:hover::before,
.side-menu__item.active::before {
    width: 4px;
}

.side-menu__item:hover {
    background: #e2e8f0 !important;
    color: #1e40af !important;
    transform: translateX(-5px) !important;
    padding-right: 25px !important;
}

.side-menu__item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(37, 99, 235, 0.15) 100%) !important;
    color: #1e40af !important;
    border-right: 4px solid #3b82f6 !important;
    font-weight: 600 !important;
}

/* Menu Icons - Light Theme */
.side-menu__icon {
    width: 20px !important;
    height: 20px !important;
    fill: currentColor !important;
    opacity: 0.7 !important;
    transition: all 0.3s ease !important;
    z-index: 1 !important;
    position: relative !important;
    color: #64748b !important;
}

.side-menu__item:hover .side-menu__icon,
.side-menu__item.active .side-menu__icon {
    opacity: 1 !important;
    transform: scale(1.1) !important;
    color: #1e40af !important;
}

/* Menu Labels */
.side-menu__label {
    font-size: 14px !important;
    font-weight: 500 !important;
    z-index: 1 !important;
    position: relative !important;
}

/* Submenu Items - Light Theme */
.slide-menu,
.app-sidebar .slide-menu,
.side-menu .slide-menu {
    background: #f1f5f9 !important;
    border-radius: 10px !important;
    margin: 5px 10px !important;
    padding: 8px 0 !important;
    border-right: 2px solid #e2e8f0 !important;
}

.slide-item,
.app-sidebar .slide-item,
.side-menu .slide-item,
.app-sidebar ul.side-menu li a.slide-item {
    color: #64748b !important;
    padding: 10px 20px 10px 40px !important;
    display: block !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    border-radius: 6px !important;
    margin: 2px 10px !important;
    font-size: 13px !important;
}

.slide-item:hover {
    background: #e2e8f0 !important;
    color: #1e40af !important;
    transform: translateX(-5px) !important;
    padding-right: 25px !important;
}

.slide-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.2) 100%) !important;
    color: #1e40af !important;
    font-weight: 600 !important;
    border-right: 3px solid #3b82f6 !important;
}

/* Chevron Icons - Light Theme */
.side-menu__item .angle {
    margin-right: auto !important;
    transition: transform 0.3s ease !important;
    color: #94a3b8 !important;
    font-size: 12px !important;
}

.side-menu__item[aria-expanded="true"] .angle {
    transform: rotate(180deg) !important;
    color: #1e40af !important;
}

/* Delivery Dates Info */
.delevery-dates,
.app-sidebar .delevery-dates {
    background: rgba(16, 185, 129, 0.1) !important;
    border-right: 3px solid #10b981 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    padding: 12px 20px !important;
    margin: 8px 10px !important;
    border-radius: 10px !important;
    font-size: 13px !important;
}

.delevery-dates span,
.app-sidebar .delevery-dates span {
    color: #10b981 !important;
    font-weight: 600 !important;
}

/* Override any existing white/light backgrounds */
.app-sidebar * {
    color: inherit;
}

/* Ensure menu items are visible - Light Theme */
.app-sidebar .side-menu li,
.app-sidebar .side-menu li a {
    color: #475569 !important;
}

.app-sidebar .side-menu li a:hover,
.app-sidebar .side-menu li a:focus {
    color: #1e40af !important;
}

/* Scrollbar Styling */
.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Slide Menu Before Icon - RTL Support */
.app-sidebar .slide-menu a:before {
    left: 27px !important;
    right: auto !important;
}

/* Main Header Height Adjustment */
.main-header {
    height: 85px !important;
    min-height: 85px !important;
}

/* Z-Index Hierarchy - Ensure proper layering */
/* Sidebar: 900 */
/* Modal backdrop: 9998 */
/* Modals/Alerts: 10000 */
/* Loading: 99999 */

.app-sidebar {
    z-index: 900 !important;
}

.app-sidebar__overlay {
    z-index: 899 !important;
}

/* Modal backdrop - between sidebar and modal content */
.modal-backdrop,
.modal-backdrop.show,
.modal-backdrop.fade {
    z-index: 9998 !important;
}

/* Modal content and alerts - above backdrop */
.modal,
.modal.show,
.modal.fade.show,
.modal-dialog,
.swal2-container,
.alert-confirm-overlay,
[role="dialog"],
[class*="alert-"],
.sweet-alert {
    z-index: 10000 !important;
}

/* Loading indicator - below alerts/modals but above sidebar */
#global-loader {
    z-index: 9500 !important;
}

/* Other loaders */
[id*="loader"]:not(#global-loader),
[class*="loader"]:not(#global-loader) {
    z-index: 9500 !important;
}

/* Responsive - Mobile sidebar behavior */
@media (max-width: 767px) {
    /* By default, sidebar is completely hidden (display: none) on mobile */
    .app-sidebar,
    .app-sidebar.sidebar-scroll,
    aside.app-sidebar.sidebar-scroll {
        display: none !important;
        visibility: hidden !important;
    }
    
    /* When menu is open (sidenav-toggled), show the sidebar */
    .app.sidenav-toggled .app-sidebar,
    .app.sidenav-toggled .app-sidebar.sidebar-scroll,
    .app.sidenav-toggled aside.app-sidebar.sidebar-scroll {
        display: flex !important;
        visibility: visible !important;
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 240px !important;
        z-index: 900 !important;
        transform: translateX(0) !important;
    }
    
    /* Overlay - hidden by default */
    .app-sidebar__overlay {
        visibility: hidden !important;
        opacity: 0 !important;
    }
    
    /* Overlay - visible when menu is open */
    .app.sidenav-toggled .app-sidebar__overlay {
        visibility: visible !important;
        opacity: 1 !important;
        background: rgba(0, 0, 0, 0.6) !important;
        z-index: 899 !important;
        cursor: pointer !important;
        display: block !important;
    }
    
    /* Header toggle should be above sidebar overlay but below alerts */
    .app.sidenav-toggled .main-header .app-sidebar__toggle {
        position: relative;
        z-index: 950 !important;
        cursor: pointer !important;
    }
}
