/* Core Layout */
body { 
    margin: 0; 
    background: #000; 
    font-family: 'Inter', -apple-system, sans-serif; 
    color: white; 
    overflow: hidden; 
}

#map { 
    position: absolute; 
    top: 0; 
    bottom: 0; 
    width: 100%; 
}

/* Glassmorphic Activity Box (Left Panel) */
.glass-panel {
    position: absolute;
    top: 25px;
    left: 25px;
    width: 380px;
    min-height: 320px;
    background: rgba(15, 15, 15, 0.75);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 24px;
    z-index: 10;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

/* Search & Autocomplete Engine */
.search-container {
    position: relative;
    margin-bottom: 20px;
}

#city-search {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

#city-search:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: #00ff88;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-top: 8px;
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
    display: none;
}

.result-item {
    padding: 12px 16px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.result-item:hover {
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
}

/* Header & Live Status */
.live-tag {
    background: #00ff88;
    color: black;
    font-size: 10px;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 6px;
    float: right;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#location-name { 
    font-size: 24px;
    margin: 0; 
    font-weight: 600; 
    color: #fff; 
    letter-spacing: -0.5px;
}

/* Temperature Section */
.temp-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 15px 0 5px 0;
}

.temp-display { 
    font-size: 72px;
    font-weight: 200; 
    letter-spacing: -4px;
}

.temp-meta {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.condition { 
    font-size: 18px;
    font-weight: 500; 
    color: #00ff88;
    line-height: 1.2;
}

#feels-like { 
    font-size: 13px; 
    opacity: 0.5; 
    margin-top: 2px;
}

/* Radar Engine / Dropdown Controls */
.glass-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300ff88' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

.glass-select option {
    background: #151515;
    color: white;
}

/* Observations Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 20px 0;
    padding: 18px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item, .detail-item {
    display: flex;
    flex-direction: column;
}

.stat-item label, .detail-item label, .card-title {
    font-size: 11px;
    font-weight: 800;
    opacity: 0.6;
    letter-spacing: 1px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.stat-item span, .detail-item span {
    font-size: 20px;
    font-weight: 600;
    color: #eee;
}

/* Advanced Details (Sky & Rain) */
.advanced-details {
    margin-bottom: 20px;
    padding-bottom: 5px;
}

.detail-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Updated Dashboard Button to ensure it stays on top */
.dashboard-btn {
    position: fixed; 
    top: 40px;
    right: 20px; 
    background: rgba(15, 15, 15, 0.8);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px 20px;
    border-radius: 14px;
    cursor: pointer;
    z-index: 1000; 
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.dashboard-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #00ff88;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.2);
}

/* Side Panel Layout */
.side-panel.active { 
    right: 0 !important; 
}

.side-panel {
    position: fixed; 
    top: 0;
    right: -420px;
    width: 420px;
    height: 100vh;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(30px);
    z-index: 9999; 
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

#close-panel {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.5;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Panel Card Styling */
.panel-card {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-box {
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
    padding: 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
}

/* AFD Discussion Styles */
.afd-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.afd-preview {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #aaa;
    background: rgba(0, 0, 0, 0.4);
    padding: 14px;
    border-radius: 12px;
    height: 160px;
    overflow: hidden;
    margin: 12px 0;
}

.full-btn {
    width: 100%;
    background: #3b82f6;
    border: none;
    color: white;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.full-btn:hover { background: #2563eb; }

/* Modal Overlay & Content Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.modal-content {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(15, 15, 15, 0.9);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.close-modal-btn {
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
}

#afd-modal-body {
    flex: 1;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #ccc;
    white-space: pre-wrap;
    padding: 20px;
}

/* Animations */
@keyframes pulse-gps {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(4); opacity: 0; }
}

@keyframes danger-pulse {
    0% { 
        opacity: 1; 
        text-shadow: 0 0 5px currentColor; 
        transform: scale(1);
    }
    100% { 
        opacity: 0.6; 
        text-shadow: 0 0 15px currentColor, 0 0 25px currentColor;
        transform: scale(1.03);
    }
}

.pulse-animation {
    animation: danger-pulse 1.0s infinite alternate ease-in-out;
}

/* GPS Pulse Animation */
.maplibregl-user-location-dot {
    background-color: #00ff88 !important;
    width: 15px !important;
    height: 15px !important;
}

.maplibregl-user-location-dot::before {
    background-color: rgba(0, 255, 136, 0.3) !important;
    content: "";
    width: 15px;
    height: 15px;
    border-radius: 50%;
    position: absolute;
    animation: pulse-gps 2s infinite;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }

/* Horizontal Hourly Scroll */
.hourly-container {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.hourly-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.hourly-icon { 
    width: 36px;
    height: 36px; 
    margin: 8px 0; 
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

.hour { font-size: 11px; opacity: 0.6; }
.hour-temp { font-weight: 700; font-size: 16px; }

/* Vertical Daily List */
.daily-row {
    display: grid;
    grid-template-columns: 110px 1fr 60px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 15px;
}

.daily-row img {
    width: 32px;
    height: 32px;
    margin-right: 8px;
}

.day-name { font-weight: 600; }
.day-condition { opacity: 0.8; font-size: 12px; }
.day-high { text-align: right; font-weight: 700; color: #00ff88; }

/* METAR micro-stats */
.stat-mini {
    display: flex;
    flex-direction: column;
}

.stat-mini label {
    font-size: 9px;
    font-weight: 800;
    color: #00ff88; 
    opacity: 0.8;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.stat-mini span {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

/* Saved Locations */
.saved-item {
    background: rgba(255, 255, 255, 0.08);
    padding: 4px 8px; 
    border-radius: 12px;
    font-size: 8px; 
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px; 
}

.saved-item:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.delete-saved {
    margin-left: 8px;
    opacity: 0.4;
    font-size: 14px;
}

.delete-saved:hover {
    opacity: 1;
    color: #ff4444;
}

/* Side-by-Side Popup Styles */
.popup-container-flex {
    display: flex;
    gap: 15px;
    max-width: 800px;
    overflow-x: auto;
    padding: 10px;
}

.popup-card {
    min-width: 280px;
    max-width: 320px;
    background: rgb(48, 48, 48);
    padding: 15px;
    border-radius: 8px;
    color: #a0a0a0 !important;
}

.popup-event {
    font-weight: 900;
    font-size: 14px;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.popup-headline {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
    opacity: 0.9;
    color: #ffffff !important;
}

.popup-scroll-area {
    font-size: 11px;
    max-height: 200px;
    overflow-y: auto; 
    line-height: 1.5;
    padding: 8px;
    background: #888888; 
    border-radius: 6px;
    color: #d3d3d3 !important;
}

/* Toggle Styling */
.layer-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    padding: 6px 0;
    transition: all 0.2s ease;
}

.layer-toggle:hover { color: #fff; }

.layer-toggle input[type="checkbox"] {
    cursor: pointer;
    accent-color: #00ff88; 
    width: 15px;
    height: 15px;
}

.toggle-text {
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 500;
}

/* --- MAP POPUP OVERRIDES --- */
.maplibregl-popup-content {
    background: #4d4d4d !important;
    color: #1a1a1a !important;
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.maplibregl-popup-close-button {
    color: #8b8b8b;
    font-size: 20px;
    padding: 5px 10px;
}

.maplibregl-popup-tip {
    border-top-color: #4d4d4d !important;
    border-bottom-color: #4d4d4d !important;
}

/* --- Timeline Player Styles --- */
.timeline-container {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-width: 90vw;
    background: rgba(15, 15, 15, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 10px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 900;
}

#play-pause-btn {
    background: rgba(0, 217, 255, 0.2);
    border: 1px solid rgba(0, 217, 255, 0.4);
    color: #00d9ff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#play-pause-btn:hover {
    background: rgba(0, 217, 255, 0.4);
    transform: scale(1.1);
}

#time-display-label {
    min-width: 50px;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    color: #00ff88;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
    font-size: 14px;
}

/* Custom Glassy Slider */
#time-slider {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    height: 4px;
    border-radius: 2px;
    outline: none;
}

#time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #ffffff;
    border: 2px solid #00d9ff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.8);
    transition: transform 0.2s;
}

#time-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

/* --- UPDATED MOBILE & INTERFACE LOGIC --- */

/* Mobile Specific Styles */
@media (max-width: 768px) {
    .glass-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 85%; 
        max-width: 340px; /* Prevents it from feeling too wide on tablets */
        height: 100dvh; /* Uses dynamic viewport height for mobile browsers */
        z-index: 2000;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
        transform: translateX(-105%); /* Ensure it is fully off-screen */
        overflow-y: auto;
        border-radius: 0 24px 24px 0; /* Rounded only on the inner edge */
        pointer-events: none; /* Ignore clicks when closed */
        opacity: 0;
    }

    /* Active State: When menu is toggled open */
    .glass-panel.mobile-active {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.9);
    }

    #map {
        position: absolute;
        inset: 0;
        z-index: 1;
    }

    .mobile-menu-trigger {
        position: fixed;
        bottom: 25px;
        right: 20px;
        width: 56px;
        height: 56px;
        background: rgba(0, 255, 136, 0.9); /* Themed to match your green status */
        border-radius: 50%;
        z-index: 2100;
        display: flex;
        justify-content: center;
        align-items: center;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
        color: #000;
        font-size: 24px;
        border: none;
        cursor: pointer;
        transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .mobile-menu-trigger:active {
        transform: scale(0.9);
    }

    .timeline-container {
        width: 88%;
        bottom: 100px; /* Lifted higher to avoid clashing with the trigger button */
        padding: 10px 15px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Desktop Trigger Hidden */
@media (min-width: 769px) {
    .mobile-menu-trigger { display: none; }
    
    .glass-panel {
        transform: translateX(0); /* Always visible on desktop */
        opacity: 1;
        pointer-events: auto;
    }
}

/* --- Alignment & Station Engine Utility --- */

.align-dot {
    width: 16px;
    height: 16px;
    background: #ff3300;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 0 10px rgba(255, 51, 0, 0.6);
    z-index: 9999; /* Keeps it above the map tiles */
    transition: background 0.2s, transform 0.2s, border-color 0.2s;
}

.align-dot:hover {
    background: #00ff88;
    border-color: #000;
    transform: scale(1.3);
}

.align-dot:active {
    cursor: grabbing;
    transform: scale(1.1);
}

/* State Management for NEXLAB/HRRR Layers */
/* Ensure your JS adds/removes these classes to the layer containers */
.layer-off {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Subtle overlay to dim map when mobile panel is open */
.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1999;
    display: none;
}

.mobile-overlay.active {
    display: block;
}