/* ================================================================
   style.css — Dark-theme dashboard
   ================================================================ */

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

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #30363d;
  --text:      #e6edf3;
  --text-dim:  #8b949e;
  --accent:    #00e5ff;
  --sidebar-w: 30%;
}

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

body {
  display: flex;
  flex-direction: column;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: var(--sidebar-w);
  min-width: 280px;
  max-width: 420px;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#sidebar header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Inline status badge in header */
.status-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: rgba(0, 229, 255, 0.12);
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}

.card h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.indicator-section canvas {
  width: 100% !important;
}

/* ---------- Indicator sections (value + chart) ---------- */
.indicator-section {
  padding: 0.5rem 0.65rem;
}

.ind-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.ind-header h2 {
  margin-bottom: 0.1rem;
}

.indicator-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.indicator-ts {
  font-size: 0.6rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.indicator-countdown {
  font-size: 0.6rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-top: 0.15rem;
}

.chart-wrap {
  position: relative;
  height: 110px;
}

/* ---------- Map ---------- */
#map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* Override Leaflet controls for dark theme */
.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Map tile background (shown before tiles load / in empty areas) */
.leaflet-container {
  background: #262626 !important;
}

/* ---------- Globe container ---------- */
#globe-container {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #050508;
  overflow: hidden;
  visibility: hidden;
}

/* Do NOT force canvas size here — Three.js owns the canvas dimensions */

/* ---------- Globe layer toggle panel ---------- */
.globe-layers-panel {
  position: absolute;
  bottom: 0.8rem;
  left: 0.8rem;
  z-index: 1001;
  background: rgba(13, 17, 23, 0.88);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  backdrop-filter: blur(6px);
  font-size: 0.68rem;
  min-width: 130px;
}
.gl-title {
  color: var(--text-dim);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}
.gl-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0;
  cursor: pointer;
  color: var(--text);
  font-size: 0.68rem;
}
.gl-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 12px;
  height: 12px;
}
.gl-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ---------- Map/Globe toggle button ---------- */
.view-toggle-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 1000;
  background: rgba(22, 27, 34, 0.88);
  color: #00e5ff;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.72rem;
  font-family: inherit;
  letter-spacing: 0.03em;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: border-color 0.15s, background 0.15s;
}

.view-toggle-btn:hover {
  border-color: #00e5ff;
  background: rgba(0, 229, 255, 0.1);
}

/* ---------- Scrollbar ---------- */
#sidebar::-webkit-scrollbar {
  width: 6px;
}
#sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ---------- Right sidebar (model output) ---------- */
#output-sidebar {
  width: 420px;
  min-width: 340px;
  max-width: 520px;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
#output-sidebar::-webkit-scrollbar { width: 6px; }
#output-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---------- Status badge ---------- */
#api-status {
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------- Dashboard layout ---------- */
#dashboard-row {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---------- Timeline panel (horizontal, bottom) ---------- */
#timeline-panel {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0.75rem;
}

#timeline-feed {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  min-width: min-content;
}

#timeline-feed::-webkit-scrollbar { height: 5px; }
#timeline-feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---------- Timeline cards (horizontal layout) ---------- */
.tl-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 150px;
  max-width: 180px;
  flex-shrink: 0;
}

.tl-card:hover { border-color: #555; }

.tl-card.tl-input  { border-left: 3px solid #36a2eb; }
.tl-card.tl-model  { border-left: 3px solid #ff6384; }

.tl-card.highlight {
  border-color: var(--accent) !important;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.35);
}

.tl-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}

.tl-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.tl-params {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: "Fira Code", "Menlo", monospace;
}

.tl-time {
  font-size: 0.6rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* ---------- Bottom panel (Timeline + Console tabs) ---------- */
#bottom-panel {
  height: 220px;
  background: var(--surface);
  border-top: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: height 0.2s ease;
}

#bottom-panel.collapsed {
  height: 34px;
}

#bottom-panel.collapsed #bottom-content {
  display: none;
}

#bottom-tabs {
  display: flex;
  align-items: center;
  background: #111;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 0.5rem;
  gap: 0;
}

.bottom-tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.bottom-tab:hover { color: var(--text); }
.bottom-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.bottom-tab-spacer { flex: 1; }

#bottom-tabs #term-toggle-btn {
  background: none;
  border: 1px solid #333;
  color: #888;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: inherit;
  margin-left: 0.5rem;
}
#bottom-tabs #term-toggle-btn:hover {
  border-color: #555;
  color: #ccc;
}

#bottom-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.bottom-pane {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}
.bottom-pane-active {
  display: flex;
  flex-direction: column;
}

/* Console pane */
#console-panel {
  display: none;
  flex-direction: column;
}
#console-panel.bottom-pane-active {
  display: flex;
}

.console-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.75rem;
  background: #111;
  flex-shrink: 0;
}

.term-label {
  font-size: 0.7rem;
  color: #666;
  cursor: pointer;
}

.term-label input { margin-right: 0.25rem; }

#term-clear-btn,
#term-toggle-btn {
  background: none;
  border: 1px solid #333;
  color: #888;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: inherit;
}

#term-clear-btn:hover,
#term-toggle-btn:hover {
  border-color: #555;
  color: #ccc;
}

#terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  color: #00ff41;
  font-size: 0.72rem;
  line-height: 1.45;
  font-family: "Fira Code", "Menlo", "Courier New", monospace;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

#terminal-output::-webkit-scrollbar { width: 5px; }
#terminal-output::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* ---------- Offline overlay ---------- */
#offline-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  flex-direction: column;
  gap: 0.5rem;
}

#offline-overlay.hidden { display: none; }

.offline-content { text-align: center; }

.offline-content h2 {
  font-size: 2rem;
  color: #ff4444;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.offline-content p {
  color: #999;
  font-size: 0.9rem;
}

/* ---------- Time mode toggle (LOCAL / UTC / SINCE) ---------- */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.time-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.tt-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.tt-btn + .tt-btn { border-left: 1px solid var(--border); }
.tt-btn:hover { color: var(--text); }
.tt-btn.tt-active {
  background: rgba(0, 229, 255, 0.15);
  color: var(--accent);
}

/* ---------- Map data overlay labels ---------- */
.map-data-label {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}
.map-data-label span {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-shadow: 0 0 4px #000, 0 0 8px #000;
  white-space: nowrap;
}

/* ---------- Show Model button (removed — model is always visible) ---------- */
.show-model-btn { display: none; }

/* ---------- Model comparison panel (inline in right sidebar) ---------- */
#model-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.model-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.model-panel-header h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 0;
}

.model-panel-body {
  overflow-y: auto;
  padding: 0.6rem 0.8rem;
  font-size: 0.72rem;
  line-height: 1.5;
}
.model-panel-body::-webkit-scrollbar { width: 6px; }
.model-panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.model-loading { color: var(--text-dim); text-align: center; padding: 2rem; }

/* Parameters banner */
.model-params {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: "Fira Code", "Menlo", monospace;
  font-size: 0.72rem;
  color: var(--text-dim);
}
.model-params strong { color: var(--accent); }

/* Summary comparison cards */
.model-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}
.model-summary-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
}
.model-summary-card h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}
.model-summary-card .big-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  font-family: "Fira Code", "Menlo", monospace;
}
.model-summary-card .sub-val {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
  font-family: "Fira Code", "Menlo", monospace;
}

/* Step tables */
.model-section { margin-bottom: 1.2rem; }
.model-section h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

.model-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.model-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Fira Code", "Menlo", monospace;
  font-size: 0.68rem;
}
.model-table th,
.model-table td {
  padding: 0.35rem 0.6rem;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid #1e242c;
}
.model-table th {
  background: var(--bg);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.62rem;
  position: sticky;
  top: 0;
}
.model-table td { color: var(--text); }
.model-table tbody tr:hover { background: rgba(0, 229, 255, 0.04); }

/* ---------- Hazard history label ---------- */
.hazard-history-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0.6rem 0 0.2rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* ---------- Visual Scripting panel (sidebar sliders) ---------- */
#vs-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.vs-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  background: #111;
  border-bottom: 1px solid var(--border);
}
.vs-panel-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.vs-sliders-body {
  padding: 0.75rem 0.65rem;
}

/* Sliders */
.slider-group {
  margin-bottom: 0.75rem;
}
.slider-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
  font-weight: 600;
}
.slider-val {
  font-family: "Fira Code", "Menlo", monospace;
  color: var(--accent);
}
.slider-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  margin-top: 2px;
}
.slider-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
}
.slider-group input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.slider-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.vs-btn {
  flex: 1;
  padding: 0.35rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: rgba(0, 229, 255, 0.1);
  color: var(--accent);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background 0.15s;
}
.vs-btn:hover { background: rgba(0, 229, 255, 0.2); }
.vs-btn-dim {
  border-color: var(--border);
  background: transparent;
  color: var(--text-dim);
}
.vs-btn-dim:hover { background: rgba(255,255,255,0.04); }

.slider-status {
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  min-height: 1em;
}

.vs-hint {
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}
.vs-empty-hint {
  font-size: 0.62rem;
  color: var(--text-dim);
  text-align: center;
  padding: 0.3rem 0;
}
.vs-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.6rem 0;
}
.vs-sub-heading {
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

/* ---------- Node Editor — now served at /editor (see editor.css) ---------- */

/* ---------- Timeline separator for model config changes ---------- */
.tl-separator {
  min-width: 100%;
  max-width: 100%;
  flex-shrink: 0;
  background: rgba(255, 193, 7, 0.08);
  border: 1px dashed rgba(255, 193, 7, 0.5);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  text-align: center;
}
.tl-separator .tl-label {
  color: #ffc107;
  font-weight: 700;
}
.tl-separator .tl-value {
  color: #ffc107;
  font-size: 0.72rem;
}

/* Override badge when model config is active */
.override-badge {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 0.5rem;
  vertical-align: middle;
}
