/* ============================================================================
   MOBILE STYLES

   Mobile-specific UI components and responsive layouts for tablet/phone.
   - Mobile controls (hidden on desktop, shown on mobile)
   - Mobile menu bar and overlay system
   - Mobile view controls (pan/zoom buttons)
   - Responsive media query for tablet and below

   Note: z-index values are defined in z-index.css
   Note: Light theme overrides are defined in theme.css
   ============================================================================ */

/* ============================================================================
   MOBILE CONTROLS (Hidden on Desktop)
   ============================================================================ */

/* Mobile controls - hidden on desktop */
#mobile-controls {
    display: none;
}

/* Mobile timestep slider (hidden on desktop) */
#mobile-timestep-slider {
    display: none; /* Old standalone element - no longer used */
}

/* Mobile timestep inline (inside fps-counter, hidden on desktop) */
.mobile-timestep-inline {
    display: none;
}

.mobile-timestep-inline .mobile-timestep-label {
    font-size: 11px;
    white-space: nowrap;
    margin-bottom: 2px;
    color: #FF9800;
}

.mobile-timestep-inline input[type="range"] {
    width: 80px;
    height: 4px;
}

/* ============================================================================
   MOBILE MENU BAR (Hidden on Desktop)
   ============================================================================ */

#mobile-menu-bar {
    display: none; /* Hidden by default, shown in media query */
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #444;
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 8px 6px;
    flex-direction: column;
    gap: 12px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
}

.mobile-menu-btn {
    background: #333;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
    user-select: none;
}

.mobile-menu-btn:hover {
    background: #444;
    border-color: #666;
}

.mobile-menu-btn:active {
    background: #222;
    transform: scale(0.95);
}

.mobile-menu-btn.active {
    background: #4CAF50;
    border-color: #66BB6A;
}

/* ============================================================================
   MOBILE OVERLAY PANEL
   ============================================================================ */

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(30, 30, 30, 0.98);
    overflow-y: auto;
    padding: 20px;
    padding-top: 60px; /* Space for close button */
    animation: slideInRight 0.3s ease-out;
}

.mobile-overlay.active {
    display: block;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.mobile-overlay-close {
    position: fixed;
    top: 10px;
    right: 10px;
    background: #333;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}

.mobile-overlay-close:hover {
    background: #444;
    transform: scale(1.1);
}

.mobile-overlay-close:active {
    background: #222;
    transform: scale(0.95);
}

/* ============================================================================
   MOBILE VIEW CONTROLS (Hidden on Desktop)
   ============================================================================ */

#mobile-view-controls {
    display: none; /* Hidden by default, shown in media query */
    position: fixed;
    bottom: 20px;
    right: 8px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 6px;
    flex-direction: column;
    gap: 8px;
    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.5);
}

.mobile-view-btn {
    background: #333;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    font-size: 20px;
    font-weight: bold;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
    user-select: none;
}

.mobile-view-btn:hover {
    background: #444;
    border-color: #666;
}

.mobile-view-btn:active {
    background: #222;
    transform: scale(0.95);
}

/* ============================================================================
   MOBILE RESPONSIVE LAYOUT (Tablet and Below)
   ============================================================================ */

@media screen and (max-width: 768px) {
    /* Show mobile menu bar - position below fps counter */
    #mobile-menu-bar {
        display: flex;
        top: 125px; /* Below fps-counter with some spacing */
        transform: none; /* Remove vertical centering */
    }

    /* Show compact mobile view controls */
    #mobile-view-controls {
        display: flex;
    }

    /* Hide desktop panels by default */
    #controls,
    #zoom-pan-controls,
    #display-options {
        display: none;
    }

    /* When panels are opened as overlays on mobile, they take full screen */
    #controls.mobile-overlay,
    #zoom-pan-controls.mobile-overlay,
    #display-options.mobile-overlay {
        display: block;
    }

    /* Adjust panel widths for full-screen mobile */
    #controls.mobile-overlay {
        width: 100%;
        max-width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        max-height: 100vh;
    }

    #zoom-pan-controls.mobile-overlay {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
        position: static;
    }

    #display-options.mobile-overlay {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
        position: static;
    }

    /* Hide bottom overlays except FPS counter */
    #histogram-panel,
    #cursor-position,
    #step-time-counter {
        display: none;
    }

    /* Hide desktop FPS counter on mobile */
    #fps-counter {
        display: none;
    }

    /* Show unified mobile controls - positioning only */
    #mobile-controls {
        display: block;
        position: fixed;
        top: 40px;
        left: 8px;
        right: 8px;
    }

    /* Reduce font sizes slightly on mobile */
    body {
        font-size: 13px;
    }

    h1 {
        font-size: 16px;
    }

    h2 {
        font-size: 14px;
    }

    label {
        font-size: 12px;
    }

    /* Increase touch target sizes */
    button,
    input[type="range"],
    select {
        min-height: 36px;
    }

    .slider-btn {
        min-width: 36px;
        min-height: 36px;
        font-size: 14px;
    }

    /* Compact top menu bar on mobile */
    #menu-bar {
        padding: 4px 8px;
        height: 32px;
    }

    .menu-item {
        padding: 4px 10px;
        font-size: 12px;
    }

    .menu-item span:not(:first-child) {
        display: none; /* Hide text labels, keep only icons */
    }

    .menu-item svg {
        margin-right: 0 !important;
    }
}
