/* --- SWISS DESIGN SYSTEM --- */
:root {
    /* Risk gradient anchors (RISK_SCORE 4.5 → 10) */
    --color-tier3:  #FEB24C;   /* Elevated  – score ~4.5–6 */
    --color-tier4:  #E31A1C;   /* High      – score ~6–8.5 */
    --color-tier5:  #67000D;   /* Extreme   – score 8.5–10 */
    --color-floodway: #003580; /* Floodway corridor outline */

    /* UI Colors */
    --swiss-black: #1c1c1e;
    --swiss-white: #ffffff;
    --swiss-grey:  #e5e5ea;

    --ui-shadow: 0 12px 40px rgba(0,0,0,0.12);
    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: var(--font-stack);
    color: var(--swiss-black);
    overflow: hidden;
    background-color: #f2f2f7;
}

/* --- MAP CONTAINER --- */
#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

/* --- FLOATING UI PANEL --- */
.ui-panel {
    position: absolute;
    top: 24px;
    left: 24px;
    width: 340px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(15px);
    padding: 32px;
    z-index: 10;
    box-shadow: var(--ui-shadow);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

p.subtitle {
    font-size: 13px;
    line-height: 1.4;
    color: #666;
    margin: 4px 0 0 0;
    font-weight: 400;
}

/* --- SEARCH BAR --- */
.search-container { width: 100%; }

.search-box {
    display: flex;
    align-items: center;
    border: 1px solid var(--swiss-grey);
    border-radius: 10px;
    padding: 4px 8px;
    transition: border-color 0.5s;
    background: white;
}

.search-box:focus-within {
    border-color: var(--swiss-black);
}

#search-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: var(--font-stack);
    font-size: 14px;
    padding: 8px 4px;
    color: var(--swiss-black);
    background: transparent;
}

#search-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--swiss-black);
    display: flex;
    align-items: center;
    justify-content: center;
}

#search-status {
    font-size: 11px;
    margin-top: 8px;
    color: #666;
    font-weight: 500;
    min-height: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- COLLAPSIBLE SECTION --- */
.ui-details {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.4s ease;
    max-height: 500px;
    opacity: 1;
}

/* State: Collapsed */
.ui-panel.is-collapsed .ui-details {
    max-height: 0;
    opacity: 0;
    margin: 0;
}

/* --- TOGGLE BUTTON --- */
.ui-toggle-btn {
    display: none;
    width: 100%;
    padding: 12px 0 0 0;
    border: none;
    background: transparent;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    border-top: 1px solid var(--swiss-grey);
    margin-top: -10px;
}

.toggle-icon {
    width: 24px;
    height: 24px;
    color: #454444;
    transition: transform 0.3s ease;
}

.ui-panel.is-collapsed .toggle-icon {
    transform: rotate(180deg);
}

/* --- TOGGLES --- */
.toggle-group {
    display: flex;
    background: #f2f2f7;
    padding: 4px;
    border-radius: 6px;
}

.toggle-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    font-family: var(--font-stack);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toggle-btn.active {
    background: var(--swiss-white);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* --- LEGEND --- */
.legend-title {
    font-size: 11px;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.legend-gradient-bar {
    height: 12px;
    border-radius: 6px;
    margin-bottom: 4px;
}

.legend-gradient-risk {
    background: linear-gradient(to right, #FEB24C, #FD8D3C, #FC4E2A, #E31A1C, #BD0026, #67000D);
}

.legend-gradient-bfe {
    background: linear-gradient(to right, #7f0000, #d73027, #f46d43, #fdae61, #74add1, #313695, #1a1a2e);
}

.legend-gradient-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #888;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 500;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 10px;
    flex-shrink: 0;
}

/* --- POPUP --- */
.maplibregl-popup-content {
    padding: 16px;
    font-family: var(--font-stack);
    box-shadow: var(--ui-shadow);
    border-radius: 4px;
    max-width: 260px;
    border: 1px solid #eee;
}

.popup-zone { font-size: 16px; font-weight: 700; display: block; margin-bottom: 4px; }
.popup-desc { font-size: 12px; color: #666; line-height: 1.4; }

/* --- LOADING SCREEN --- */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--swiss-grey);
    border-top: 4px solid var(--color-tier4);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loader-text { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.fade-out { opacity: 0; pointer-events: none; }

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 600px) {
    .ui-panel {
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        border-radius: 12px 12px 0 0;
        box-sizing: border-box;
        padding: 20px 20px 10px 20px;
        gap: 16px;
    }

    .ui-toggle-btn {
        display: flex;
    }

    h1 { font-size: 16px; }

    .ui-panel.is-collapsed .subtitle {
        display: none;
    }
}
