/* ── Reset & base ────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark:       #0f1117;
    --bg-panel:      #181c27;
    --bg-card:       #1e2333;
    --border:        #2a2f45;
    --accent:        #4f8ef7;
    --accent-dim:    #2a4a8a;
    --text-primary:  #e8eaf0;
    --text-secondary:#8892a8;
    --text-muted:    #4a5268;
    --panel-width:   380px;
}

html, body {
    height: 100%;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
}

/* ── App layout ──────────────────────────────── */
#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ── Left panel ──────────────────────────────── */
#left-pane {
    width: var(--panel-width);
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sidebar-header {
    padding: 24px 20px 18px;
    border-bottom: 1px solid var(--border);
}

#sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--text-primary);
}

#location-hint {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* selected location badge */
#selected-location {
    padding: 14px 20px;
    min-height: 56px;
    border-bottom: 1px solid var(--border);
}

.location-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.82rem;
    color: var(--text-primary);
}

.location-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

/* charts area */
#charts-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    padding: 40px 20px;
}

.empty-icon {
    font-size: 2.5rem;
    opacity: 0.2;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 220px;
    line-height: 1.5;
}

/* chart card placeholder (for future use) */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.chart-card h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

/* ── Right pane / map ────────────────────────── */
#right-pane {
    flex: 1;
    position: relative;
}

#map {
    position: absolute;
    inset: 0;
}

/* ── Mapbox overrides ────────────────────────── */
.mapboxgl-ctrl-attrib {
    background: rgba(15, 17, 23, 0.8) !important;
    color: var(--text-muted) !important;
}

.mapboxgl-ctrl-attrib a {
    color: var(--accent) !important;
}

.mapboxgl-ctrl-group {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
}

.mapboxgl-ctrl-group button {
    background-color: transparent !important;
}

.mapboxgl-ctrl-group button .mapboxgl-ctrl-icon {
    filter: invert(0.7);
}

.mapboxgl-ctrl-group button:hover .mapboxgl-ctrl-icon {
    filter: invert(1);
}

/* click marker */
.click-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid white;
    box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.35), 0 2px 6px rgba(0,0,0,0.5);
    cursor: pointer;
}

/* datacenter info rows */
.dc-info .dc-row {
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
}

.dc-info .dc-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.dc-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 0;
}

.dc-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.dc-value {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
}

/* datacenter marker — selected state glow */
.mapboxgl-canvas-container.mapboxgl-interactive {
    cursor: default;
}

/* ── Map overlay panels (legend, toggles) ────── */
.map-overlay {
    position: absolute;
    bottom: 36px;
    left: 12px;
    z-index: 1;
    background: rgba(15, 17, 23, 0.88);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.75rem;
    color: var(--text-primary);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    min-width: 170px;
}

.legend-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    color: var(--text-primary);
}

.legend-header input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
}

.legend-header input[type="checkbox"]:disabled {
    cursor: default;
    opacity: 0.5;
}

.legend-scale {
    list-style: none;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--text-secondary);
}

.legend-scale li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
}

.legend-scale .swatch {
    width: 14px;
    height: 10px;
    border-radius: 2px;
    opacity: 0.85;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ── Streamflow card ──────────────────────────── */
.sf-readout {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.sf-main {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 10px;
}

.sf-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.sf-unit {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sf-pct-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sf-pct-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.sf-pct-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.sf-pct-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
    min-width: 96px;
}

.sf-pct-num {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.sf-pct-small {
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-secondary);
    vertical-align: super;
    margin-left: 1px;
}

.sf-pct-cat {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

.sf-meta .dc-row {
    border-bottom: 1px solid var(--border);
    padding: 7px 0;
}

.sf-meta .dc-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.sf-meta a {
    color: var(--accent);
    text-decoration: none;
}

.sf-meta a:hover {
    text-decoration: underline;
}

.sf-note {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 10px;
    line-height: 1.4;
}

/* ── Forecast chart ───────────────────────────── */
.forecast-chart {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 4px;
}

.forecast-chart text {
    font-family: inherit;
}

/* ── Info tooltips ───────────────────────────── */
.info-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--text-muted);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
    line-height: 1;
    padding: 0;
}

.info-btn:hover,
.info-btn.active {
    border-color: var(--accent);
    color: var(--accent);
}

.info-tooltip {
    display: none;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--text-secondary);
    margin-top: 8px;
}

.info-tooltip.visible {
    display: block;
}

/* chart-card header row */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.card-header h3 {
    margin-bottom: 0;
}

/* legend header row with info btn */
.legend-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.legend-header {
    margin-right: 4px;
}

.legend-title-row .info-btn {
    width: 16px;
    height: 16px;
    font-size: 0.6rem;
}

/* info tooltip inside the map legend */
#drought-legend .info-tooltip {
    background: rgba(15, 17, 23, 0.95);
}

/* ── Scrollbar styling ───────────────────────── */
#charts-container::-webkit-scrollbar {
    width: 5px;
}
#charts-container::-webkit-scrollbar-track {
    background: transparent;
}
#charts-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
