/* ================================================================
   MOBILE-ONLY STYLES FOR LOCATIONS PAGE (< 768px)
   ================================================================ */

/* ===== MAP CONTAINER - UNIVERSAL FIX ===== */
/* This ensures consistent sizing across ALL viewports */
#interactiveMapContainer {
    box-sizing: border-box !important;
    position: relative !important;
    width: 100% !important;
    max-width: 900px !important;
    margin: 0 auto !important;
    aspect-ratio: 736 / 575 !important;
    overflow: hidden !important;
    border: 2px solid rgba(59, 130, 246, 0.3) !important;
    border-radius: 0.5rem !important;
}

/* Fallback for browsers that don't support aspect-ratio */
@supports not (aspect-ratio: 736 / 575) {
    #interactiveMapContainer {
        height: 0 !important;
        padding-bottom: calc(100% * 575 / 736) !important;
    }
}

/* Map image fills container without distortion */
#worldMapImage {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
}

/* Ensure wrapper fills parent */
#mapImageWrapper {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* Marker layer sits on top */
#mapMarkersLayer {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: 10 !important;
}

@media (max-width: 768px) {
    /* ===== HEADER COMPACT ===== */
    header {
        padding: 0 !important;
        min-height: 48px;
    }

    header .container {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }

    header h1 {
        font-size: 0.95rem !important;
    }

    header .w-10.h-10 {
        width: 1.6rem !important;
        height: 1.6rem !important;
    }

    header .w-10.h-10 i {
        font-size: 0.7rem !important;
    }

    /* ===== MAIN CONTENT SPACING ===== */
    main {
        padding: 0.5rem 0 !important;
    }

    section.text-center {
        padding: 0.75rem 0 !important;
        margin-bottom: 1rem !important;
    }

    section.text-center h2 {
        font-size: 1.3rem !important;
        margin-bottom: 0.25rem !important;
        line-height: 1.2 !important;
    }

    section.text-center p {
        font-size: 0.8rem !important;
        margin-bottom: 0.5rem !important;
        color: rgba(248, 250, 252, 0.6) !important;
        line-height: 1.4 !important;
    }

    /* Hide floating decorations */
    section.text-center .absolute {
        display: none !important;
    }

    /* ===== MAP SECTION MOBILE ===== */
    #interactiveMapSection {
        margin-bottom: 1rem !important;
    }

    #interactiveMapSection h3 {
        font-size: 1rem !important;
        text-align: center !important;
        margin-bottom: 0.35rem !important;
    }

    #interactiveMapSection > p {
        font-size: 0.75rem !important;
        text-align: center !important;
        margin-bottom: 0.5rem !important;
    }

        /* Map container - MOBILE FIX */
    #interactiveMapContainer {
        max-width: 100% !important;
        aspect-ratio: 736/575 !important;
        border-width: 1px !important;
        /* Ensure proper box model */
        box-sizing: border-box !important;
    }

    /* Ensure wrapper uses absolute positioning */
    #mapImageWrapper {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
    }

    /* Map zoom buttons */
    #zoomInBtn, #zoomOutBtn, #resetZoomBtn {
        width: 2rem !important;
        height: 2rem !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
        border-radius: 50% !important;
        background: rgba(30, 41, 59, 0.8) !important;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    #zoomInBtn {
        top: 0.5rem !important;
        left: 0.5rem !important;
    }

    #zoomOutBtn {
        top: 2.75rem !important;
        left: 0.5rem !important;
    }

    #resetZoomBtn {
        top: 5rem !important;
        left: 0.5rem !important;
    }

    /* Show All Locations button */
    #showAllLocationsBtn {
        width: 100% !important;
        padding: 0.55rem 1rem !important;
        font-size: 0.8rem !important;
        border-radius: 0.6rem !important;
        background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(59, 130, 246, 0.2)) !important;
        border: 1px solid rgba(16, 185, 129, 0.3) !important;
        color: #6ee7b7 !important;
    }

    #showAllLocationsBtn:active {
        transform: scale(0.97) !important;
    }

    /* Legend items */
    #interactiveMapSection .flex.items-center.gap-4 {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        margin-top: 0.5rem !important;
    }

    #interactiveMapSection .inline-flex.items-center {
        font-size: 0.65rem !important;
    }

    /* ===== SEARCH FILTER SECTION ===== */
    #searchFilterControls {
        padding: 0 0.75rem !important;
        margin-bottom: 1rem !important;
    }

    #searchFilterControls .grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    #searchFilterControls input,
    #searchFilterControls select {
        width: 100% !important;
        min-height: 44px !important;
        font-size: 16px !important;
        border-radius: 0.6rem !important;
        background: rgba(30, 30, 50, 0.7) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        color: #f8fafc !important;
        padding: 0.65rem 0.85rem !important;
    }

    #searchFilterControls button {
        width: 100% !important;
        min-height: 44px !important;
        font-size: 0.8rem !important;
        border-radius: 0.6rem !important;
    }

    /* ===== SEARCH RESULTS LIST ===== */
    #searchResultsList {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
        padding: 0 0.75rem !important;
    }

    .result-card {
        padding: 0.6rem !important;
        border-radius: 0.6rem !important;
        background: rgba(30, 30, 50, 0.7) !important;
        border: 1px solid rgba(255, 255, 255, 0.06) !important;
    }

    .result-card .result-thumbnail {
        width: 3.5rem !important;
        height: 2.5rem !important;
        border-radius: 0.4rem !important;
        margin-right: 0.5rem !important;
    }

    .result-card .font-bold.text-xl {
        font-size: 0.85rem !important;
    }

    .result-card .text-sm {
        font-size: 0.65rem !important;
    }

    .result-card .search-badge {
        font-size: 0.55rem !important;
        padding: 0.15rem 0.4rem !important;
    }

    /* ===== LOCATION DETAIL SECTION ===== */
    #locationDetailSection {
        margin: 0 0.75rem 1rem !important;
        padding: 0.75rem !important;
        border-radius: 0.75rem !important;
    }

    #locationDetailSection h3 {
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
    }

    .detail-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    .detail-card {
        padding: 0.6rem !important;
        border-radius: 0.5rem !important;
    }

    .detail-card h4 {
        font-size: 0.8rem !important;
        margin-bottom: 0.35rem !important;
    }

    .detail-card ul {
        font-size: 0.7rem !important;
    }

    .detail-card img {
        border-radius: 0.4rem !important;
    }

    /* ===== MONSTER PREVIEW CARDS ===== */
    .monster-preview-card {
        padding: 0.5rem !important;
        border-radius: 0.5rem !important;
    }

    .monster-preview-card img {
        height: 45px !important;
    }

    /* ===== CONNECTION PILLS ===== */
    .connection-pill {
        font-size: 0.7rem !important;
        padding: 0.4rem 0.75rem !important;
        border-radius: 1rem !important;
    }

    /* ===== ELEMENT BARS ===== */
    .element-bar {
        height: 6px !important;
    }

    /* ===== IMAGE VIEWER MODAL ===== */
    #imageViewerModal {
        padding: 0 !important;
    }

    #imageViewerModal > div {
        width: 100% !important;
        max-width: 100% !important;
    }

    #imageViewerModal img {
        max-width: 100vw !important;
        max-height: 85vh !important;
    }

    .zoom-controls {
        bottom: 1rem !important;
    }

    .zoom-btn {
        width: 2.5rem !important;
        height: 2.5rem !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        border-radius: 50% !important;
        padding: 0 !important;
    }

    /* ===== FILTER MODAL ===== */
    #filterModal {
        width: calc(100% - 1rem) !important;
        max-width: none !important;
        margin: 0 auto !important;
        border-radius: 1rem 1rem 0 0 !important;
        padding: 1rem !important;
    }

    #filterModal h2 {
        font-size: 1.1rem !important;
        margin-bottom: 0.75rem !important;
    }

    #filterModal .flex.gap-4.mt-6 {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    #filterModal button {
        width: 100% !important;
        min-height: 44px !important;
    }

    /* ===== FOOTER MOBILE ===== */
    footer .grid {
        display: block !important;
        text-align: center !important;
    }

    footer .grid > div {
        display: none !important;
    }

    footer .grid > div:first-child {
        display: block !important;
        text-align: center !important;
    }

    footer .grid > div:first-child .flex {
        justify-content: center !important;
    }

    footer .border-t {
        padding-top: 0.75rem !important;
    }

    footer .border-t .text-sm {
        font-size: 0.6rem !important;
    }

    /* ===== MOBILE MENU BUTTON - HIDDEN (replaced by FAB) ===== */
    #openSidebar {
        display: none !important;
    }

    /* ===== SIDEBAR MOBILE ===== */
    #mobileSidebar {
        width: 80vw !important;
        max-width: 18rem !important;
    }

    #mobileSidebar nav a {
        padding: 0.6rem 0.75rem !important;
        font-size: 0.85rem !important;
    }

    /* ===== TOAST NOTIFICATION ===== */
    .toast {
        left: 1rem !important;
        right: 1rem !important;
        text-align: center !important;
    }

    /* ===== COMPARISON MODAL ===== */
    #comparisonModal .comparison-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    #comparisonModal .comparison-card {
        padding: 0.75rem !important;
    }

    /* ===== STAR RATING ===== */
    .star {
        font-size: 1.2rem !important;
    }
}

/* ===== EXTRA SMALL SCREENS (<=420px) ===== */
@media (max-width: 420px) {
    .result-card .result-thumbnail {
        width: 3rem !important;
        height: 2rem !important;
    }

    .result-card .font-bold.text-xl {
        font-size: 0.78rem !important;
    }

    #interactiveMapContainer {
        border-width: 0 !important;
    }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-height: 500px) and (orientation: landscape) {
    #interactiveMapContainer {
        max-height: 50vh !important;
    }
}

/* ===== FAB NAVIGATION ===== */
#fabNavContainer {
    display: flex !important;
    position: fixed !important;
    bottom: calc(env(safe-area-inset-bottom, 0.5rem) + 1.5rem) !important;
    left: calc(env(safe-area-inset-left, 0.5rem) + 1.5rem) !important;
    z-index: 999 !important;
}

#fabNavBtn {
    display: flex !important;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.85rem;
    min-height: 3rem;
    border-radius: 1.5rem;
    background: rgba(16, 185, 129, 0.2) !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.25), 0 1px 3px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(16px) saturate(1.8);
    -webkit-backdrop-filter: blur(16px) saturate(1.8);
    color: #6ee7b7 !important;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

#fabNavBtn i {
    font-size: 0.8rem !important;
}

#fabNavBtn .fab-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(248, 250, 252, 0.9);
    white-space: nowrap;
}

#fabNavBtn:active {
    transform: scale(0.93) !important;
    background: rgba(16, 185, 129, 0.35) !important;
}

/* FAB Drawer */
#fabNavDrawer {
    display: none !important;
    position: fixed !important;
    bottom: calc(env(safe-area-inset-bottom, 0.5rem) + 5rem) !important;
    left: calc(env(safe-area-inset-left, 0.5rem) + 1.5rem) !important;
    z-index: 998 !important;
    background: linear-gradient(180deg, rgba(20, 20, 35, 0.98) 0%, rgba(13, 13, 20, 0.99) 100%) !important;
    border: 1px solid rgba(139, 92, 246, 0.15) !important;
    border-radius: 1rem !important;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: 0.5rem !important;
    min-width: 180px;
    transform: scale(0.75) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#fabNavDrawer.open {
    display: flex !important;
    flex-direction: column !important;
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#fabNavDrawer a {
    display: flex !important;
    align-items: center;
    gap: 0.6rem !important;
    padding: 0.65rem 0.85rem !important;
    border-radius: 0.6rem !important;
    font-size: 0.8rem !important;
    color: rgba(248, 250, 252, 0.7) !important;
    transition: background-color 0.1s ease, transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

#fabNavDrawer a:active {
    transform: scale(0.97);
    background-color: rgba(139, 92, 246, 0.1) !important;
}

#fabNavDrawer a i {
    font-size: 0.85rem !important;
    width: 1.2rem;
    text-align: center;
}

/* FAB overlay backdrop */
#fabNavOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 997;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.25s ease;
}

#fabNavOverlay.open {
    display: block;
    opacity: 1;
}