/* frontend/static/css/explorer.css */

/* --- Container & Layout --- */
.explorer-main-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--background-color-app, #121218);
}

/* Ensure main content fills the flex body on explorer page */
body.page-explorer {
    height: 100dvh !important;
    overflow: hidden !important;
}

body.page-explorer #main-content,
body.page-explorer .explorer-main-wrapper,
body.page-explorer .explorer-content-card,
body.page-explorer .map-container-wrapper,
body.page-explorer .map-bs-container {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
    height: auto !important;
    /* Allow flex to control height */
}

/* Hide global footer on explorer page to maximize map space */
body.page-explorer .main-footer,
body.page-explorer footer {
    display: none !important;
}

/* Force contained width on desktop, full-width on mobile */
body.page-explorer .map-bs-container {
    max-width: 1320px !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 15px !important;
    overflow: hidden;
}

@media (max-width: 991.98px) {
    body.page-explorer .map-bs-container {
        max-width: 100% !important;
        padding: 0 !important;
    }
}

#map {
    flex: 1 !important;
    height: 100% !important;
    width: 100% !important;
    border-radius: 16px;
    /* Rounded corners on desktop */
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    background: #0d0d1a !important;
}

@media (max-width: 991.98px) {
    #map {
        border-radius: 0 !important;
        border: none !important;
    }
}

.map-container-wrapper {
    flex: 1;
    position: relative;
    padding-bottom: 0;
    padding-top: 0;
}

/* --- Header Polish --- */
.explorer-main-wrapper .page-header {
    padding: 10px 0 5px;
    text-align: center;
}

.explorer-main-wrapper .page-header h1 {
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 900;
    letter-spacing: -1.5px;
    color: #fff;
    margin: 0;
    line-height: 1;
    text-transform: uppercase;
}

.explorer-main-wrapper .page-header h1 span {
    color: var(--apple-green, #34c759);
    text-shadow: 0 0 30px rgba(52, 199, 89, 0.4);
}

.explorer-main-wrapper .page-header p {
    font-size: 0.9rem;
    margin-top: 2px;
    margin-bottom: 5px;
    font-weight: 500;
    letter-spacing: -0.2px;
    opacity: 0.6;
    color: var(--color-text-secondary, rgba(255, 255, 255, 0.6));
}

/* --- Command Console (Search & Filters) --- */
.explorer-controls {
    background: transparent;
    width: 100%;
    padding: 0 15px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
}

.command-console {
    width: 100%;
    max-width: 850px;
    display: flex;
    align-items: center;
    background: rgba(20, 20, 25, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 6px;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.search-zone {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.search-zone i {
    color: var(--apple-green, #34c759);
    font-size: 1rem;
}

#location-search-input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-weight: 500;
    outline: none;
}

.radius-zone {
    padding: 0 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 180px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.radius-zone i {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
}

#radius-slider {
    flex: 1;
    cursor: pointer;
    accent-color: var(--apple-green, #34c759);
    height: 4px;
}

#radius-value {
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    width: 35px;
    text-align: right;
}

.console-btn {
    border-radius: 12px;
    height: 40px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #fff;
    transition: all 0.2s ease;
}

.console-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    transform: translateY(-1px);
}

/* --- Filter Ribbon --- */
.filter-ribbon {
    width: 100%;
    max-width: 850px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0;
    scrollbar-width: none;
    display: flex;
    justify-content: center;
}

.filter-ribbon::-webkit-scrollbar {
    display: none;
}

.filter-pills {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.filter-pill {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.5) !important;
    padding: 6px 14px !important;
    border-radius: 20px !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    text-decoration: none;
    cursor: pointer;
}

.filter-pill.active {
    background: var(--apple-green, #34c759) !important;
    border-color: var(--apple-green, #34c759) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.3) !important;
    transform: scale(1.05);
}

.filter-pill:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

.filter-separator {
    width: 1px;
    height: 14px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
}

/* --- Autocomplete --- */
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 15px;
    right: 15px;
    z-index: 1000;
    background: rgba(30, 30, 45, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-top: 5px;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
}

.autocomplete-item {
    padding: 12px 16px;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
}

.autocomplete-item:hover {
    background: rgba(52, 199, 89, 0.1);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

/* --- Map Area --- */
#map {
    height: 100%;
    width: 100%;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    background: #0d0d1a !important;
    /* Placeholder during load */
}

/* Map Floating Controls */
.map-floating-actions {
    position: absolute;
    right: 20px;
    top: 20px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fab-mini {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(36, 36, 53, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    cursor: pointer;
}

.fab-mini:hover {
    background: var(--apple-green, #34c759);
    border-color: var(--apple-green, #34c759);
    transform: scale(1.05);
}

/* Main Action FAB */
.main-action-fab {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 450;
    width: max-content;
}

.fab-primary {
    height: 52px;
    padding: 0 24px;
    border-radius: 26px;
    background: linear-gradient(135deg, var(--apple-green, #34c759) 0%, #299e47 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 8px 25px rgba(52, 199, 89, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab-primary:hover {
    transform: translateX(-50%) translateY(-2px) scale(1.02);
    box-shadow: 0 10px 30px rgba(52, 199, 89, 0.5);
    color: white;
}

/* Loading Indicator */
.map-loading-overlay {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
}

.map-loading-content {
    background: rgba(36, 36, 53, 0.95);
    border: 1px solid rgba(52, 199, 89, 0.2);
    padding: 10px 24px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: slideDownFade 0.4s ease-out;
}

.map-loading-content p {
    margin: 0;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

/* --- Bottom Sheet --- */
.map-bottom-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 1001;
    /* Above map and FABs */
    background: linear-gradient(180deg, rgba(30, 35, 45, 0.98) 0%, rgba(18, 18, 24, 0.99) 100%);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 -15px 50px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    padding: 0 20px 30px;
}

.map-bottom-sheet.active {
    transform: translateY(0);
    min-height: 280px;
}

.sheet-handle-bar {
    padding: 15px 0 10px;
    display: flex;
    justify-content: center;
}

.sheet-handle {
    width: 40px;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.sheet-content {
    animation: slideUpContent 0.6s ease-out;
}

/* --- Animations --- */
@keyframes slideDownFade {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideUpContent {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Mobile Specific Overrides --- */
@media (max-width: 768px) {
    .explorer-main-wrapper .page-header {
        padding: 5px 0;
    }

    .explorer-controls {
        padding: 0 10px 5px;
        gap: 5px;
    }

    .command-console {
        padding: 4px;
        border-radius: 14px;
    }

    .search-zone {
        padding: 0 8px;
    }

    #location-search-input {
        padding: 8px 10px;
        font-size: 0.9rem;
    }

    .radius-zone {
        display: none !important;
        /* Managed via drawer/settings on mobile if needed */
    }

    .filter-pills {
        padding: 4px 8px;
        gap: 6px;
    }

    .filter-pill {
        padding: 5px 12px !important;
        font-size: 0.75rem !important;
    }

    #map {
        border-radius: 0;
        /* Full Bleed */
    }

    .map-bs-container {
        padding: 0 !important;
        max-width: 100% !important;
    }

    .main-action-fab {
        bottom: calc(65px + env(safe-area-inset-bottom) + 15px) !important;
    }

    .map-bottom-sheet {
        padding-bottom: calc(30px + 65px + env(safe-area-inset-bottom)) !important;
    }

    .fab-primary {
        height: 56px;
        width: 56px;
        padding: 0;
        border-radius: 50%;
    }

    .fab-primary .fab-text {
        display: none;
    }

    .fab-primary i {
        font-size: 1.4rem;
        margin: 0;
    }
}

/* Mesh Gradient Effects */
.mesh-gradient {
    position: fixed;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.3;
}

.mesh-1 {
    background: radial-gradient(at 0% 0%, rgba(52, 199, 89, 0.15) 0, transparent 50%);
}

.mesh-2 {
    background: radial-gradient(at 100% 100%, rgba(0, 122, 255, 0.1) 0, transparent 50%);
}