/* Custom CSS to fix mobile sidebar scrolling issues */

@media (max-width: 768px) {
    /* Prevent the background page content from scrolling when the sidebar is open on mobile */
    body.show-sidebar #wrapper {
        overflow: hidden !important;
        max-height: calc(100vh - 57px) !important;
    }

    /* Ensure the mobile sidebar has smooth scrolling and its own scrollbar */
    #menu.sidebar {
        /* main.js inflates the height to the full document height, which makes
           the off-canvas drawer scroll with the page instead of itself. */
        position: fixed !important;
        top: 0;
        bottom: 0;
        height: auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden;
        z-index: 60;
        -webkit-overflow-scrolling: touch !important; /* Smooth momentum scrolling on iOS Safari */
    }
}

/* Ensure setup menu is always on top of main menu sidebar on desktop/mobile when active */
#setup-menu-wrapper {
    z-index: 101 !important;
}

/* Admin top bar logo
   The header is white, so it renders the light-background lockup. The logo
   files are wide (roughly 9:1) and the header's flex row used to squeeze them
   down to a few dozen pixels, which cropped the wordmark to its tail. */
body.admin #header #logo {
    min-width: 220px;
}

body.admin #header #logo a.logo {
    display: inline-flex;
    align-items: center;
    height: 100%;
    max-width: none;
}

body.admin #header #logo img {
    height: 28px !important;
    width: auto !important;
    max-width: none !important;
    object-fit: contain;
}

/* Admin shell: fixed top bar + independently scrolling sidebar.
   main.js (mainWrapperHeightFix) writes an inline min-height equal to the whole
   document height on both #menu and #wrapper, which makes the sidebar as tall as
   the page and drags it along when the page scrolls. Pin both columns and let
   each one own its scrolling. */
@media (min-width: 769px) {
    body.admin #header {
        position: fixed;
        top: 0;
        right: 0;
        left: 0;
        z-index: 100;
    }

    body.admin #menu.sidebar {
        position: fixed;
        top: 57px;
        bottom: 0;
        left: 0;
        z-index: 99;
        height: auto !important;
        min-height: 0 !important;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
    }

    /* The scroll box now starts below the header, so the profile card no longer
       has to clear it with the stock 80px top margin. */
    body.admin #menu.sidebar .sidebar-user-profile {
        margin-top: 23px;
    }

    body.admin #wrapper {
        margin-top: 57px;
        height: auto !important;
        min-height: calc(100vh - 57px) !important;
    }
}
