/* Copyright (c) 2026 Dung1412. All Rights Reserved. */
/* ============================================================================
   MOBILE & TABLET RESPONSIVE ENHANCEMENT LAYER (<= 960px)
   Designed for smooth Coffee-Shop Phone / iPad presentations without affecting Desktop.
   ============================================================================ */

/* Floating Mobile Drawer Trigger Button (Hidden on Desktop) */
#pt-mobile-drawer-fab,
#pt-mobile-drawer-backdrop {
    display: none;
}

@media (max-width: 960px) {
    html, body {
        overscroll-behavior: none;
        -webkit-tap-highlight-color: transparent;
    }

    /* Prevent iOS Safari auto-zoom when focusing inputs */
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* --- 1. COMPACT SCROLLABLE TOP HEADER --- */
    .app-header {
        height: 52px !important;
        padding: 0 8px !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
    }

    .brand-section {
        gap: 6px !important;
        flex-shrink: 0;
    }

    .brand-logo-img {
        width: 30px !important;
        height: 30px !important;
    }

    .brand-info h1 {
        font-size: 12px !important;
        letter-spacing: 0.4px !important;
        white-space: nowrap;
    }

    .brand-info p {
        display: none !important;
    }

    .header-actions {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 5px !important;
        padding: 4px 2px !important;
        align-items: center;
    }

    .header-actions::-webkit-scrollbar {
        display: none;
    }

    .header-actions .btn-header {
        padding: 5px 8px !important;
        font-size: 11px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    /* Make dropdowns fixed-centered on small screens so they never clip inside scrollable header */
    .header-dropdown-menu.open,
    .header-dropdown-menu.show,
    #user-dropdown-menu[style*="block"] {
        position: fixed !important;
        top: 56px !important;
        right: 10px !important;
        left: auto !important;
        max-width: calc(100vw - 20px) !important;
        max-height: 75dvh !important;
        overflow-y: auto !important;
        z-index: 9500 !important;
    }

    /* --- 2. FULLSCREEN MAP + SLIDE-OVER SIDEBAR DRAWER --- */
    .main-container,
    .app-main {
        height: calc(100dvh - 52px) !important;
        position: relative !important;
    }

    .sidebar,
    aside.sidebar {
        position: fixed !important;
        top: 52px !important;
        left: 0 !important;
        bottom: 0 !important;
        width: min(88vw, 370px) !important;
        max-width: 92vw !important;
        z-index: 8800 !important;
        transform: translateX(-104%) !important;
        transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1) !important;
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.72) !important;
    }

    body.pt-mobile-drawer-open .sidebar,
    body.pt-mobile-drawer-open aside.sidebar {
        transform: translateX(0) !important;
    }

    #pt-mobile-drawer-backdrop {
        position: fixed;
        inset: 52px 0 0 0;
        background: rgba(2, 6, 23, 0.56);
        backdrop-filter: blur(3px);
        z-index: 8700;
        display: none;
    }

    body.pt-mobile-drawer-open #pt-mobile-drawer-backdrop {
        display: block !important;
    }

    /* Floating Action Pill to Open/Close Sidebar Drawer */
    #pt-mobile-drawer-fab {
        display: inline-flex !important;
        align-items: center;
        gap: 7px;
        position: fixed;
        left: 12px;
        bottom: 78px;
        z-index: 8600;
        padding: 10px 15px;
        border-radius: 999px;
        border: 1px solid rgba(52, 211, 153, 0.65);
        background: linear-gradient(135deg, rgba(6, 78, 59, 0.94), rgba(14, 116, 144, 0.94));
        color: #f8fafc;
        font-size: 12.5px;
        font-weight: 800;
        letter-spacing: 0.3px;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65), 0 0 18px rgba(16, 185, 129, 0.35);
        backdrop-filter: blur(12px);
        cursor: pointer;
    }

    .map-viewport {
        width: 100% !important;
        height: 100% !important;
        flex: 1 1 100% !important;
    }

    /* Hide desktop sidebar collapse button inside mobile mode */
    #btn-toggle-sidebar,
    .sidebar-collapse-handle {
        display: none !important;
    }

    /* --- 3. FLOATING MAP WIDGETS (Basemap Switcher, Timeline, Coordinate Bar) --- */
    .basemap-switcher,
    .map-layer-panel,
    #basemap-panel {
        max-width: 240px !important;
        max-height: 55dvh !important;
        overflow-y: auto !important;
        top: 60px !important;
        right: 8px !important;
        font-size: 11px !important;
    }

    .planet-timeline-bar,
    #planet-timeline-container {
        left: 8px !important;
        right: 8px !important;
        bottom: 26px !important;
        transform: none !important;
        max-width: calc(100vw - 16px) !important;
        padding: 6px 8px !important;
    }

    .coord-status-bar,
    #coord-status-bar {
        font-size: 9.5px !important;
        padding: 3px 8px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(100vw - 16px);
    }

    /* --- 4. MODALS & FLOATING WINDOWS --- */
    .modal-content,
    .rs-modal-card,
    #mapinfo-floating-window {
        width: 96vw !important;
        max-width: 96vw !important;
        max-height: 90dvh !important;
        border-radius: 14px !important;
    }

    /* --- 5. GRAND INTRO CINEMA & LOGIN CARD ON MOBILE --- */
    #pt-intro-cinema-hud {
        padding: 14px 14px 18px !important;
    }

    #pt-intro-chapter-title {
        font-size: 15px !important;
        line-height: 1.3 !important;
    }

    #pt-intro-caption {
        font-size: 12px !important;
        padding: 7px 12px !important;
    }

    #pt-intro-mute-btn,
    #pt-intro-skip-btn {
        padding: 8px 13px !important;
        font-size: 11.5px !important;
    }

    #pt-intro-card {
        padding: 22px 18px 18px !important;
        max-height: 92dvh !important;
        overflow-y: auto !important;
    }

    #pt-intro-card h1 {
        font-size: 21px !important;
    }
}

/* Landscape Phone Tweaks */
@media (max-width: 960px) and (max-height: 500px) {
    #pt-intro-card {
        padding: 14px 18px !important;
    }
    #pt-intro-card > div:first-child {
        width: 62px !important;
        height: 62px !important;
        margin-bottom: 8px !important;
    }
    #pt-mobile-drawer-fab {
        bottom: 60px;
        padding: 8px 12px;
    }
}
