/**
 * Modern Sidebar Styles
 * A completely modern redesign of the admin sidebar
 * Uses CSS variables from theme colors set in admin panel
 */

/* ============================================
   SIDEBAR CONTAINER - THEME AWARE
   ============================================ */
.side-bar {
    background: linear-gradient(180deg, var(--sidebar-bg-start, #1e293b) 0%, var(--sidebar-bg-end, #0f172a) 100%) !important;
    background-color: var(--sidebar-bg-end, #0f172a) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15) !important;
}

/* Sidebar Header / Logo Area */
.side-bar > a:first-of-type {
    min-height: 58px !important;
}

.side-bar .side-bar-heading {
    font-size: 1rem !important;
    font-weight: 600 !important;
    letter-spacing: -0.025em !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

/* ============================================
   SIDEBAR SEARCH BOX
   ============================================ */
.sidebar-search-wrapper {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-search-input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-size: 13px;
    transition: all 0.2s ease;
    outline: none;
}

.sidebar-search-input::placeholder {
    color: #64748b;
}

.sidebar-search-input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--theme-primary, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.sidebar-search-container {
    position: relative;
}

.sidebar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    pointer-events: none;
}

/* ============================================
   MINI LOGO (shown in collapsed mode)
   ============================================ */
.sidebar-mini-logo {
    display: none;
    color: white;
    align-items: center;
    justify-content: center;
}

.sidebar-mini-logo svg {
    width: 28px;
    height: 28px;
}

.sidebar-mini-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px;
}

/* ============================================
   SIDEBAR MENU CONTAINER
   ============================================ */
#side-bar {
    background: transparent !important;
    border-right: none !important;
    padding: 12px 12px 24px 12px !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

#side-bar::-webkit-scrollbar {
    width: 6px;
}

#side-bar::-webkit-scrollbar-track {
    background: transparent;
}

#side-bar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

#side-bar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   MENU ITEMS - PARENT LEVEL
   ============================================ */
#side-bar > a,
#side-bar > div > a {
    color: #94a3b8 !important;
    background: transparent !important;
    border-radius: 10px !important;
    padding: 11px 14px !important;
    margin-bottom: 2px !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border: 1px solid transparent !important;
}

#side-bar > a:hover,
#side-bar > div > a:hover {
    color: #f1f5f9 !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.04) !important;
    transform: translateX(2px);
}

/* Active State - Uses Theme Colors */
#side-bar > a.tw-bg-gray-200,
#side-bar > div > a.tw-bg-gray-200,
#side-bar > a[class*="tw-text-primary"],
#side-bar > div > a[class*="tw-text-primary"] {
    color: #ffffff !important;
    background: linear-gradient(135deg, var(--theme-primary, #3b82f6) 0%, var(--theme-primary-dark, #2563eb) 100%) !important;
    border-color: transparent !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
}

/* Active state for parent with active child */
#side-bar > div.tw-pb-1,
#side-bar > div[class*="tw-bg-gray-200"] {
    background: rgba(255, 255, 255, 0.03) !important;
    border-radius: 10px !important;
    margin-bottom: 4px !important;
}

#side-bar > div.tw-pb-1 > a:first-child,
#side-bar > div[class*="tw-bg-gray-200"] > a:first-child {
    color: var(--theme-primary-light, #60a5fa) !important;
    background: transparent !important;
}

/* ============================================
   MENU ICONS
   ============================================ */
#side-bar a i,
#side-bar a svg:not(.svg) {
    color: inherit !important;
    opacity: 0.9;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    font-size: 18px !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#side-bar a:hover i,
#side-bar a:hover svg:not(.svg) {
    opacity: 1;
}

/* Ensure FontAwesome icons are visible */
#side-bar a i.fa,
#side-bar a i.fas,
#side-bar a i.far,
#side-bar a i.fab {
    font-size: 16px !important;
    line-height: 1 !important;
}

/* SVG icons inside menu items - CRM and other module icons */
#side-bar > div > a > svg:first-of-type,
#side-bar > a > svg:first-of-type {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    flex-shrink: 0 !important;
    stroke: currentColor !important;
    color: inherit !important;
}

/* Dropdown Arrow - the toggle indicator */
#side-bar a svg.svg {
    color: #64748b !important;
    transition: transform 0.25s ease !important;
    flex-shrink: 0 !important;
    width: 16px !important;
    height: 16px !important;
}

#side-bar > div.tw-pb-1 > a svg.svg {
    transform: rotate(90deg);
}

/* ============================================
   CHILD MENU ITEMS (Submenu)
   ============================================ */
#side-bar .chiled {
    margin-top: 6px !important;
    margin-bottom: 8px !important;
    padding-left: 36px !important;
    background: var(--sidebar-bg-end, #0f172a) !important;
    border-radius: 8px !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

#side-bar .chiled > div:first-child {
    background: linear-gradient(180deg, var(--theme-primary, #3b82f6) 0%, var(--theme-primary-dark, #2563eb) 100%) !important;
    width: 2px !important;
    border-radius: 1px !important;
    left: 22px !important;
}

#side-bar .chiled a {
    color: #94a3b8 !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
}

#side-bar .chiled a:hover {
    color: #f1f5f9 !important;
    background: rgba(255, 255, 255, 0.05) !important;
    padding-left: 16px !important;
}

#side-bar .chiled a.tw-text-primary-700,
#side-bar .chiled a[class*="tw-text-primary"] {
    color: var(--theme-primary-light, #60a5fa) !important;
    background: rgba(59, 130, 246, 0.1) !important;
    font-weight: 500 !important;
}

/* Submenu icon - Show in expanded mode */
#side-bar .chiled .submenu-icon {
    display: flex !important;
    visibility: visible !important;
    align-items: center !important;
    justify-content: center !important;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s ease, color 0.2s ease;
}

#side-bar .chiled .submenu-icon svg {
    display: block !important;
    width: 14px !important;
    height: 14px !important;
    color: currentColor;
}

#side-bar .chiled .submenu-link:hover .submenu-icon {
    opacity: 1;
}

#side-bar .chiled .submenu-link.tw-text-primary-700 .submenu-icon {
    opacity: 1;
    color: var(--theme-primary, #3b82f6);
}

/* ============================================
   MENU SECTION HEADERS
   ============================================ */
#side-bar > div[class*="tw-uppercase"] {
    color: #475569 !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.1em !important;
    padding: 16px 14px 8px 14px !important;
    margin-top: 8px !important;
}

/* ============================================
   HIDDEN ITEMS (for search filtering)
   ============================================ */
#side-bar .sidebar-item-hidden {
    display: none !important;
}

#side-bar .sidebar-search-match {
    background: rgba(var(--theme-primary-rgb, 59, 130, 246), 0.15) !important;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 991px) {
    .side-bar {
        width: 280px !important;
        z-index: 1050 !important;
        background: linear-gradient(180deg, var(--sidebar-bg-start, #1e293b) 0%, var(--sidebar-bg-end, #0f172a) 100%) !important;
        background-color: var(--sidebar-bg-end, #0f172a) !important;
    }

    .side-bar.small-view-side-active {
        transform: translateX(0) !important;
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.3) !important;
        background: linear-gradient(180deg, var(--sidebar-bg-start, #1e293b) 0%, var(--sidebar-bg-end, #0f172a) 100%) !important;
        background-color: var(--sidebar-bg-end, #0f172a) !important;
        width: 280px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Force full sidebar view when open on mobile/tablet - override mini mode */
    .side-bar.small-view-side-active .side-bar-heading,
    .side-bar.small-view-side-active .sidebar-search-wrapper,
    .side-bar.small-view-side-active #side-bar > a > span.tw-truncate,
    .side-bar.small-view-side-active #side-bar > div > a > span.tw-truncate,
    .side-bar.small-view-side-active #side-bar > div > a > svg.svg {
        display: flex !important;
    }

    .side-bar.small-view-side-active .sidebar-search-wrapper {
        display: block !important;
    }

    .side-bar.small-view-side-active #side-bar > a,
    .side-bar.small-view-side-active #side-bar > div > a {
        justify-content: flex-start !important;
        padding: 0.5rem 0.75rem !important;
    }

    body.sidebar-light .side-bar,
    body.sidebar-light .side-bar.small-view-side-active {
        background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
        background-color: #f8fafc !important;
    }
}

/* ============================================
   SCROLL FADE EFFECT
   ============================================ */
.side-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, #0f172a 0%, transparent 100%);
    pointer-events: none;
    z-index: 10;
}

/* ============================================
   ANIMATION FOR MENU OPEN/CLOSE
   ============================================ */
#side-bar .chiled {
    overflow: hidden;
}

/* ============================================
   BADGE / NOTIFICATION DOT ON MENU ITEMS
   ============================================ */
#side-bar .menu-badge {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* ============================================
   SIDEBAR STYLE VARIANTS
   ============================================ */

/* Light Sidebar Style */
body.sidebar-light .side-bar {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    border-right: 1px solid #e2e8f0 !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05) !important;
}

body.sidebar-light .side-bar > a:first-of-type {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

body.sidebar-light .side-bar .side-bar-heading {
    color: #1e293b !important;
}

body.sidebar-light .sidebar-search-input {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #1e293b;
}

body.sidebar-light .sidebar-search-input::placeholder {
    color: #94a3b8;
}

body.sidebar-light #side-bar .menu-item > a {
    color: #475569 !important;
}

body.sidebar-light #side-bar .menu-item > a:hover {
    background: rgba(0, 0, 0, 0.04) !important;
    color: var(--theme-primary, #3b82f6) !important;
}

body.sidebar-light #side-bar .menu-item.active > a {
    background: linear-gradient(135deg, var(--theme-primary, #3b82f6) 0%, var(--theme-primary-dark, #2563eb) 100%) !important;
    color: white !important;
}

body.sidebar-light #side-bar .chiled {
    background: #f1f5f9 !important;
}

body.sidebar-light #side-bar .chiled a {
    color: #64748b !important;
}

body.sidebar-light #side-bar .chiled a:hover {
    color: var(--theme-primary, #3b82f6) !important;
    background: rgba(0, 0, 0, 0.02) !important;
}

body.sidebar-light .side-bar::after {
    background: linear-gradient(to top, #f8fafc 0%, transparent 100%);
}

/* Gradient Sidebar Style */
body.sidebar-gradient .side-bar {
    background: linear-gradient(180deg, var(--theme-primary, #3b82f6) 0%, var(--theme-primary-darker, #1d4ed8) 100%) !important;
}

body.sidebar-gradient .side-bar > a:first-of-type {
    background: rgba(255, 255, 255, 0.1) !important;
}

body.sidebar-gradient #side-bar .menu-item > a:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

body.sidebar-gradient #side-bar .menu-item.active > a {
    background: rgba(255, 255, 255, 0.2) !important;
}

body.sidebar-gradient .side-bar::after {
    background: linear-gradient(to top, var(--theme-primary-darker, #1d4ed8) 0%, transparent 100%);
}

/* Match Theme Sidebar Style */
body.sidebar-match-theme .side-bar {
    background: linear-gradient(180deg, var(--theme-primary, #3b82f6) 0%, var(--theme-primary-dark, #2563eb) 100%) !important;
}

body.sidebar-match-theme .side-bar > a:first-of-type {
    background: rgba(0, 0, 0, 0.1) !important;
}

body.sidebar-match-theme .side-bar::after {
    background: linear-gradient(to top, var(--theme-primary-dark, #2563eb) 0%, transparent 100%);
}

/* ============================================
   SIDEBAR BEHAVIOR VARIANTS
   ============================================ */

/* Mini Sidebar (Icon Only) - Only for sidebar-icon-only behavior, NOT AdminLTE's sidebar-mini */
body.sidebar-icon-only .side-bar {
    width: 70px !important;
    overflow: visible !important;
}

body.sidebar-icon-only .side-bar .side-bar-heading,
body.sidebar-icon-only .side-bar .menu-item > a span:not(.fa):not(.fas):not(.far):not(.fab),
body.sidebar-icon-only .side-bar .sidebar-search-wrapper {
    display: none !important;
}

body.sidebar-icon-only .side-bar .menu-item > a {
    justify-content: center !important;
    padding: 14px !important;
}

body.sidebar-icon-only .side-bar .menu-item > a i {
    margin-right: 0 !important;
    font-size: 18px !important;
}

body.sidebar-icon-only .side-bar .chiled {
    position: absolute !important;
    left: 70px !important;
    top: 0 !important;
    width: 200px !important;
    background: var(--sidebar-bg-start, #1e293b) !important;
    border-radius: 0 8px 8px 0 !important;
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.2) !important;
    display: none !important;
}

body.sidebar-icon-only .side-bar .menu-item:hover .chiled {
    display: block !important;
}

body.sidebar-mini .content-wrapper {
    margin-left: 70px !important;
}

/* Hover Expand Behavior - Default collapsed, expand on hover */
body.sidebar-hover-expand .side-bar {
    width: 70px !important;
    transition: width 0.3s ease !important;
    overflow: visible !important;
}

body.sidebar-hover-expand .side-bar:hover {
    width: 260px !important;
    overflow-y: auto !important;
}

body.sidebar-hover-expand .side-bar .side-bar-heading,
body.sidebar-hover-expand #side-bar > a > span.tw-truncate,
body.sidebar-hover-expand #side-bar > div > a > span.tw-truncate,
body.sidebar-hover-expand .side-bar .sidebar-search-wrapper {
    opacity: 0;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

body.sidebar-hover-expand .side-bar:hover .side-bar-heading,
body.sidebar-hover-expand .side-bar:hover #side-bar > a > span.tw-truncate,
body.sidebar-hover-expand .side-bar:hover #side-bar > div > a > span.tw-truncate,
body.sidebar-hover-expand .side-bar:hover .sidebar-search-wrapper {
    opacity: 1;
}

/* Hide dropdown arrow when collapsed */
body.sidebar-hover-expand #side-bar > div > a > svg.svg {
    opacity: 0;
    transition: opacity 0.2s ease;
}

body.sidebar-hover-expand .side-bar:hover #side-bar > div > a > svg.svg {
    opacity: 1;
}

body.sidebar-hover-expand .content-wrapper {
    margin-left: 70px !important;
    transition: margin-left 0.3s ease !important;
}

/* Always Expanded */
body.sidebar-always-expanded .side-bar {
    width: 280px !important;
}

body.sidebar-always-expanded .content-wrapper {
    margin-left: 280px !important;
}

/* ============================================
   DEVICE-SPECIFIC SIDEBAR SETTINGS
   ============================================ */

/* Desktop Sidebar Settings */
@media (min-width: 1200px) {
    body.sidebar-desktop-collapsed .side-bar {
        width: 70px !important;
    }
    body.sidebar-desktop-collapsed #side-bar > a > span.tw-truncate,
    body.sidebar-desktop-collapsed #side-bar > div > a > span.tw-truncate,
    body.sidebar-desktop-collapsed .side-bar .side-bar-heading {
        display: none !important;
    }
    /* Show search icon in collapsed mode */
    body.sidebar-desktop-collapsed .side-bar .sidebar-search-wrapper {
        padding: 8px !important;
    }
    body.sidebar-desktop-collapsed .side-bar .sidebar-search-wrapper .sidebar-search-container {
        display: flex !important;
        justify-content: center !important;
    }
    body.sidebar-desktop-collapsed .side-bar .sidebar-search-wrapper .sidebar-search-input {
        display: none !important;
    }
    body.sidebar-desktop-collapsed .side-bar .sidebar-search-wrapper .sidebar-search-icon {
        position: static !important;
        transform: none !important;
        cursor: pointer !important;
        pointer-events: auto !important;
        color: #94a3b8 !important;
        transition: color 0.2s ease !important;
    }
    body.sidebar-desktop-collapsed .side-bar .sidebar-search-wrapper .sidebar-search-icon:hover {
        color: #ffffff !important;
    }
    /* Show mini logo in desktop collapsed mode */
    body.sidebar-desktop-collapsed .sidebar-mini-logo {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    body.sidebar-desktop-collapsed .content-wrapper {
        margin-left: 70px !important;
    }

    body.sidebar-desktop-hidden .side-bar {
        display: none !important;
    }
    body.sidebar-desktop-hidden .content-wrapper {
        margin-left: 0 !important;
    }
}

/* Tablet Sidebar Settings */
@media (min-width: 768px) and (max-width: 1199px) {
    /* Ensure content wrapper is above any overlays but below modals */
    .content-wrapper {
        position: relative !important;
        z-index: 1 !important;
    }

    /* Ensure form inputs are clickable and not blocked by any overlays */
    .content-wrapper input,
    .content-wrapper textarea,
    .content-wrapper select,
    .content-wrapper button,
    .content-wrapper .form-control {
        position: relative !important;
        z-index: 2 !important;
    }

    /* Ensure solid background on tablet */
    .side-bar {
        background: linear-gradient(180deg, var(--sidebar-bg-start, #1e293b) 0%, var(--sidebar-bg-end, #0f172a) 100%) !important;
        background-color: var(--sidebar-bg-end, #0f172a) !important;
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        height: 100vh !important;
        z-index: 1050 !important;
    }

    body.sidebar-light .side-bar {
        background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
        background-color: #f8fafc !important;
    }

    /* Ensure solid sidebar menu container */
    #side-bar {
        background: transparent !important;
    }

    /* Ensure submenus have solid background - NO transparency */
    #side-bar .chiled {
        background: #0c1222 !important;
        background-color: #0c1222 !important;
        border-radius: 8px !important;
        margin-left: 8px !important;
        padding: 8px !important;
    }

    /* Hide blue vertical line on tablet */
    #side-bar .chiled > div:first-child {
        display: none !important;
    }

    body.sidebar-light #side-bar .chiled {
        background: #e2e8f0 !important;
        background-color: #e2e8f0 !important;
    }

    body.sidebar-tablet-collapsed .side-bar {
        width: 70px !important;
        overflow: visible !important;
        transition: width 0.3s ease !important;
        background: linear-gradient(180deg, var(--sidebar-bg-start, #1e293b) 0%, var(--sidebar-bg-end, #0f172a) 100%) !important;
        background-color: var(--sidebar-bg-end, #0f172a) !important;
    }
    body.sidebar-light.sidebar-tablet-collapsed .side-bar {
        background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
        background-color: #f8fafc !important;
    }
    body.sidebar-tablet-collapsed #side-bar > a > span.tw-truncate,
    body.sidebar-tablet-collapsed #side-bar > div > a > span.tw-truncate,
    body.sidebar-tablet-collapsed .side-bar .side-bar-heading,
    body.sidebar-tablet-collapsed #side-bar > div > a > svg.svg {
        display: none !important;
    }
    /* Show mini logo in tablet collapsed mode */
    body.sidebar-tablet-collapsed .sidebar-mini-logo {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    /* Show search icon only in tablet collapsed mode */
    body.sidebar-tablet-collapsed .side-bar .sidebar-search-wrapper {
        padding: 8px !important;
    }
    body.sidebar-tablet-collapsed .side-bar .sidebar-search-wrapper .sidebar-search-container {
        display: flex !important;
        justify-content: center !important;
    }
    body.sidebar-tablet-collapsed .side-bar .sidebar-search-wrapper .sidebar-search-input {
        display: none !important;
    }
    body.sidebar-tablet-collapsed .side-bar .sidebar-search-wrapper .sidebar-search-icon {
        position: static !important;
        transform: none !important;
        cursor: pointer !important;
        pointer-events: auto !important;
        color: #94a3b8 !important;
    }
    body.sidebar-tablet-collapsed #side-bar > a,
    body.sidebar-tablet-collapsed #side-bar > div > a {
        justify-content: center !important;
        padding: 12px !important;
    }
    body.sidebar-tablet-collapsed .content-wrapper {
        margin-left: 70px !important;
    }
    body.sidebar-tablet-collapsed #side-bar .chiled {
        display: none !important;
    }

    /* Tablet collapsed but with dropdown open - expand sidebar */
    body.sidebar-tablet-collapsed.sidebar-dropdown-open .side-bar {
        width: 260px !important;
    }
    body.sidebar-tablet-collapsed.sidebar-dropdown-open #side-bar > a > span.tw-truncate,
    body.sidebar-tablet-collapsed.sidebar-dropdown-open #side-bar > div > a > span.tw-truncate,
    body.sidebar-tablet-collapsed.sidebar-dropdown-open .side-bar .side-bar-heading,
    body.sidebar-tablet-collapsed.sidebar-dropdown-open .side-bar .sidebar-search-wrapper,
    body.sidebar-tablet-collapsed.sidebar-dropdown-open #side-bar > div > a > svg.svg {
        display: block !important;
    }
    body.sidebar-tablet-collapsed.sidebar-dropdown-open #side-bar > a,
    body.sidebar-tablet-collapsed.sidebar-dropdown-open #side-bar > div > a {
        justify-content: flex-start !important;
        padding: 8px 12px !important;
    }
    body.sidebar-tablet-collapsed.sidebar-dropdown-open #side-bar .chiled {
        display: none !important;
        position: static !important;
        width: auto !important;
        background: transparent !important;
        box-shadow: none !important;
        padding-left: 36px !important;
        border-left: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    body.sidebar-tablet-collapsed.sidebar-dropdown-open #side-bar .chiled.tw-block,
    body.sidebar-tablet-collapsed.sidebar-dropdown-open #side-bar .chiled[style*="display: block"] {
        display: block !important;
    }

    body.sidebar-tablet-hidden .side-bar {
        display: none !important;
    }
    body.sidebar-tablet-hidden .content-wrapper {
        margin-left: 0 !important;
    }

    body.sidebar-tablet-expanded .side-bar {
        width: 260px !important;
    }
}

/* Mobile Sidebar Settings */
@media (max-width: 767px) {
    /* Ensure solid background on mobile */
    .side-bar {
        background: linear-gradient(180deg, var(--sidebar-bg-start, #1e293b) 0%, var(--sidebar-bg-end, #0f172a) 100%) !important;
        background-color: var(--sidebar-bg-end, #0f172a) !important;
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        height: 100vh !important;
        z-index: 1050 !important;
    }

    body.sidebar-light .side-bar {
        background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
        background-color: #f8fafc !important;
    }

    /* Ensure solid sidebar menu container */
    #side-bar {
        background: transparent !important;
    }

    /* Ensure submenus have solid background - NO transparency */
    #side-bar .chiled {
        background: #0c1222 !important;
        background-color: #0c1222 !important;
        border-radius: 8px !important;
        margin-left: 8px !important;
        padding: 8px !important;
    }

    /* Hide blue vertical line on mobile */
    #side-bar .chiled > div:first-child {
        display: none !important;
    }

    body.sidebar-light #side-bar .chiled {
        background: #e2e8f0 !important;
        background-color: #e2e8f0 !important;
    }

    body.sidebar-mobile-collapsed .side-bar {
        width: 70px !important;
        overflow: visible !important;
        transition: width 0.3s ease !important;
        background: linear-gradient(180deg, var(--sidebar-bg-start, #1e293b) 0%, var(--sidebar-bg-end, #0f172a) 100%) !important;
        background-color: var(--sidebar-bg-end, #0f172a) !important;
    }
    body.sidebar-light.sidebar-mobile-collapsed .side-bar {
        background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
        background-color: #f8fafc !important;
    }
    body.sidebar-mobile-collapsed #side-bar > a > span.tw-truncate,
    body.sidebar-mobile-collapsed #side-bar > div > a > span.tw-truncate,
    body.sidebar-mobile-collapsed .side-bar .side-bar-heading,
    body.sidebar-mobile-collapsed #side-bar > div > a > svg.svg {
        display: none !important;
    }
    /* Show mini logo in mobile collapsed mode */
    body.sidebar-mobile-collapsed .sidebar-mini-logo {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    /* Show search icon only in mobile collapsed mode */
    body.sidebar-mobile-collapsed .side-bar .sidebar-search-wrapper {
        padding: 8px !important;
    }
    body.sidebar-mobile-collapsed .side-bar .sidebar-search-wrapper .sidebar-search-container {
        display: flex !important;
        justify-content: center !important;
    }
    body.sidebar-mobile-collapsed .side-bar .sidebar-search-wrapper .sidebar-search-input {
        display: none !important;
    }
    body.sidebar-mobile-collapsed .side-bar .sidebar-search-wrapper .sidebar-search-icon {
        position: static !important;
        transform: none !important;
        cursor: pointer !important;
        pointer-events: auto !important;
        color: #94a3b8 !important;
    }
    body.sidebar-mobile-collapsed #side-bar > a,
    body.sidebar-mobile-collapsed #side-bar > div > a {
        justify-content: center !important;
        padding: 12px !important;
    }
    body.sidebar-mobile-collapsed #side-bar .chiled {
        display: none !important;
    }

    /* Mobile collapsed but with dropdown open - expand sidebar */
    body.sidebar-mobile-collapsed.sidebar-dropdown-open .side-bar {
        width: 260px !important;
    }
    body.sidebar-mobile-collapsed.sidebar-dropdown-open #side-bar > a > span.tw-truncate,
    body.sidebar-mobile-collapsed.sidebar-dropdown-open #side-bar > div > a > span.tw-truncate,
    body.sidebar-mobile-collapsed.sidebar-dropdown-open .side-bar .side-bar-heading,
    body.sidebar-mobile-collapsed.sidebar-dropdown-open .side-bar .sidebar-search-wrapper,
    body.sidebar-mobile-collapsed.sidebar-dropdown-open #side-bar > div > a > svg.svg {
        display: block !important;
    }
    body.sidebar-mobile-collapsed.sidebar-dropdown-open #side-bar > a,
    body.sidebar-mobile-collapsed.sidebar-dropdown-open #side-bar > div > a {
        justify-content: flex-start !important;
        padding: 8px 12px !important;
    }
    body.sidebar-mobile-collapsed.sidebar-dropdown-open #side-bar .chiled {
        display: none !important;
        position: static !important;
        width: auto !important;
        background: transparent !important;
        box-shadow: none !important;
        padding-left: 36px !important;
        border-left: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    body.sidebar-mobile-collapsed.sidebar-dropdown-open #side-bar .chiled.tw-block,
    body.sidebar-mobile-collapsed.sidebar-dropdown-open #side-bar .chiled[style*="display: block"] {
        display: block !important;
    }

    body.sidebar-mobile-hidden .side-bar {
        transform: translateX(-100%);
        transition: transform 0.3s ease !important;
    }
    body.sidebar-mobile-hidden.sidebar-open .side-bar {
        transform: translateX(0);
    }
    body.sidebar-mobile-hidden .content-wrapper {
        margin-left: 0 !important;
    }

    body.sidebar-mobile-expanded .side-bar {
        width: 260px !important;
    }
}

/* ============================================
   MINI SIDEBAR COLLAPSED MODE
   (when sidebar is collapsed via button with mini sidebar enabled)
   ============================================ */
body.sidebar-collapsed-mini .side-bar,
.side-bar.sidebar-mini-mode {
    width: 70px !important;
    overflow: visible !important;
    transition: width 0.3s ease !important;
}

body.sidebar-collapsed-mini .content-wrapper {
    margin-left: 70px !important;
    transition: margin-left 0.3s ease !important;
}

/* Hide text labels in mini mode */
body.sidebar-collapsed-mini .side-bar .side-bar-heading,
body.sidebar-collapsed-mini #side-bar > a > span.tw-truncate,
body.sidebar-collapsed-mini #side-bar > div > a > span.tw-truncate,
body.sidebar-collapsed-mini #side-bar > div > a > svg.svg {
    display: none !important;
}

/* Show mini logo in collapsed mode */
body.sidebar-collapsed-mini .sidebar-mini-logo {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Hide search input but show icon in mini mode */
body.sidebar-collapsed-mini .side-bar .sidebar-search-wrapper {
    padding: 8px !important;
}

body.sidebar-collapsed-mini .side-bar .sidebar-search-wrapper .sidebar-search-container {
    display: flex !important;
    justify-content: center !important;
}

body.sidebar-collapsed-mini .side-bar .sidebar-search-wrapper .sidebar-search-input {
    display: none !important;
}

body.sidebar-collapsed-mini .side-bar .sidebar-search-wrapper .sidebar-search-icon {
    position: static !important;
    transform: none !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    color: #94a3b8 !important;
    transition: color 0.2s ease !important;
}

body.sidebar-collapsed-mini .side-bar .sidebar-search-wrapper .sidebar-search-icon:hover {
    color: #ffffff !important;
}

/* Light sidebar search icon in mini mode */
body.sidebar-light.sidebar-collapsed-mini .side-bar .sidebar-search-wrapper .sidebar-search-icon {
    color: #64748b !important;
}

body.sidebar-light.sidebar-collapsed-mini .side-bar .sidebar-search-wrapper .sidebar-search-icon:hover {
    color: #1e293b !important;
}

/* Center icons in mini mode */
body.sidebar-collapsed-mini #side-bar > a,
body.sidebar-collapsed-mini #side-bar > div > a {
    justify-content: center !important;
    padding: 12px !important;
}

/* Popup submenu in mini mode */
body.sidebar-collapsed-mini #side-bar > div {
    position: relative !important;
}

/* Hide submenu by default in mini mode */
body.sidebar-collapsed-mini #side-bar .chiled {
    display: none !important;
}

/* Show submenu inline with icons when parent has active child (user is on submenu page) */
/* Match both with and without space in display value */
body.sidebar-collapsed-mini #side-bar .chiled[style*="display:block"],
body.sidebar-collapsed-mini #side-bar .chiled[style*="display: block"],
body.sidebar-collapsed-mini #side-bar .chiled.tw-block {
    display: block !important;
    position: static !important;
    width: 100% !important;
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 4px 0 !important;
    margin: 0 !important;
    border-left: none !important;
    padding-left: 0 !important;
}

/* ALWAYS hide the blue vertical line in collapsed mode */
body.sidebar-collapsed-mini #side-bar .chiled .chiled-vertical-line {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
}

body.sidebar-collapsed-mini #side-bar .chiled > div:first-child {
    display: none !important;
    visibility: hidden !important;
}

/* Style submenu items as icons in collapsed mode */
body.sidebar-collapsed-mini #side-bar .chiled .submenu-items-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 2px !important;
}

body.sidebar-collapsed-mini #side-bar .chiled a.submenu-link {
    justify-content: center !important;
    padding: 10px !important;
    color: #94a3b8 !important;
    border-radius: 8px !important;
    margin-bottom: 0 !important;
    width: 46px !important;
    height: 46px !important;
}

body.sidebar-collapsed-mini #side-bar .chiled a.submenu-link:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    padding-left: 10px !important;
}

body.sidebar-collapsed-mini #side-bar .chiled a.tw-text-primary-700 {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
}

/* Show submenu icons in collapsed mode - override expanded mode hiding */
body.sidebar-collapsed-mini #side-bar .chiled .submenu-icon {
    display: flex !important;
    visibility: visible !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 20px !important;
    overflow: visible !important;
}

body.sidebar-collapsed-mini #side-bar .chiled .submenu-icon svg {
    display: block !important;
    width: 16px !important;
    height: 16px !important;
}

body.sidebar-collapsed-mini #side-bar .chiled .submenu-text {
    display: none !important;
}

/* Light sidebar in mini mode */
body.sidebar-light.sidebar-collapsed-mini #side-bar .chiled[style*="display: block"],
body.sidebar-light.sidebar-collapsed-mini #side-bar .chiled.tw-block {
    background: transparent !important;
}

body.sidebar-light.sidebar-collapsed-mini #side-bar .chiled a.submenu-link {
    color: #64748b !important;
}

body.sidebar-light.sidebar-collapsed-mini #side-bar .chiled a.submenu-link:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    color: #1e293b !important;
}

/* Popup flyout submenu on hover in mini mode (for parent menus without active child) */
body.sidebar-collapsed-mini #side-bar .chiled.submenu-popup-visible {
    display: block !important;
    position: absolute !important;
    left: 70px !important;
    top: 0 !important;
    width: 220px !important;
    background: #1e293b !important;
    border-radius: 0 12px 12px 0 !important;
    box-shadow: 8px 4px 24px rgba(0, 0, 0, 0.4) !important;
    padding: 12px !important;
    z-index: 1060 !important;
    margin: 0 !important;
    border-left: 3px solid var(--theme-primary, #3b82f6) !important;
    padding-left: 12px !important;
}

body.sidebar-collapsed-mini #side-bar .chiled.submenu-popup-visible .submenu-items-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
}

body.sidebar-collapsed-mini #side-bar .chiled.submenu-popup-visible a.submenu-link {
    justify-content: flex-start !important;
    width: auto !important;
    height: auto !important;
    padding: 10px 14px !important;
}

body.sidebar-collapsed-mini #side-bar .chiled.submenu-popup-visible .submenu-icon {
    display: flex !important;
}

body.sidebar-collapsed-mini #side-bar .chiled.submenu-popup-visible .submenu-text {
    display: inline !important;
}

body.sidebar-light.sidebar-collapsed-mini #side-bar .chiled.submenu-popup-visible {
    background: #ffffff !important;
    box-shadow: 8px 4px 24px rgba(0, 0, 0, 0.15) !important;
}

/* ============================================
   SIDEBAR FULLY HIDDEN MODE
   (when sidebar is collapsed via button without mini sidebar)
   ============================================ */
body.sidebar-collapsed-hidden .side-bar {
    display: none !important;
}

body.sidebar-collapsed-hidden .content-wrapper {
    margin-left: 0 !important;
}

/* ============================================
   DROPDOWN CLICK AREA FIX
   Make the entire dropdown link clickable
   ============================================ */
#side-bar > div > a.drop_down {
    cursor: pointer !important;
}

