/* Shell stacking — uses --z-* tokens from theme.css (sidebar always below modal). */

@media (min-width: 992px) {
    #sidebar {
        position: fixed !important;
        top: 64px !important;
        left: 0;
        bottom: 0;
        height: calc(100vh - 64px) !important;
        max-height: calc(100vh - 64px) !important;
        overflow-y: auto !important;
        z-index: var(--z-sidebar) !important;
        border-right: 1px solid var(--border-color) !important;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    #content {
        margin-left: 260px !important;
        width: calc(100% - 260px) !important;
        transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    #sidebar.active ~ #content {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

#sidebar.active.sidebar-hover-expanded {
    min-width: 260px !important;
    max-width: 260px !important;
    width: 260px !important;
    margin-left: 0 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: var(--z-sidebar-elevated) !important;
    box-shadow: 12px 0 35px rgba(0, 0, 0, 0.45) !important;
    position: fixed !important;
    top: 64px !important;
    left: 0;
    bottom: 0;
    height: calc(100vh - 64px) !important;
    background-color: var(--sidebar-bg, #ffffff) !important;
    overflow-y: auto !important;
    border-right: 1px solid var(--border-color) !important;
}
#sidebar.active.sidebar-hover-expanded .sidebar-header,
#sidebar.active.sidebar-hover-expanded ul.components,
#sidebar.active.sidebar-hover-expanded ul.components li a {
    background-color: var(--sidebar-bg, #ffffff) !important;
}
#sidebar.active.sidebar-hover-expanded ul.components li a:hover {
    background-color: var(--sidebar-hover-bg, rgba(0, 0, 0, 0.04)) !important;
}
#sidebar.active.sidebar-hover-expanded .sidebar-header span,
#sidebar.active.sidebar-hover-expanded ul li a span,
#sidebar.active.sidebar-hover-expanded .sidebar-section-header span,
#sidebar.active.sidebar-hover-expanded .category-chevron {
    display: inline-block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition: opacity 0.2s ease-in-out;
}
/* Group headers must be visible on hover (collapsed rule uses display:none) */
#sidebar.active.sidebar-hover-expanded .sidebar-section-header {
    display: flex !important;
    justify-content: space-between !important;
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
}
/* Show all report groups while hovering collapsed flyout */
#sidebar.active.sidebar-hover-expanded .sidebar-category-list {
    display: block !important;
}
#sidebar.active.sidebar-hover-expanded .sidebar-version-footer,
#sidebar.active.sidebar-hover-expanded .sidebar-customer-logo {
    display: block !important;
}
#sidebar.active.sidebar-hover-expanded ul li a {
    text-align: left !important;
    padding-left: 1.25rem !important;
    white-space: nowrap !important;
    justify-content: flex-start !important;
}

/* Mobile & Tablet Offcanvas Drawer & Backdrop Overlay */
@media (max-width: 991.98px) {
    #sidebar {
        position: fixed !important;
        top: 64px !important;
        left: 0;
        bottom: 0;
        height: calc(100vh - 64px) !important;
        max-height: calc(100vh - 64px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        z-index: var(--z-sidebar-elevated) !important;
        margin-left: 0 !important;
        width: 285px !important;
        min-width: 285px !important;
        max-width: 285px !important;
        box-shadow: none;
        transform: translateX(-105%);
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s !important;
    }

    #sidebar.show-mobile {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4) !important;
    }

    #sidebar ul.components {
        padding-bottom: 90px !important;
    }

    #sidebarCollapse {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        border-radius: 8px;
        font-size: 1.15rem;
        cursor: pointer;
    }
    .navbar-custom {
        padding: 10px 15px !important;
    }

    .navbar-icon-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        padding: 0 !important;
        border-radius: 8px;
        background-color: var(--card-bg);
        color: var(--text-color);
        border-color: var(--border-color);
    }

    .sidebar-section-header.drag-over-header {
        background-color: rgba(13, 110, 253, 0.15) !important;
        border: 2px dashed var(--primary-color) !important;
        border-radius: 8px;
    }

    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: var(--z-sidebar-backdrop);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

    /* Report toolbar wraps on narrow screens (D5) */
    .dt-action-toolbar,
    .report-action-bar {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        top: 56px !important;
    }
    .report-action-bar {
        /* mobile topnav height — thead offset still measured in JS */
        top: 56px !important;
    }
}

#reportDataTable thead th, .table-custom thead th {
    background-color: var(--primary-color);
    color: #ffffff;
}
