/* ================================================
   MODERN SIDEBAR - Complete Overhaul
   ================================================
   Features:
   - Floating design with rounded corners
   - Pill-shaped active states
   - Circular icons when collapsed
   - CSS tooltips
   - Light/Dark mode support
   - Smooth transitions
   ================================================ */

/* === BASE SIDEBAR STYLES === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    background-color: #ffffff;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

/* Mobile: Hidden by default */
@media (max-width: 1199px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }
}

/* Desktop: Always visible */
@media (min-width: 1200px) {
    .sidebar {
        transform: translateX(0);
    }
}

/* === DARK MODE BASE === */
[data-theme=dark] .sidebar {
    background-color: #1a1f2e;
    border-right-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
}

/* === SIDEBAR LOGO === */
.sidebar-logo {
    height: 72px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

[data-theme=dark] .sidebar-logo {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.sidebar-logo img {
    max-height: 40px;
    width: auto;
    object-fit: contain;
    transition: opacity 0.2s ease;
}

/* === EXPANDED STATE (Default) === */
/* Light Mode: Show full light logo only */
.sidebar-logo img.full-logo-light {
    display: block;
}

.sidebar-logo img.full-logo-dark,
.sidebar-logo img.icon-logo-light,
.sidebar-logo img.icon-logo-dark {
    display: none;
}

/* Dark Mode Expanded: Show full dark logo only */
[data-theme=dark] .sidebar-logo img.full-logo-light {
    display: none;
}

[data-theme=dark] .sidebar-logo img.full-logo-dark {
    display: block;
}

[data-theme=dark] .sidebar-logo img.icon-logo-light,
[data-theme=dark] .sidebar-logo img.icon-logo-dark {
    display: none;
}

/* === CLOSE BUTTON (Mobile) === */
.sidebar-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background-color: #f1f5f9;
    color: #64748b;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-close-btn:hover {
    background-color: #e2e8f0;
    color: #334155;
}

[data-theme=dark] .sidebar-close-btn {
    background-color: #2d3748;
    color: #94a3b8;
}

[data-theme=dark] .sidebar-close-btn:hover {
    background-color: #3d4758;
    color: #e2e8f0;
}

@media (min-width: 1200px) {
    .sidebar-close-btn {
        display: none;
    }
}

/* === SIDEBAR MENU AREA === */
.sidebar-menu-area {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Allow overflow in collapsed mode for tooltips/flyout */
.sidebar.active .sidebar-menu-area {
    overflow: visible !important;
}

.sidebar-menu-area::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu-area::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu-area::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
}

.sidebar-menu-area:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme=dark] .sidebar-menu-area:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

/* === SIDEBAR MENU === */
.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* === MENU GROUP TITLES === */
.sidebar-menu .sidebar-menu-group-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    padding: 20px 12px 8px;
    margin: 0;
}

[data-theme=dark] .sidebar-menu .sidebar-menu-group-title {
    color: #64748b;
}

/* === MENU ITEMS === */
.sidebar-menu>li {
    margin-bottom: 4px;
}

.sidebar-menu>li>a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 30px;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
}

[data-theme=dark] .sidebar-menu>li>a {
    color: #94a3b8;
}

/* Menu Icons */
.sidebar-menu>li>a .menu-icon {
    font-size: 20px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

/* Hover State */
.sidebar-menu>li>a:hover {
    background-color: rgba(69, 104, 220, 0.08);
    color: #4568dc;
}

[data-theme=dark] .sidebar-menu>li>a:hover {
    background-color: rgba(69, 104, 220, 0.15);
    color: #7c9aff;
}

/* Active State - Rounded Design */
/* Active State - Rounded Design (Subtle Pill) */
.sidebar-menu>li>a.active-page,
.sidebar-menu li.dropdown.open>a,
.sidebar-menu li.dropdown.dropdown-open>a,
.sidebar-menu li.active>a {
    background: linear-gradient(135deg, rgba(69, 104, 220, 0.12) 0%, rgba(91, 124, 238, 0.12) 100%) !important;
    color: #4568dc !important;
    box-shadow: none !important;
    border-radius: 30px !important;
    border-left: none !important;
    margin-right: 0 !important;
}

[data-theme=dark] .sidebar-menu>li>a.active-page,
[data-theme=dark] .sidebar-menu li.dropdown.open>a,
[data-theme=dark] .sidebar-menu li.dropdown.dropdown-open>a,
[data-theme=dark] .sidebar-menu li.active>a {
    background: rgba(69, 104, 220, 0.2) !important;
    color: #7c9aff !important;
    box-shadow: none !important;
    border-left: none !important;
}

/* Active State & Open Dropdown Icon - Solid Circle */
.sidebar-menu>li>a.active-page .menu-icon,
.sidebar-menu li.dropdown.open>a .menu-icon,
.sidebar-menu li.dropdown.dropdown-open>a .menu-icon,
.sidebar-menu li.active>a .menu-icon {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #4568dc 0%, #5b7cee 100%) !important;
    color: #ffffff !important;
    fill: #ffffff !important;
    stroke: #ffffff !important;
    -webkit-text-fill-color: unset !important;
    opacity: 1 !important;
    background-clip: border-box;
    -webkit-background-clip: border-box;
    box-shadow: 0 4px 12px rgba(69, 104, 220, 0.35) !important;
    z-index: 10;
}

/* === DROPDOWN STYLES === */
.sidebar-menu li.dropdown>a::after {
    content: "\ea6e";
    font-family: remixicon;
    font-size: 16px;
    margin-left: auto;
    transition: transform 0.2s ease;
    opacity: 0.5;
    display: inline-block !important;
}

.sidebar-menu li.dropdown.open>a::after,
.sidebar-menu li.dropdown.dropdown-open>a::after {
    transform: rotate(90deg);
    opacity: 1;
}

.sidebar-menu li.dropdown.open>a,
.sidebar-menu li.dropdown.dropdown-open>a {
    background-color: rgba(69, 104, 220, 0.12);
    color: #4568dc;
}

[data-theme=dark] .sidebar-menu li.dropdown.open>a,
[data-theme=dark] .sidebar-menu li.dropdown.dropdown-open>a {
    background-color: rgba(69, 104, 220, 0.2);
    color: #7c9aff;
}

/* === SUBMENU === */
.sidebar-submenu {
    list-style: none;
    padding: 8px 0 8px 20px;
    margin: 0;
    display: none;
}

.sidebar-menu li.dropdown.open .sidebar-submenu {
    display: block;
}

.sidebar-submenu li {
    margin-bottom: 2px;
}

.sidebar-submenu li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

[data-theme=dark] .sidebar-submenu li a {
    color: #94a3b8;
}

.sidebar-submenu li a:hover {
    background-color: rgba(69, 104, 220, 0.08);
    color: #4568dc;
}

[data-theme=dark] .sidebar-submenu li a:hover {
    background-color: rgba(69, 104, 220, 0.12);
    color: #7c9aff;
}

.sidebar-submenu li a .menu-icon {
    font-size: 8px;
    opacity: 0.5;
}

.sidebar-submenu li.active-page a {
    background-color: rgba(69, 104, 220, 0.1);
    color: #4568dc;
}

[data-theme=dark] .sidebar-submenu li.active-page a {
    background-color: rgba(69, 104, 220, 0.15);
    color: #7c9aff;
}

/* ================================================
   COLLAPSED STATE
   ================================================ */

.sidebar.active {
    width: 80px;
}

/* Hide elements in collapsed state */
/* === COLLAPSED STATE: Hide ALL full logos === */
.sidebar.active .sidebar-logo img.full-logo-light,
.sidebar.active .sidebar-logo img.full-logo-dark {
    display: none !important;
}

/* Light Mode Collapsed: Show ONLY light icon */
.sidebar.active .sidebar-logo img.icon-logo-light {
    display: block !important;
    max-height: 44px;
    width: 44px;
    margin: 0 auto;
}

.sidebar.active .sidebar-logo img.icon-logo-dark {
    display: none !important;
}

/* Dark Mode Collapsed: Show ONLY dark icon */
[data-theme=dark] .sidebar.active .sidebar-logo img.icon-logo-light {
    display: none !important;
}

[data-theme=dark] .sidebar.active .sidebar-logo img.icon-logo-dark {
    display: block !important;
    max-height: 44px;
    width: 44px;
    margin: 0 auto;
}

.sidebar.active .sidebar-menu-group-title {
    display: none !important;
}

.sidebar.active .sidebar-menu>li>a span {
    display: none;
}

.sidebar.active .sidebar-menu li.dropdown>a::after {
    display: none;
}

.sidebar.active .sidebar-submenu {
    display: none !important;
}

/* Collapsed menu items */
.sidebar.active .sidebar-menu>li>a {
    justify-content: center;
    padding: 14px;
}

/* Collapsed icon styling - FULLY circular background */
.sidebar.active .sidebar-menu>li>a .menu-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #64748b;
}

[data-theme=dark] .sidebar.active .sidebar-menu>li>a .menu-icon {
    background-color: #2d3748;
    color: #94a3b8;
}

/* Collapsed hover state */
.sidebar.active .sidebar-menu>li>a:hover {
    background-color: transparent !important;
    color: inherit;
}

.sidebar.active .sidebar-menu>li>a:hover .menu-icon {
    background-color: rgba(69, 104, 220, 0.15);
    color: #4568dc;
}

[data-theme=dark] .sidebar.active .sidebar-menu>li>a:hover .menu-icon {
    background-color: rgba(69, 104, 220, 0.2);
    color: #7c9aff;
}

/* Collapsed active state */
/* Collapsed active state & dropdown open state overrides */
.sidebar.active .sidebar-menu>li>a.active-page,
.sidebar.active .sidebar-menu li.dropdown.open>a,
.sidebar.active .sidebar-menu li.dropdown.dropdown-open>a,
.sidebar.active .sidebar-menu li.active>a {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

/* Collapsed active/open state icon - FORCE CIRCLE */
.sidebar.active .sidebar-menu>li>a.active-page .menu-icon,
.sidebar.active .sidebar-menu li.dropdown.open>a .menu-icon,
.sidebar.active .sidebar-menu li.dropdown.dropdown-open>a .menu-icon,
.sidebar.active .sidebar-menu li.active>a .menu-icon {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #4568dc 0%, #5b7cee 100%) !important;
    color: #ffffff !important;
    fill: #ffffff !important;
    stroke: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    /* Re-add for collapsed as we want white */
    opacity: 1 !important;
    box-shadow: 0 4px 15px rgba(69, 104, 220, 0.35) !important;
}

/* === TOOLTIPS FOR COLLAPSED STATE === */
.sidebar.active .sidebar-menu>li>a[data-title]::before {
    content: attr(data-title);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #4568dc 0%, #5b7cee 100%);
    color: #ffffff;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(69, 104, 220, 0.25);
}

/* Tooltip arrow */
.sidebar.active .sidebar-menu>li>a[data-title]::after {
    content: '';
    position: absolute;
    left: calc(100% + 4px);
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #4568dc;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 9999;
}

/* Show tooltip on hover */
.sidebar.active .sidebar-menu>li>a[data-title]:hover::before,
.sidebar.active .sidebar-menu>li>a[data-title]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Dark mode tooltips */
[data-theme=dark] .sidebar.active .sidebar-menu>li>a[data-title]::before {
    background-color: #ffffff;
    color: #1e293b;
}

[data-theme=dark] .sidebar.active .sidebar-menu>li>a[data-title]::after {
    border-right-color: #ffffff;
}

/* === FLYOUT SUBMENU FOR COLLAPSED DROPDOWNS === */
/* Hide tooltip for dropdowns, show flyout instead */
.sidebar.active .sidebar-menu li.dropdown>a[data-title]:hover::before,
.sidebar.active .sidebar-menu li.dropdown>a[data-title]:hover::after {
    opacity: 0;
    visibility: hidden;
}

/* Flyout submenu container */
.sidebar.active .sidebar-menu li.dropdown:hover .sidebar-submenu {
    display: block !important;
    position: absolute;
    left: calc(100% + 10px);
    /* Increased gap slightly */
    top: 0;
    min-width: 200px;
    background-color: #ffffff;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 9999;
}

/* Invisible bridge to prevent menu from disappearing */
.sidebar.active .sidebar-menu li.dropdown:hover .sidebar-submenu::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 0;
    width: 20px;
    height: 100%;
    background: transparent;
}

[data-theme=dark] .sidebar.active .sidebar-menu li.dropdown:hover .sidebar-submenu {
    background-color: #1a1f2e;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* Position the dropdown li for absolute positioning */
.sidebar.active .sidebar-menu li.dropdown {
    position: relative;
}

/* Flyout submenu items */
.sidebar.active .sidebar-menu li.dropdown .sidebar-submenu li a {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    color: #475569;
}

[data-theme=dark] .sidebar.active .sidebar-menu li.dropdown .sidebar-submenu li a {
    color: #94a3b8;
}

.sidebar.active .sidebar-menu li.dropdown .sidebar-submenu li a:hover {
    background-color: rgba(69, 104, 220, 0.1);
    color: #4568dc;
}

[data-theme=dark] .sidebar.active .sidebar-menu li.dropdown .sidebar-submenu li a:hover {
    background-color: rgba(69, 104, 220, 0.15);
    color: #7c9aff;
}

/* === PREVENT HOVER EXPANSION === */
.sidebar.active:hover {
    width: 80px !important;
}

/* === RESPONSIVE WIDTHS === */
@media (min-width: 1400px) {
    .sidebar {
        width: 280px;
    }

    .sidebar.active {
        width: 80px;
    }

    .sidebar.active:hover {
        width: 80px !important;
    }
}

@media (min-width: 1650px) {
    .sidebar {
        width: 300px;
    }

    .sidebar.active {
        width: 88px;
    }

    .sidebar.active:hover {
        width: 88px !important;
    }
}

/* === SIDEBAR END === */