/* flood_dashboard.css */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    overflow-x: hidden;
}

.header {
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    padding: 18px 25px;
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.header h1 {
    font-size: 1.45rem;
    color: #38bdf8;
    display: flex;
    align-items: center;
    gap: 10px;
}
.header h1::before { content: "🌊"; font-size: 1.7rem; }

.search-container {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.search-container input {
    padding: 9px 14px;
    border: 1px solid #475569;
    border-radius: 8px;
    background: #1e293b;
    color: #e2e8f0;
    font-size: 0.9rem;
    width: 160px;
    outline: none;
    transition: border-color 0.3s;
}
.search-container input:focus { border-color: #38bdf8; }
.search-container input::placeholder { color: #64748b; }

.btn {
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}
.btn-primary {
    background: #0ea5e9;
    color: white;
}
.btn-primary:hover { background: #0284c7; transform: translateY(-1px); }
.btn-secondary {
    background: #334155;
    color: #e2e8f0;
}
.btn-secondary:hover { background: #475569; }

.main-container {
    display: grid;
    grid-template-columns: 1fr 460px;
    height: calc(100vh - 75px);
}

.map-section { position: relative; }
#map {
    width: 100%;
    height: 100%;
    background: #0f172a;
}

/* Base Layer Selector */
.base-layer-selector {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.92);
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #334155;
    backdrop-filter: blur(10px);
    max-width: 200px;
}
.base-layer-selector h3 {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.layer-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.layer-btn {
    padding: 6px 10px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #94a3b8;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.3s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
}
.layer-btn.active {
    background: #0ea5e9;
    color: white;
    border-color: #0ea5e9;
}
.layer-btn:hover:not(.active) { background: #334155; color: #e2e8f0; }
.layer-icon { font-size: 0.9rem; }

/* Flood Risk Overlay Selector */
.flood-risk-selector {
    position: absolute;
    bottom: 50px;
    right: 12px;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.92);
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #334155;
    backdrop-filter: blur(10px);
    max-width: 240px;
}
.flood-risk-selector h3 {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.risk-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.risk-btn {
    padding: 6px 10px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #94a3b8;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.3s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
}
.risk-btn.active {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}
.risk-btn:hover:not(.active) { background: #334155; color: #e2e8f0; }
.risk-icon { font-size: 0.9rem; }

.risk-note {
    font-size: 0.68rem;
    color: #64748b;
    margin-top: 8px;
    line-height: 1.3;
}

/* Map overlay info */
.map-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.92);
    padding: 14px;
    border-radius: 10px;
    border: 1px solid #334155;
    max-width: 280px;
    backdrop-filter: blur(10px);
}
.map-overlay h3 {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.coord-display {
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    color: #38bdf8;
    margin-bottom: 8px;
}

/* Sidebar */
.sidebar {
    background: #1e293b;
    border-left: 1px solid #334155;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid #334155;
}
.sidebar-header h2 { font-size: 1.05rem; color: #f8fafc; margin-bottom: 4px; }
.sidebar-header p { font-size: 0.8rem; color: #94a3b8; }

.chart-container {
    padding: 18px 20px;
    flex: 1;
    min-height: 260px;
    position: relative;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 20px 16px;
}
.stat-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    transition: border-color 0.3s;
}
.stat-card .label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.stat-card .value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #e2e8f0;
}
.stat-card .unit {
    font-size: 0.75rem;
    color: #64748b;
}
.stat-card.alert { border-color: #ef4444; }
.stat-card.alert .value { color: #ef4444; }
.stat-card.warning { border-color: #f59e0b; }
.stat-card.warning .value { color: #f59e0b; }
.stat-card.safe { border-color: #22c55e; }
.stat-card.safe .value { color: #22c55e; }

/* Risk Panel */
.risk-panel {
    padding: 0 20px 16px;
    border-bottom: 1px solid #334155;
    margin-bottom: 12px;
}
.risk-panel h4 {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 10px;
}
.risk-bar-container {
    margin-bottom: 10px;
}
.risk-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #94a3b8;
    margin-bottom: 4px;
}
.risk-bar {
    height: 8px;
    border-radius: 4px;
    background: #334155;
    overflow: hidden;
    position: relative;
}
.risk-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
}
.risk-bar-fill.low { background: #22c55e; }
.risk-bar-fill.moderate { background: #eab308; }
.risk-bar-fill.high { background: linear-gradient(90deg, #f59e0b, #d97706); }
.risk-bar-fill.severe { background: linear-gradient(90deg, #ef4444, #b91c1c); }

.forecast-days {
    display: flex;
    gap: 6px;
    padding: 0 20px 12px;
}
.day-btn {
    flex: 1;
    padding: 7px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #94a3b8;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.3s;
}
.day-btn.active {
    background: #0ea5e9;
    color: white;
    border-color: #0ea5e9;
}
.day-btn:hover:not(.active) { background: #334155; color: #e2e8f0; }

.loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.92);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
    gap: 12px;
}
.loading-overlay.active { display: flex; }
.spinner {
    width: 45px; height: 45px;
    border: 3px solid #334155;
    border-top-color: #0ea5e9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: #94a3b8; font-size: 0.95rem; }

.error-message {
    background: rgba(127, 29, 29, 0.9);
    color: #fecaca;
    padding: 10px 18px;
    border-radius: 8px;
    margin: 0 20px 12px;
    font-size: 0.85rem;
    display: none;
    border: 1px solid #7f1d1d;
}
.error-message.active { display: block; }

.sample-locations {
    padding: 0 20px 18px;
}
.sample-locations h4 {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 8px;
}
.location-chip {
    display: inline-block;
    padding: 5px 11px;
    margin: 3px;
    background: #334155;
    border-radius: 16px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid transparent;
    color: #e2e8f0;
}
.location-chip:hover {
    background: #0ea5e9;
    color: white;
    border-color: #0ea5e9;
}

.api-status {
    padding: 0 20px 12px;
    font-size: 0.75rem;
    color: #64748b;
}
.api-status span { color: #22c55e; }
.api-status.error span { color: #ef4444; }

.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}
.no-data-icon { font-size: 2.5rem; margin-bottom: 10px; }

.custom-marker div {
    background: #0ea5e9;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 12px rgba(14,165,233,0.6);
}

@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: 45vh 1fr;
    }
    .sidebar { border-left: none; border-top: 1px solid #334155; }
    .base-layer-selector { top: auto; bottom: 12px; right: 12px; }
    .flood-risk-selector { bottom: 12px; left: 12px; right: auto; }
}