/* ═══════════════════════════════════════════════════════════════
   上帝之眼监控系统 — Design System
   基于 OSIRIS: Egyptian Mythology × Dark Ops × Glassmorphism
   ═══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* ── Core Palette ── */
  --bg-void: #04040A;
  --bg-primary: #06060C;
  --bg-secondary: #0C0E1A;
  --bg-tertiary: #121628;
  --bg-panel: rgba(8, 10, 20, 0.88);
  --bg-panel-solid: #0C0E1A;

  /* ── Gold Accent (Eye of Horus) ── */
  --gold-rgb: 212, 175, 55;
  --gold-primary: #D4AF37;
  --gold-light: #F0D060;
  --gold-dim: #8B7325;
  --gold-glow: rgba(212, 175, 55, 0.3);

  /* ── Cyan Intel Stream ── */
  --cyan-rgb: 0, 229, 255;
  --cyan-primary: #00E5FF;
  --cyan-dim: #006B7A;
  --cyan-glow: rgba(0, 229, 255, 0.15);

  /* ── Alert Colors ── */
  --alert-red: #FF3D3D;
  --alert-orange: #FF9500;
  --alert-green: #00E676;
  --alert-blue: #448AFF;
  --accent-weather: #E040FB;
  --accent-nuclear: #76FF03;

  /* ── Borders ── */
  --border-primary: rgba(212, 175, 55, 0.15);
  --border-secondary: rgba(212, 175, 55, 0.08);
  --border-active: rgba(212, 175, 55, 0.4);
  --border-cyan: rgba(0, 229, 255, 0.2);

  /* ── Text ── */
  --text-primary: #E8E6E0;
  --text-secondary: #9B978E;
  --text-muted: #5C5A54;
  --text-heading: #F5F0E0;
  --text-gold: #D4AF37;
  --text-cyan: #00E5FF;

  /* ── Layout ── */
  --top-bar-h: 56px;
  --bottom-bar-h: 32px;
  --left-w: 280px;
  --right-w: 320px;

  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  --font-sans: 'Inter', -apple-system, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ═══ Scrollbar ═══ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(212, 175, 55, 0.4); }

/* ═══ Top Header Bar ═══ */
.top-bar {
  height: var(--top-bar-h);
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 10;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.6);
}
.top-bar::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold-primary) 50%, transparent 100%);
  opacity: 0.5;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  font-size: 26px;
  filter: drop-shadow(0 0 8px var(--gold-glow));
  animation: pulse-eye 4s ease-in-out infinite;
}
@keyframes pulse-eye {
  0%, 100% { filter: drop-shadow(0 0 6px var(--gold-glow)); }
  50% { filter: drop-shadow(0 0 14px var(--gold-glow)); }
}
.brand-text h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-heading);
  font-family: var(--font-mono);
}
.brand-sub {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 2px;
  font-family: var(--font-mono);
}

.top-stats { display: flex; align-items: center; gap: 8px; }
.stat-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(12, 14, 26, 0.6);
  border: 1px solid var(--border-secondary);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.stat-label { color: var(--text-muted); font-size: 9px; letter-spacing: 1px; }
.stat-val { color: var(--text-primary); font-weight: 600; }
.stat-val.alert { color: var(--alert-red); }
.stat-chip.live { color: var(--alert-green); border-color: rgba(0, 230, 118, 0.3); }
.pulse-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--alert-green);
  box-shadow: 0 0 8px var(--alert-green);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ═══ Main Layout ═══ */
.main-layout {
  display: flex;
  height: calc(100vh - var(--top-bar-h) - var(--bottom-bar-h));
  position: relative;
}

/* ── Panels (glassmorphism) ── */
.left-panel, .right-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, transform 0.3s ease;
  z-index: 5;
}
.left-panel {
  width: var(--left-w);
  border-right: 1px solid var(--border-primary);
}
.right-panel {
  width: var(--right-w);
  border-left: 1px solid var(--border-primary);
}
.left-panel.collapsed { width: 0; overflow: hidden; border-right: none; }
.right-panel.collapsed { width: 0; overflow: hidden; border-left: none; }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-secondary);
  background: rgba(212, 175, 55, 0.03);
}
.panel-header h2 {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-gold);
  font-family: var(--font-mono);
  font-weight: 600;
}
.collapse-btn {
  background: none; border: 1px solid var(--border-secondary);
  color: var(--text-secondary);
  width: 22px; height: 22px; border-radius: 3px;
  cursor: pointer; font-size: 14px; line-height: 1;
  transition: all 0.2s;
}
.collapse-btn:hover { border-color: var(--gold-primary); color: var(--gold-primary); }

.panel-body { flex: 1; overflow-y: auto; padding: 8px; }
.panel-footer {
  padding: 8px;
  border-top: 1px solid var(--border-secondary);
}

.action-btn {
  width: 100%;
  padding: 8px;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--border-primary);
  color: var(--text-gold);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.2s;
}
.action-btn:hover {
  background: rgba(212, 175, 55, 0.15);
  border-color: var(--gold-primary);
  box-shadow: 0 0 12px var(--gold-glow);
}
.action-btn i { width: 14px; height: 14px; }

/* ── Layer items ── */
.layer-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}
.layer-item:hover {
  background: rgba(212, 175, 55, 0.06);
  border-color: var(--border-secondary);
}
.layer-item.active {
  background: rgba(0, 229, 255, 0.06);
  border-color: var(--border-cyan);
}
.layer-icon {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-secondary);
  flex-shrink: 0;
}
.layer-info { flex: 1; min-width: 0; }
.layer-name {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
}
.layer-count {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.layer-toggle {
  width: 32px; height: 16px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.layer-toggle::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  top: 2px; left: 2px;
  transition: all 0.2s;
}
.layer-item.active .layer-toggle { background: rgba(0, 229, 255, 0.3); }
.layer-item.active .layer-toggle::after {
  left: 18px;
  background: var(--cyan-primary);
  box-shadow: 0 0 6px var(--cyan-primary);
}
.layer-item.loading .layer-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Map ═══ */
.map-wrap {
  flex: 1;
  position: relative;
  background: var(--bg-void);
}
#map {
  position: absolute;
  inset: 0;
  background: #04040A;
}

/* ═══════════════════════════════════════════════════════════════
   Leaflet 暗色主题适配
   ═══════════════════════════════════════════════════════════════ */
/* 地图容器 */
.leaflet-container {
  background: #04040A !important;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  outline: none;
}

/* 缩放控件(暗色) */
.leaflet-control-zoom {
  border: 1px solid #2B2A27 !important;
  border-radius: 4px !important;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
}
.leaflet-control-zoom a {
  background: #1A1917 !important;
  color: #9B978E !important;
  border-color: #2B2A27 !important;
  width: 28px !important;
  height: 28px !important;
  line-height: 28px !important;
  font-size: 16px !important;
}
.leaflet-control-zoom a:hover {
  background: #2B2A27 !important;
  color: #FFD700 !important;
}

/* Popup 样式(暗色) */
.leaflet-popup-content-wrapper {
  background: #1A1917 !important;
  color: #E8E4DC !important;
  border-radius: 6px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
  border: 1px solid #2B2A27;
}
.leaflet-popup-content {
  margin: 10px 14px !important;
  font-size: 12px !important;
  line-height: 1.5 !important;
}
.leaflet-popup-tip {
  background: #1A1917 !important;
  border: 1px solid #2B2A27;
  border-top: none;
  border-left: none;
}
.leaflet-popup-close-button {
  color: #9B978E !important;
  font-size: 16px !important;
  padding: 4px 6px !important;
}
.leaflet-popup-close-button:hover { color: #FF3D3D !important; }

/* 禁用默认 attribution */
.leaflet-control-attribution { display: none !important; }

/* Circle marker hover */
.leaflet-interactive { cursor: pointer; }

/* iframe 在 modal 中 */
.modal iframe {
  display: block;
  width: 100%;
  max-width: 640px;
  height: 380px;
  margin: 0 auto;
  border: none;
  background: #000;
  border-radius: 4px;
}

/* 隐藏 Leaflet 默认的高德 attribution 文字(太丑) */
.leaflet-control-attribution {
  display: none !important;
}

/* 高德弹窗容器适配暗色主题 */
.amap-info-content {
  background: #1A1917 !important;
  color: #E8E4DC !important;
  border: 1px solid #2B2A27 !important;
  border-radius: 4px !important;
}

/* 确保 popup 在地图容器之上 */
.leaflet-popup { z-index: 2000 !important; }
.leaflet-popup-content { margin: 10px 14px !important; }

/* circle-marker 交互样式 */
.leaflet-circle-marker-pane { pointer-events: auto; }
svg.leaflet-overlay-pane-svg { pointer-events: auto; }

/* ── Map overlays ── */
.map-overlay {
  position: absolute;
  z-index: 4;
  pointer-events: none;
}
.map-overlay.top-left { top: 12px; left: 12px; }
.map-overlay.top-right { top: 12px; right: 12px; }
.map-overlay.bottom-left { bottom: 12px; left: 12px; }
.map-overlay > * { pointer-events: auto; }

.hud-card {
  background: var(--bg-panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  padding: 8px 12px;
  min-width: 140px;
}
.hud-title {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}
.hud-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-cyan);
}

.view-btns { display: flex; gap: 4px; }
.view-btns button {
  width: 30px; height: 28px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-secondary);
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.view-btns button:hover { border-color: var(--gold-primary); background: rgba(212, 175, 55, 0.1); }

.legend-card { max-width: 220px; }
.legend-list { display: flex; flex-direction: column; gap: 4px; }
.legend-row { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Loading overlay ── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 10, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity 0.4s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loader-ring {
  width: 48px; height: 48px;
  border: 2px solid rgba(212, 175, 55, 0.15);
  border-top-color: var(--gold-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}
.loader-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-gold);
  letter-spacing: 1.5px;
}

/* ═══ Right Panel: Tabs ═══ */
.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border-secondary);
  background: rgba(0, 0, 0, 0.3);
}
.tab-btn {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active {
  color: var(--text-gold);
  border-bottom-color: var(--gold-primary);
  background: rgba(212, 175, 55, 0.05);
}
.tab-content { display: none; padding: 10px; }
.tab-content.active { display: block; }

/* ── Alert list ── */
.alert-list { display: flex; flex-direction: column; gap: 6px; }
.alert-card {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid var(--text-muted);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}
.alert-card:hover { background: rgba(255, 255, 255, 0.05); }
.alert-card.severity-critical { border-left-color: var(--alert-red); }
.alert-card.severity-high { border-left-color: var(--alert-orange); }
.alert-card.severity-moderate { border-left-color: var(--alert-blue); }
.alert-card.severity-info { border-left-color: var(--cyan-primary); }
.alert-type {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
  font-family: var(--font-mono);
  margin-bottom: 2px;
}
.alert-title { font-size: 12px; color: var(--text-primary); font-weight: 500; }
.alert-meta { font-size: 10px; color: var(--text-muted); margin-top: 4px; font-family: var(--font-mono); }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-block {
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-secondary);
  border-radius: 4px;
}
.stat-block-label {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.stat-block-val {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-cyan);
  margin-top: 2px;
}
.stat-block-sub { font-size: 10px; color: var(--text-muted); }

/* ── Detail ── */
.detail-content { font-size: 12px; }
.detail-section { margin-bottom: 14px; }
.detail-label {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}
.detail-val { color: var(--text-primary); font-family: var(--font-mono); font-size: 11px; word-break: break-all; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  padding: 30px 10px;
  font-style: italic;
}

/* ═══ Bottom Bar ═══ */
.bottom-bar {
  height: var(--bottom-bar-h);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}
.status-left, .status-right { display: flex; gap: 16px; }
.status-item { display: flex; align-items: center; gap: 4px; }
.status-item i { width: 11px; height: 11px; }
.status-center { color: var(--text-gold); letter-spacing: 1px; }

/* ═══ Modals ═══ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-content.modal-lg { width: 800px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-secondary);
  background: rgba(212, 175, 55, 0.05);
}
.modal-header h3 { font-size: 13px; color: var(--text-gold); font-family: var(--font-mono); letter-spacing: 1px; }
.modal-close {
  background: none;
  border: 1px solid var(--border-secondary);
  color: var(--text-secondary);
  width: 24px; height: 24px;
  border-radius: 3px;
  cursor: pointer;
}
.modal-close:hover { border-color: var(--alert-red); color: var(--alert-red); }
.modal-body { padding: 12px; overflow: auto; }
#newsVideo { width: 100%; max-width: 760px; display: block; background: #000; }
#cctvImage { max-width: 600px; max-height: 70vh; display: block; }

/* ═══ Responsive ═══ */
@media (max-width: 1024px) {
  :root { --left-w: 240px; --right-w: 280px; }
}
@media (max-width: 768px) {
  .left-panel, .right-panel { position: absolute; top: 0; bottom: 0; }
  .left-panel { left: 0; }
  .right-panel { right: 0; }
  .map-overlay.bottom-left { display: none; }
}
