/* ===============================================
   MOBILE STYLES - osmkeyvalue mobile.css
   ===============================================
   Mobile-specific styles for screens < 600px
   Separated from desktop styles for maintainability
*/

/* Mobile/Responsive Mode (screens < 600px) */
@media only screen and (max-width: 599px) {
    /* Mobile layout: Full screen map with bottom sliding menu */
    .flex-row {
        flex-direction: column; /* Stack map and menu vertically */
        height: 100vh;
        position: relative;
        overflow: hidden;
    }

    .map {
        height: 100vh; /* Full height for map when menu hidden */
        width: 100vw;
        border: none;
        position: relative;
        flex: 1 1 auto;
        min-width: 100vw;
    }

    /* When menu is visible, hide map completely */
    .flex-row.menu-active .map {
        height: 0; /* Hide map when menu is open */
        transition: height 0.3s ease-in-out;
    }

    /* Menu slides up from bottom */
    .menu {
        height: 0; /* Hidden by default */
        min-height: 0;
        width: 100vw;
        background: white;
        border-top: 3px solid #567CAC;
        transform: translateY(0); /* Start in normal position */
        transition: height 0.3s ease-in-out, min-height 0.3s ease-in-out;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Menu visible state - expand to full screen */
    .menu.menu-visible {
        height: 100vh; /* Full screen menu when visible */
        min-height: 100vh; /* Full screen height */
    }

    /* Menu content - horizontal scrolling when visible */
    .menu.menu-visible .osmcat-menu {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        width: 100%;
        height: calc(100% - 60px);
        overflow-x: auto;
        overflow-y: hidden;
        gap: 1px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #888 #f1f1f1;
    }

    /* Individual menu sections in horizontal layout */
    .menu.menu-visible .osmcat-layer,
    .menu.menu-visible .osmcat-overlay,
    .menu.menu-visible .osmcat-router-section,
    .menu.menu-visible .query-statistics {
        flex: 0 0 auto;
        width: 280px;
        min-width: 250px;
        border: 1px solid #BBB;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: white;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100vh - 80px);
    }

    /* Query Statistics in horizontal layout */
    .menu.menu-visible .query-statistics {
        background: #f8f9fa;
        padding: 8px;
        max-height: calc(100vh - 80px);
    }

    /* Default menu layout when hidden (2 columns) */
    .osmcat-menu {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        width: 100%;
        height: calc(100% - 60px);
        overflow: visible;
        gap: 1px;
    }

    /* Default 2-column layout for hidden menu */
    .osmcat-layer:first-of-type {
        flex: 1 1 50%;
        width: 50%;
        border-right: 1px solid #BBB;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: white;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: 100%;
    }

    .osmcat-layer:nth-of-type(2),
    .osmcat-overlay {
        flex: 1 1 50%;
        width: 50%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: white;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: 100%;
    }

    /* Query Statistics styling */
    .query-statistics {
        width: 100%;
        padding: 8px;
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        border-radius: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #888 #f1f1f1;
    }

    /* Mobile control buttons positioning */
    .osmcat-geobutton,
    .osmcat-infobutton,
    .osmcat-sharebutton,
    .osmcat-clearoverlaybutton,
    .osmcat-panoramax,
    .osmcat-mapillary,
    .osmcat-router {
        right: 8px;
        width: 32px !important;
        height: 32px !important;
        font-size: 14px;
        z-index: 1001;
        position: fixed; /* Keep buttons fixed since they need to stay on map */
    }

    /* Button positions */
    .osmcat-router { top: 80px; }
    .osmcat-clearoverlaybutton { 
        top: 115px; 
        pointer-events: auto;
        z-index: 1002;
    }
    .osmcat-mapillary { bottom: 260px; }
    .osmcat-panoramax { bottom: 210px; }
    .osmcat-sharebutton { bottom: 160px; }
    .osmcat-geobutton { bottom: 110px; }
    .osmcat-infobutton { bottom: 60px; }

    /* Menu toggle button */
    .menu-toggle {
        position: fixed;
        bottom: 290px; /* Above Mapillary button (260px) */
        right: 10px;
        z-index: 1002;
        width: 50px;
        height: 50px;
        background: #567CAC;
        color: white;
        border: none;
        border-radius: 50%;
        font-size: 20px;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .menu-toggle:hover {
        background: #34587C;
        transform: scale(1.1);
        box-shadow: 0 6px 16px rgba(0,0,0,0.4);
    }

    .menu-toggle.active {
        background: #05CB63;
        transform: scale(1.1);
        box-shadow: 0 6px 16px rgba(5, 203, 99, 0.4);
    }

    /* Enhanced Mapillary button when active */
    .osmcat-mapillary.active {
        background-color: #05CB63 !important;
    }

    /* Ensure OpenLayers attribution is visible on mobile */
    .ol-attribution {
        position: fixed !important;
        bottom: 5px !important;
        left: 5px !important;
        background: rgba(255,255,255,0.8) !important;
        padding: 2px 5px !important;
        font-size: 10px !important;
        border-radius: 3px !important;
        z-index: 1000 !important;
        max-width: 200px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* Ensure attribution doesn't conflict with other elements */
    .ol-attribution a {
        color: #333 !important;
        font-size: 10px !important;
    }

    /* Ensure OpenLayers scale line is visible on mobile */
    .ol-scale-line {
        position: fixed !important;
        bottom: 25px !important;
        left: 5px !important;
        background: rgba(255,255,255,0.8) !important;
        padding: 2px 5px !important;
        font-size: 10px !important;
        border-radius: 3px !important;
        z-index: 1000 !important;
        border: 1px solid #ccc !important;
    }

    .ol-scale-line-inner {
        border: none !important;
        border-bottom: 2px solid #000 !important;
        font-size: 10px !important;
        color: #000 !important;
        text-align: center !important;
    }
}
