/* QuakeFire Sim - Dark theme styles */

:root {
  --bg-950: #030712;
  --bg-900: #111827;
  --bg-800: #1f2937;
  --bg-700: #374151;
  --text-100: #f3f4f6;
  --text-400: #9ca3af;
  --accent: #22d3ee;
  --cyan-400: #22d3ee;
  --amber-400: #fbbf24;
  --red-400: #f87171;
  --emerald-400: #34d399;
  --btn-gradient: linear-gradient(135deg, #0891b2, #06b6d4);
  --btn-shadow: rgba(34, 211, 238, 0.15);
  --btn-shadow-hover: rgba(34, 211, 238, 0.3);
  --sidebar-bg: rgba(17, 24, 39, 0.97);
  --slider-gradient: linear-gradient(to right, var(--accent), var(--bg-700));
  --slider-glow: rgba(34, 211, 238, 0.4);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-950);
  color: var(--text-100);
  overflow: hidden;
  height: 100vh;
}

/* Header */
#header {
  height: 48px;
  background: var(--bg-900);
  border-bottom: 1px solid var(--bg-700);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
  position: relative;
}

#header .logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--cyan-400);
  white-space: nowrap;
}

#header .status-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-400);
}

#header .badge {
  background: var(--bg-700);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

#progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--cyan-400);
  width: 0%;
  transition: width 0.3s ease;
}

#progress-bar.active {
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% { width: 0%; margin-left: 0; }
  50% { width: 40%; margin-left: 30%; }
  100% { width: 0%; margin-left: 100%; }
}

/* Main layout */
#main {
  display: flex;
  height: calc(100vh - 48px);
}

/* Sidebar */
#sidebar {
  width: 280px;
  min-width: 280px;
  background: rgba(17, 24, 39, 0.97);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--bg-700);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 50;
}

.sidebar-section {
  border-bottom: 1px solid var(--bg-700);
  padding-bottom: 14px;
}

.sidebar-section:last-child { border-bottom: none; }

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-400);
  margin-bottom: 10px;
}

/* Coordinate display */
.coord-display {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  color: var(--cyan-400);
  background: var(--bg-800);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--bg-700);
  text-align: center;
}

.coord-display .label {
  font-size: 10px;
  color: var(--text-400);
  font-family: 'Inter', sans-serif;
  margin-bottom: 2px;
}

/* Range slider */
.range-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-wrap input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: linear-gradient(to right, var(--cyan-400), var(--bg-700));
  border-radius: 2px;
  outline: none;
}

.range-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cyan-400);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.4);
}

.range-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--cyan-400);
  min-width: 50px;
  text-align: right;
}

/* Radio buttons */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.15s;
}

.radio-group label:hover {
  background: var(--bg-800);
}

.radio-group input[type="radio"] {
  accent-color: var(--cyan-400);
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--btn-gradient);
  color: white;
  box-shadow: 0 0 20px var(--btn-shadow);
  transition: all 0.2s;
}

.btn-primary:hover {
  box-shadow: 0 0 30px var(--btn-shadow-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--bg-700);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-800);
  color: var(--text-100);
  transition: all 0.15s;
}

.btn-secondary:hover {
  border-color: var(--cyan-400);
  background: var(--bg-700);
}

/* Seed toggle */
.seed-toggle {
  display: flex;
  gap: 4px;
}

.seed-toggle button {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--bg-700);
  border-radius: 6px;
  background: var(--bg-800);
  color: var(--text-400);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.seed-toggle button.active {
  background: var(--accent, var(--cyan-400));
  color: var(--bg-950);
  border-color: var(--accent, var(--cyan-400));
  font-weight: 600;
}

.seed-toggle button:hover {
  border-color: var(--accent, var(--cyan-400));
}

/* Reset button */
.btn-reset {
  color: var(--text-400) !important;
  font-size: 12px !important;
  border-style: dashed !important;
}

/* Content area */
#content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Map */
#map-container {
  flex: 1;
  position: relative;
  min-height: 300px;
}

#map {
  width: 100%;
  height: 100%;
}

#folium-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 1100;
  display: none;
  background: var(--bg-950);
}

#folium-overlay iframe {
  width: 100%;
  height: 100%;
  border: none;
}

#folium-close {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1200;
  background: var(--bg-900);
  color: var(--text-100);
  border: 1px solid var(--bg-700);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#folium-close:hover {
  background: var(--bg-700);
}

/* Map overlay instruction */
#map-instruction {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.9);
  color: var(--text-400);
  padding: 8px 16px;
  border-radius: 8px;
  z-index: 1050;
  font-size: 13px;
  pointer-events: none;
  border: 1px solid var(--bg-700);
  transition: opacity 0.3s;
}

/* Dashboard panel */
#dashboard-panel {
  height: 0;
  overflow: hidden;
  background: var(--bg-900);
  border-top: 1px solid var(--bg-700);
  transition: height 0.3s ease;
}

#dashboard-panel.open {
  height: 380px;
  overflow-y: auto;
}

#dashboard-toggle {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1050;
  background: var(--bg-900);
  border: 1px solid var(--bg-700);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 4px 20px;
  color: var(--text-400);
  font-size: 12px;
  cursor: pointer;
}

#dashboard-toggle:hover {
  color: var(--cyan-400);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
}

.kpi-card {
  background: var(--bg-800);
  border: 1px solid var(--bg-700);
  border-radius: 12px;
  padding: 14px;
}

.kpi-card .kpi-label {
  font-size: 11px;
  color: var(--text-400);
  margin-bottom: 4px;
}

.kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.kpi-card .kpi-value.cyan { color: var(--cyan-400); }
.kpi-card .kpi-value.emerald { color: var(--emerald-400); }
.kpi-card .kpi-value.amber { color: var(--amber-400); }
.kpi-card .kpi-value.red { color: var(--red-400); }

.kpi-card .kpi-sub {
  font-size: 11px;
  color: var(--text-400);
  margin-top: 4px;
}

/* Charts area */
.charts-area {
  display: flex;
  gap: 12px;
  padding: 0 16px 16px;
  overflow-x: auto;
}

.chart-card {
  background: var(--bg-800);
  border: 1px solid var(--bg-700);
  border-radius: 12px;
  padding: 14px;
  min-width: 320px;
  flex: 1;
}

.chart-card .chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-400);
  margin-bottom: 8px;
}

/* Simulation stepper */
.sim-stepper {
  display: flex;
  gap: 8px;
  padding: 16px;
}

.sim-step {
  flex: 1;
  background: var(--bg-800);
  border: 1px solid var(--bg-700);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.sim-step .step-num {
  font-size: 10px;
  color: var(--text-400);
  font-weight: 700;
}

.sim-step .step-label {
  font-size: 12px;
  margin: 4px 0;
}

.sim-step .step-value {
  font-size: 20px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.sim-step .step-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  transition: width 0.8s ease;
}

/* Basis toggle */
.basis-toggle {
  display: flex;
  gap: 4px;
  padding: 0 16px 8px;
}

.basis-toggle button {
  padding: 4px 12px;
  border: 1px solid var(--bg-700);
  border-radius: 6px;
  background: var(--bg-800);
  color: var(--text-400);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.basis-toggle button.active {
  background: var(--cyan-400);
  color: var(--bg-950);
  border-color: var(--cyan-400);
  font-weight: 600;
}

/* Skeleton loading */
.skeleton {
  background: var(--bg-700);
  border-radius: 8px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Responsive */
@media (max-width: 768px) {
  #main { flex-direction: column; }
  #sidebar {
    width: 100%;
    min-width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    border-right: none;
    border-bottom: 1px solid var(--bg-700);
  }
  .sidebar-section {
    flex: 1;
    min-width: 140px;
    border-bottom: none;
    padding-bottom: 0;
  }
  #map-container { min-height: 250px; }
  #dashboard-panel.open { height: 300px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .sim-stepper { flex-wrap: wrap; }
  .sim-step { min-width: 120px; }
}

/* Debug Panel */
.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.debug-arrow {
  font-size: 10px;
  color: var(--text-400);
  transition: transform 0.2s;
}

.debug-arrow.open {
  transform: rotate(90deg);
}

.debug-panel {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.debug-panel.collapsed {
  max-height: 0;
}

.debug-panel.expanded {
  max-height: 400px;
}

.debug-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 4px;
}

.debug-btn {
  padding: 2px 8px;
  border: 1px solid var(--bg-700);
  border-radius: 4px;
  background: var(--bg-800);
  color: var(--text-400);
  font-size: 10px;
  cursor: pointer;
}

.debug-btn:hover {
  border-color: var(--accent);
  color: var(--text-100);
}

.debug-count {
  font-size: 10px;
  color: var(--text-400);
  font-family: 'JetBrains Mono', monospace;
}

.debug-log {
  max-height: 340px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  line-height: 1.5;
  background: var(--bg-950);
  border: 1px solid var(--bg-700);
  border-radius: 6px;
  padding: 6px;
}

.debug-entry {
  border-bottom: 1px solid var(--bg-800);
  padding: 3px 0;
  word-break: break-all;
}

.debug-entry:last-child {
  border-bottom: none;
}

.debug-entry .debug-time {
  color: var(--text-400);
}

.debug-entry .debug-method {
  font-weight: 700;
  color: var(--accent);
}

.debug-entry .debug-url {
  color: var(--cyan-400);
}

.debug-entry .debug-status-ok {
  color: var(--emerald-400);
  font-weight: 700;
}

.debug-entry .debug-status-err {
  color: var(--red-400);
  font-weight: 700;
}

.debug-entry .debug-body {
  color: var(--text-400);
  display: block;
  margin-top: 2px;
  white-space: pre-wrap;
  max-height: 80px;
  overflow-y: auto;
}

.debug-entry .debug-error-detail {
  color: #fca5a5;
  display: block;
  margin-top: 2px;
  white-space: pre-wrap;
}

/* 2D/3D view mode toggle */
.view-mode-toggle {
  display: flex;
  gap: 4px;
}

.view-mode-toggle button {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--bg-700);
  border-radius: 6px;
  background: var(--bg-800);
  color: var(--text-400);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.view-mode-toggle button.active {
  background: var(--accent, var(--cyan-400));
  color: var(--bg-950);
  border-color: var(--accent, var(--cyan-400));
  font-weight: 600;
}

.view-mode-toggle button:hover {
  border-color: var(--accent, var(--cyan-400));
}

.view-mode-toggle button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 3D Map overlay */
#map-3d-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1100;
  display: none;
  background: var(--bg-950);
}

#map-3d-maplibre {
  width: 100%;
  height: 100%;
}

#map-3d-tooltip {
  display: none;
  position: absolute;
  z-index: 1200;
  background: rgba(17, 24, 39, 0.94);
  color: #f3f4f6;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid var(--bg-700);
  pointer-events: none;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

#map-3d-legend {
  position: absolute;
  bottom: 20px;
  left: 12px;
  z-index: 1200;
  background: rgba(17, 24, 39, 0.94);
  color: #f3f4f6;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid var(--bg-700);
  max-height: 50vh;
  overflow-y: auto;
  max-width: 240px;
}

#map-3d-legend .legend-title {
  font-weight: 700;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--bg-700);
}

#map-3d-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0;
}

#map-3d-legend .legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid #555;
  flex-shrink: 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-900); }
::-webkit-scrollbar-thumb { background: var(--bg-700); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }
