/* Mobile Navigation Overlay - Full Screen for XS devices (<576px) */
/* Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/@media */

@media (max-width: 575.98px) {
    /* CRITICAL: Override Bootstrap d-none d-sm-flex classes on sidebar */
    /* The template has class="xaf-sidebar sidebar d-none d-sm-flex" which hides it on mobile */
    .xaf-sidebar.sidebar.d-none {
        display: block !important;
    }

    /* Mobile navigation dropdown - comes from bottom, full width */
    .xaf-sidebar.sidebar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: none !important;
        max-height: 0 !important;
        z-index: 9999 !important;
        background-color: var(--dxbl-bg-color, #fff) !important;
        overflow: hidden !important;
        transition: max-height 0.3s ease-in-out !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
    }

    /* Show dropdown when mobile menu is open */
    #main-window-template-component.sidebar-mobile-open .xaf-sidebar.sidebar {
        max-height: calc(100vh - 60px) !important; /* Leave space for footer at bottom */
        height: calc(100vh - 60px) !important; /* Explicit height */
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important; /* iOS momentum scrolling */
        padding-bottom: 80px !important; /* Extra padding so content isn't hidden behind footer */
    }

    /* Ensure footer stays at bottom and above the menu */
    .pineapple-footer {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        z-index: 10000 !important; /* Higher than menu */
    }

    /* Backdrop overlay when menu is open */
    #main-window-template-component.sidebar-mobile-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        animation: fadeIn 0.3s ease-in-out;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    /* Ensure hamburger button is visible and touch-friendly */
    .btn-hamburger {
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: 10px !important;
    }

    /* Prevent body scroll when menu is open */
    body:has(#main-window-template-component.sidebar-mobile-open) {
        overflow: hidden;
    }

    /* Full width main content on mobile */
    .pineapple-main-content {
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* Remove sidebar shadow on mobile (only show when overlay is active) */
    .sidebar-sm-shadow {
        display: none;
    }

    /* Minimum 44px touch targets (Apple HIG / Material Design) */
    /* Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/min-height */

    button,
    a,
    .dxbl-btn,
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Navigation items spacing for thumb-friendly tapping */
    .xaf-sidebar.sidebar a,
    .xaf-sidebar.sidebar button {
        padding: 12px 16px !important;
        min-height: 48px;
    }

    /* Input fields - 16px minimum to prevent iOS auto-zoom */
    /* Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/font-size */
    input,
    select,
    textarea,
    .dxbl-edit-box input {
        font-size: 16px !important;
    }

    .dxbl-accordion-group-header {
        padding: 4px 8px !important;
        min-height: 32px !important;
    }

    .dxbl-group-control {
        margin-bottom: 2px !important;
    }

    /* Fix DevExpress grid header icons alignment and size on mobile */
    .dxbl-grid-header-content svg,
    .dxbl-grid-header-content .dxbl-image,
    .dxbl-grid-header-content .dxbl-icon,
    .dxbl-grid-header-content .dxbl-grid-sort-asc,
    .dxbl-grid-header-content .dxbl-grid-sort-desc,
    .dxbl-grid-header-content .dxbl-grid-filter-menu-funnel-btn {
        vertical-align: middle !important;
        margin-left: 4px !important;
        margin-right: 0 !important;
        width: 16px !important;
        height: 16px !important;
        display: inline-block !important;
        position: relative !important;
        top: 0 !important;
    }

    /* If icons still overlap, force them to a new line below the header text */
    .dxbl-grid-header-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        gap: 2px !important;
        font-size: 12px !important; /* Make header text a little smaller */
    }

        .dxbl-grid-header-content span,
        .dxbl-grid-header-content .dxbl-grid-sort-asc,
        .dxbl-grid-header-content .dxbl-grid-sort-desc,
        .dxbl-grid-header-content .dxbl-grid-filter-menu-funnel-btn {
            margin-top: 0 !important;
            margin-bottom: 0 !important;
        }

}


