/* 07-responsive.css — All @media breakpoint rules
   =========================================================== */

/* -----------------------------------------------------------
   19. Responsive
   ----------------------------------------------------------- */

/* Body scroll lock when mobile sidebar is open */
body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    /* Prevents iOS Safari rubber-band scroll behind overlay */
    touch-action: none;
    -webkit-overflow-scrolling: none;
}

@media (max-width: 991.98px) {
    /* Larger touch target for sidebar toggle on mobile */
    .fp-sidebar-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    /* Topbar: hide separator and reduce padding */
    .fp-topbar-sep { display: none; }
    .fp-topbar-label { display: none; }
    .fp-topbar { padding: 0.4rem 0.75rem; gap: 0.25rem; }
    .fp-topbar-title { font-size: 0.95rem; }

    /* On mobile, sidebar overlays instead of pushing content */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        /* Use dvh for iOS Safari dynamic viewport; fallback to 100% */
        height: 100%;
        height: 100dvh;
        width: var(--sidebar-w);
        min-width: var(--sidebar-w);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        -webkit-overflow-scrolling: touch;
    }

    #sidebar.show {
        transform: translateX(0);
    }

    /* Backdrop overlay when sidebar is open */
    .fp-sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1039;
        display: none;
        -webkit-tap-highlight-color: transparent;
    }

    .fp-sidebar-backdrop.show {
        display: block;
    }

    .page-wrapper {
        margin-left: 0 !important;
    }

    /* On mobile, collapsed state doesn't apply */
    html.sidebar-collapsed #sidebar {
        width: var(--sidebar-w);
        min-width: var(--sidebar-w);
    }

    /* Restore hidden text inside sidebar on mobile (even if collapsed on desktop) */
    html.sidebar-collapsed #sidebar .fp-logo-text,
    html.sidebar-collapsed #sidebar .nav-link-title,
    html.sidebar-collapsed #sidebar .fp-btn-text,
    html.sidebar-collapsed #sidebar .fp-sidebar-version {
        display: revert;
    }

    html.sidebar-collapsed #sidebar .nav-link {
        justify-content: flex-start;
        padding: 0.3125rem 0.75rem;
        margin: 1px 0.5rem;
    }

    .fp-content {
        padding: 1rem;
    }

    /* Hide the in-sidebar mobile toggler — topbar button handles it now */
    #mobile-menu-toggle {
        display: none;
    }

}

/* Dropdown inline-flow rules: only when sidebar is in mobile overlay mode.
   Scoped to #sidebar.show so they don't affect desktop layout on touch devices ≥992px. */
#sidebar.show .nav-item.dropdown {
    position: static;
}

#sidebar.show .dropdown-menu {
    position: static !important;
    border: none;
    background: transparent;
    box-shadow: none;
    padding-left: 1rem;
}

#sidebar.show .nav-item.dropdown.show > .dropdown-menu {
    display: block;
}

#sidebar.show .dropend {
    position: static;
}

#sidebar.show .dropend .dropdown-menu {
    position: static !important;
    padding-left: 1rem;
}

@media (min-width: 992px) {
    /* Ensure sidebar is always visible on large screens */
    #sidebar {
        transform: none !important;
    }
}
