/* ==========================================================================
   EASUP_FLOOD_2D.CSS — High-Contrast Topographic WebGIS Simulation Dashboard
   Hệ thống mô phỏng ngập lụt 2D hạ du liên hồ Ea Súp (V1.17 Standalone Pro)
   Thiết kế tương phản cao trên nền Bản đồ Địa hình / Giao thông, không lag giật
   ========================================================================== */

:root {
  --ef-bg: #090e1a;
  --ef-card-bg: rgba(13, 22, 44, 0.94);
  --ef-card-border: rgba(56, 189, 248, 0.25);
  --ef-accent-blue: #0284c7;
  --ef-accent-cyan: #06b6d4;
  --ef-accent-green: #10b981;
  --ef-accent-amber: #f59e0b;
  --ef-accent-red: #ef4444;
  --ef-text-main: #f8fafc;
  --ef-text-muted: #94a3b8;
  --ef-hud-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

body, html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ef-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ef-text-main);
}

#flood2d {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

#efMap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #e2e8f0;
}

/* ==========================================================================
   TOP MODE BAR — Thanh điều hướng đỉnh cao
   ========================================================================== */
.ef-top-mode-bar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 440px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  gap: 12px;
}

.ef-top-mode-bar * {
  pointer-events: auto;
}

.ef-top-left-modes, .ef-top-right-modes {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.90);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 3px;
  backdrop-filter: blur(14px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}

.ef-mode-btn, .ef-sim-mode-btn {
  border: none;
  background: transparent;
  color: var(--ef-text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ef-mode-btn:hover, .ef-sim-mode-btn:hover {
  color: #fff;
}

.ef-mode-btn.active {
  background: #0284c7;
  color: #fff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.45);
}

.ef-sim-mode-btn.active {
  background: #dc2626;
  color: #fff;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.5);
}

/* ==========================================================================
   HUD SIDEBAR — Bảng điều khiển tác nghiệp bên phải
   ========================================================================== */
.ef-hud-sidebar {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 420px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 145px);
  z-index: 1000;
  background: var(--ef-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--ef-card-border);
  border-radius: 16px;
  box-shadow: var(--ef-hud-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ef-hud-header {
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--ef-card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ef-hud-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ef-hud-title h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.25;
}

.ef-hud-title span {
  display: block;
  font-size: 0.72rem;
  color: var(--ef-accent-cyan);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.ef-badge-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.70rem;
  font-weight: 800;
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.ef-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: efPulse 1.8s infinite;
}

@keyframes efPulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.ef-hud-tabs {
  display: flex;
  padding: 6px 12px;
  gap: 6px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--ef-card-border);
}

.ef-hud-tab-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ef-text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.ef-hud-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.ef-hud-tab-btn.active {
  color: #fff;
  background: rgba(6, 182, 212, 0.25);
  border: 1px solid rgba(6, 182, 212, 0.45);
}

.ef-hud-body {
  padding: 12px 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ef-hud-body::-webkit-scrollbar {
  width: 5px;
}
.ef-hud-body::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
}
.ef-hud-body::-webkit-scrollbar-thumb {
  background: rgba(6, 182, 212, 0.35);
  border-radius: 4px;
}

/* ==========================================================================
   BANNER CẢNH BÁO KHẨN CẤP
   ========================================================================== */
.ef-alert-card {
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(239, 68, 68, 0.65);
  background: linear-gradient(135deg, rgba(185, 28, 28, 0.55) 0%, rgba(127, 29, 29, 0.75) 100%);
  box-shadow: 0 4px 18px rgba(239, 68, 68, 0.3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ef-alert-badge-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ef-alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #fee2e2;
}

.ef-alert-pulse-circle {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f87171;
  box-shadow: 0 0 10px #f87171;
  animation: efPulse 1.2s infinite;
}

.ef-alert-main-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
}

.ef-alert-subinfo {
  font-size: 0.74rem;
  color: #fca5a5;
  display: flex;
  gap: 10px;
  font-weight: 600;
}

.ef-alert-evac {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.2);
  font-size: 0.72rem;
  color: #fef08a;
  line-height: 1.35;
  font-weight: 600;
}

/* ==========================================================================
   SECTION CARDS
   ========================================================================== */
.ef-section-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--ef-card-border);
  border-radius: 12px;
  padding: 10px 12px;
}

.ef-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--ef-accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 4px;
}

.ef-section-head-sub {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ef-text-muted);
  text-transform: none;
}

.ef-station-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
  font-size: 0.80rem;
}

.ef-station-row:last-child {
  border-bottom: none;
}

.ef-station-name {
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.ef-station-name small {
  font-size: 0.70rem;
  color: #94a3b8;
  font-weight: 400;
}

.ef-station-val {
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
}

.ef-station-tag {
  font-size: 0.66rem;
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 800;
  text-transform: uppercase;
}

.ef-tag-safe { background: rgba(16, 185, 129, 0.25); color: #34d399; }
.ef-tag-warn { background: rgba(245, 158, 11, 0.25); color: #fbbf24; }
.ef-tag-danger { background: rgba(239, 68, 68, 0.32); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.5); }

/* Grid 4 chỉ số thiệt hại ngập lụt */
.ef-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}

.ef-metric-tile {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 8px 10px;
}

.ef-metric-tile-label {
  font-size: 0.66rem;
  color: var(--ef-text-muted);
  text-transform: uppercase;
  font-weight: 700;
}

.ef-metric-tile-val {
  font-size: 1.25rem;
  font-weight: 900;
  color: #fff;
  margin-top: 2px;
  line-height: 1.15;
}

.ef-metric-tile-sub {
  font-size: 0.68rem;
  color: var(--ef-accent-cyan);
  margin-top: 2px;
  font-weight: 600;
}

/* 4 thẻ phân cấp độ sâu */
.ef-depth-chip-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.ef-depth-chip {
  background: rgba(15, 23, 42, 0.90);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px 6px;
  text-align: center;
}

.ef-depth-chip-num {
  font-size: 0.76rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

.ef-depth-chip-lbl {
  font-size: 0.62rem;
  color: #94a3b8;
  font-weight: 600;
  margin-top: 1px;
}

/* ==========================================================================
   VẬN HÀNH HỒ — NHẬP XẢ TRỰC TIẾP
   ========================================================================== */
.ef-reservoir-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  padding: 8px 10px;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ef-res-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
}

.ef-res-name {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #fff;
}

.ef-res-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
}

.ef-res-stage {
  color: var(--ef-accent-cyan);
  font-size: 0.74rem;
  font-weight: 700;
}

.ef-res-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ef-res-input-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
}

.ef-res-input {
  width: 90px;
  padding: 4px 8px;
  background: #1e293b;
  border: 1px solid rgba(6, 182, 212, 0.45);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  border-radius: 6px;
  outline: none;
  text-align: right;
  transition: all 0.2s ease;
}

.ef-res-input:focus {
  border-color: #06b6d4;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.45);
}

.ef-res-unit {
  font-size: 0.70rem;
  color: #94a3b8;
  font-weight: 600;
}

.ef-action-btn-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.ef-btn-sim-run {
  flex: 1.2;
  padding: 8px 10px;
  background: linear-gradient(135deg, #059669 0%, #0284c7 100%);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 800;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(5, 150, 105, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.ef-btn-sim-run:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.ef-btn-sync {
  flex: 1;
  padding: 8px 10px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.ef-scenario-selector-wrap {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.ef-scenario-select {
  width: 100%;
  padding: 6px 10px;
  background: #1e293b;
  border: 1px solid rgba(6, 182, 212, 0.35);
  border-radius: 7px;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

/* ==========================================================================
   TIMELINE PLAYER Ở ĐÁY MÀN HÌNH
   ========================================================================== */
.ef-timeline-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(94vw, 980px);
  z-index: 1000;
  background: rgba(10, 18, 38, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--ef-card-border);
  border-radius: 14px;
  padding: 8px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ef-timeline-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ef-timeline-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ef-timeline-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ef-timeline-clock {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ef-accent-cyan);
  background: rgba(6, 182, 212, 0.18);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(6, 182, 212, 0.35);
}

.ef-timeline-stat-summary {
  font-size: 0.74rem;
  color: #cbd5e1;
  font-weight: 600;
  display: flex;
  gap: 12px;
}

.ef-timeline-stat-summary span strong {
  color: #38bdf8;
}

.ef-timeline-controls-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ef-btn-player {
  background: #0284c7;
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ef-btn-player:hover {
  background: #0369a1;
}

.ef-timeline-slider {
  width: 100%;
  accent-color: #06b6d4;
  height: 5px;
  cursor: pointer;
  margin: 2px 0;
}

.ef-timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--ef-text-muted);
  font-weight: 600;
}

/* ==========================================================================
   LEGEND & POI MARKERS
   ========================================================================== */
.ef-map-legend {
  position: absolute;
  bottom: 85px;
  left: 20px;
  z-index: 1000;
  background: rgba(10, 18, 38, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid var(--ef-card-border);
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.ef-legend-title {
  font-size: 0.72rem;
  font-weight: 800;
  margin-bottom: 5px;
  color: #e2e8f0;
}

.ef-legend-bar {
  width: 170px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #0ea5e9, #0284c7, #1e40af, #111827, #7c3aed);
}

.ef-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: #94a3b8;
  margin-top: 3px;
  font-weight: 600;
}

/* Pulse Radar Pin */
.ef-pulse-pin {
  position: relative;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ef-pulse-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid #ef4444;
  animation: efRadarPulse 1.8s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

.ef-pulse-core {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
  box-shadow: 0 0 10px #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #fff;
}

@keyframes efRadarPulse {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.ef-pin-amber .ef-pulse-ring { border-color: #f59e0b; }
.ef-pin-amber .ef-pulse-core { background: #f59e0b; box-shadow: 0 0 10px #f59e0b; }

.ef-pin-blue .ef-pulse-ring { border-color: #06b6d4; }
.ef-pin-blue .ef-pulse-core { background: #0284c7; box-shadow: 0 0 10px #06b6d4; }

.ef-poi-label {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 18, 38, 0.94);
  color: #fff;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

/* Leaflet Dark Popup */
.leaflet-popup-content-wrapper {
  background: rgba(10, 18, 38, 0.96) !important;
  color: #f8fafc !important;
  border: 1px solid rgba(6, 182, 212, 0.4) !important;
  border-radius: 14px !important;
  backdrop-filter: blur(16px) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7) !important;
  padding: 2px !important;
}

.leaflet-popup-tip {
  background: rgba(10, 18, 38, 0.96) !important;
  border: 1px solid rgba(6, 182, 212, 0.4) !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  line-height: 1.4 !important;
}

.ef-popup-card h4 {
  margin: 0 0 8px 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #38bdf8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 5px;
}

.ef-popup-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.ef-popup-label { color: #94a3b8; font-weight: 600; }
.ef-popup-val { font-weight: 700; color: #fff; }

@media (max-width: 900px) {
  .ef-top-mode-bar {
    right: 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .ef-hud-sidebar {
    top: 90px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: 46%;
  }
  .ef-timeline-bar {
    width: calc(100vw - 20px);
    bottom: 8px;
  }
  .ef-map-legend {
    display: none;
  }
}
