/* Mobile Menu Fix - Prevents gray layout and enables scrolling/clicking */
/* This file fixes the mobile menu issues on small devices */
/* STANDALONE - Does not require emergency-scroll-fix.css */

/* Fix for small devices (mobile phones) */
@media (max-width: 767px) {
    /* Prevent body overflow hidden when menu is expanded */
    .layout-menu-expanded body {
        overflow: auto !important;
        position: relative !important;
        width: auto !important;
        padding-right: 0 !important;
        margin-right: 0 !important;
        height: auto !important;
        max-height: none !important;
    }
    
    /* Ensure the layout overlay (gray background) is properly clickable */
    .layout-menu-expanded .layout-overlay {
        display: block !important;
        background: rgba(67, 89, 113, 0.5) !important;
        cursor: pointer !important;
        z-index: 1040 !important;
    }
    
    /* Make sure menu content is scrollable */
    .layout-menu-expanded .layout-menu {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: 100vh !important;
        z-index: 1050 !important;
    }
    
    /* Ensure menu inner content can scroll */
    .layout-menu-expanded .layout-menu .menu-inner {
        overflow-y: auto !important;
        max-height: calc(100vh - 4rem) !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 2rem !important;
    }
    
    /* Ensure proper scrollbar styling for mobile */
    .layout-menu .menu-inner::-webkit-scrollbar {
        width: 4px !important;
    }
    
    .layout-menu .menu-inner::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1) !important;
        border-radius: 2px !important;
    }
    
    .layout-menu .menu-inner::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.3) !important;
        border-radius: 2px !important;
    }
    
    .layout-menu .menu-inner::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, 0.5) !important;
    }
    
    /* Fix touch scrolling behavior */
    .layout-menu .menu-inner {
        scroll-behavior: smooth !important;
        touch-action: pan-y !important;
    }
    
    /* Ensure page content remains accessible under overlay */
    .layout-menu-expanded .layout-page {
        pointer-events: none !important;
    }
    
    /* But allow interaction with the overlay to close menu */
    .layout-menu-expanded .layout-overlay {
        pointer-events: auto !important;
    }
    
    /* Ensure menu itself is interactive */
    .layout-menu-expanded .layout-menu {
        pointer-events: auto !important;
    }
    
    /* Fix menu toggle button positioning */
    .layout-menu-expanded .layout-menu-toggle {
        z-index: 1060 !important;
    }
}

/* Additional fix for very small devices */
@media (max-width: 480px) {
    .layout-menu-expanded .layout-menu {
        width: 280px !important;
        max-width: 90vw !important;
    }
}

/* Fix for when menu is not expanded - ensure normal scrolling */
body:not(.layout-menu-expanded) {
    overflow: auto !important;
    position: relative !important;
}

/* Override any conflicting modal styles */
.layout-menu-expanded:not(.modal-open) body {
    overflow: auto !important;
    padding-right: 0 !important;
}

/* Additional safeguards - ensure HTML element scrolling */
@media (max-width: 767px) {
    .layout-menu-expanded html {
        overflow: auto !important;
        position: relative !important;
        height: auto !important;
        max-height: none !important;
    }
    
    /* Ensure page wrapper stays scrollable */
    .layout-menu-expanded .layout-wrapper {
        overflow: visible !important;
        height: auto !important;
    }
    
    /* Prevent any container from blocking scroll */
    .layout-menu-expanded .layout-container {
        overflow: visible !important;
        height: auto !important;
    }
}