/* ═══════════════════════════════════════════════════════════════
   SIMULADOR DE TERREMOTOS — Sistema de Diseño
   Tema oscuro premium con glassmorphism
   ═══════════════════════════════════════════════════════════════ */

/* ─── Variables de Diseño ─── */
:root {
  /* Fondos */
  --bg-primary: #0a0a0f;
  --bg-secondary: #0d0d15;
  --bg-surface: rgba(255, 255, 255, 0.05);
  --bg-surface-hover: rgba(255, 255, 255, 0.08);
  --bg-surface-active: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);

  /* Glassmorphism */
  --glass-bg: rgba(15, 15, 25, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: blur(20px);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

  /* Paleta sísmica por magnitud */
  --m-micro:    #22c55e;   /* M1–2: Verde */
  --m-menor:    #84cc16;   /* M2–3: Lima */
  --m-leve:     #eab308;   /* M3–4: Amarillo */
  --m-moderado: #f97316;   /* M4–5: Naranja */
  --m-fuerte:   #ef4444;   /* M5–6: Rojo */
  --m-mayor:    #dc2626;   /* M6–7: Rojo oscuro */
  --m-gran:     #9333ea;   /* M7–8: Púrpura */
  --m-enorme:   #7c3aed;   /* M8+:  Violeta */

  /* Acentos */
  --accent-primary: #6366f1;
  --accent-primary-glow: rgba(99, 102, 241, 0.3);
  --accent-success: #22c55e;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-info: #3b82f6;

  /* Tipografía */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --text-accent: #a5b4fc;

  /* Espaciado */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  /* Radios */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Transiciones */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --header-height: 64px;
  --footer-height: 48px;
  --panel-width: 300px;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
}

/* ─── Scrollbar personalizado ─── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */

#app-header {
  height: var(--header-height);
  background: linear-gradient(
    180deg,
    rgba(15, 15, 30, 0.95) 0%,
    rgba(10, 10, 20, 0.9) 100%
  );
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-lg);
  z-index: 100;
  flex-shrink: 0;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#header-title {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, #f1f5f9 0%, #a5b4fc 50%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.header-icon {
  -webkit-text-fill-color: initial;
  font-size: 1.4rem;
}

#header-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: 0.5px;
}

/* Badge de estado */
.status-badge {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--radius-xl);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid;
}

.status-badge.status-idle {
  color: var(--text-secondary);
  border-color: var(--border);
  background: var(--bg-surface);
}

.status-badge.status-running {
  color: var(--accent-danger);
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  animation: statusPulse 2s ease-in-out infinite;
}

.status-badge.status-paused {
  color: var(--accent-warning);
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.1);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.status-running .status-dot {
  animation: dotPulse 1s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
  50% { box-shadow: 0 0 12px 2px rgba(239, 68, 68, 0.2); }
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.btn-mute {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  margin-right: var(--spacing-sm);
  opacity: 0.7;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.btn-mute:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════════
   MAIN LAYOUT — 3 columnas dinámicas
   ═══════════════════════════════════════════════════════════════ */

#app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════════
   PANELES GLASS & COLAPSO
   ═══════════════════════════════════════════════════════════════ */

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: var(--panel-width);
  flex-shrink: 0;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), margin 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 10;
}

#panel-controls {
  border-right: 1px solid var(--glass-border);
  border-left: none;
}

#panel-controls.collapsed {
  margin-left: calc(var(--panel-width) * -1);
}

#panel-info {
  border-left: 1px solid var(--glass-border);
  border-right: none;
}

#panel-info.collapsed {
  margin-right: calc(var(--panel-width) * -1);
}

/* Contenedor central (3D) */
#viewport-container {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

/* Botones Colapsables */
.btn-toggle-panel {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-surface-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 24px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  border-radius: 0 8px 8px 0;
  border-left: none;
  backdrop-filter: var(--glass-blur);
  transition: background 0.2s, opacity 0.2s;
  opacity: 0.6;
}

.btn-toggle-panel:hover {
  background: var(--primary);
  opacity: 1;
}

.btn-toggle-panel.right {
  right: 0;
  border-radius: 8px 0 0 8px;
  border-right: none;
  border-left: 1px solid var(--border);
}

.panel-header {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.panel-body {
  padding: var(--spacing-md) var(--spacing-lg);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

/* ═══════════════════════════════════════════════════════════════
   CONTROLES (Panel Izquierdo)
   ═══════════════════════════════════════════════════════════════ */

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.control-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.control-value {
  color: var(--accent-primary);
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

/* ─── Sliders ─── */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-surface);
  outline: none;
  cursor: pointer;
  transition: var(--transition-base);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-primary-glow), 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: var(--transition-fast);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 16px var(--accent-primary-glow), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 10px var(--accent-primary-glow), 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Slider de magnitud — cambia de color según el valor (controlado por JS) */
.slider-magnitude {
  --slider-color: var(--m-moderado);
}

.slider-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* ─── Select ─── */
.select-control {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: var(--transition-base);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.select-control:hover {
  border-color: var(--border-hover);
  background-color: var(--bg-surface-hover);
}

.select-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary-glow);
}

.select-control option {
  background: #1a1a2e;
  color: var(--text-primary);
}

/* ─── Radio buttons ─── */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.radio-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--spacing-xs) 0;
  transition: color var(--transition-fast);
}

.radio-label:hover {
  color: var(--text-primary);
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-custom {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  position: relative;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.radio-label input[type="radio"]:checked + .radio-custom {
  border-color: var(--accent-primary);
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
}

/* ─── Botones ─── */
.control-actions {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-base);
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::before {
  opacity: 1;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary) 0%, #4f46e5 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.btn-simulate.simulating {
  background: linear-gradient(135deg, var(--accent-danger) 0%, #dc2626 100%);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-icon {
  font-size: 1rem;
}

/* ═══════════════════════════════════════════════════════════════
   VIEWPORT (Centro — Canvas Three.js)
   ═══════════════════════════════════════════════════════════════ */

#viewport-container {
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
  /* Gradiente sutil de fondo */
  background: 
    radial-gradient(ellipse at 50% 50%, rgba(99, 102, 241, 0.03) 0%, transparent 70%),
    var(--bg-primary);
}

#three-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Etiqueta de escena */
.scene-label {
  position: absolute;
  top: var(--spacing-md);
  left: var(--spacing-md);
  padding: var(--spacing-xs) var(--spacing-md);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 10;
}

/* ═══════════════════════════════════════════════════════════════
   DEPTH GAUGE (overlay sobre canvas)
   ═══════════════════════════════════════════════════════════════ */

.depth-gauge {
  position: absolute;
  right: var(--spacing-md);
  top: 50%;
  transform: translateY(-50%);
  width: 120px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm);
  z-index: 10;
  pointer-events: none;
}

.depth-gauge-header {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--border);
}

.depth-gauge-track {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.depth-layer {
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-xs);
  display: flex;
  flex-direction: column;
  gap: 1px;
  transition: opacity var(--transition-base);
}

.layer-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-primary);
}

.layer-range {
  font-size: 0.55rem;
  color: var(--text-muted);
}

.layer-corteza {
  background: rgba(139, 92, 42, 0.4);
  border-left: 3px solid #8b5c2a;
}

.layer-manto-sup {
  background: rgba(192, 88, 33, 0.3);
  border-left: 3px solid #c05821;
}

.layer-astenosfera {
  background: rgba(220, 50, 20, 0.25);
  border-left: 3px solid #dc3214;
}

.layer-manto-inf {
  background: rgba(180, 30, 10, 0.2);
  border-left: 3px solid #b41e0a;
}

/* Indicador del epicentro */
.depth-indicator {
  position: absolute;
  left: -4px;
  right: -4px;
  height: 2px;
  background: var(--accent-danger);
  box-shadow: 0 0 8px var(--accent-danger), 0 0 16px rgba(239, 68, 68, 0.4);
  transition: top var(--transition-slow);
  top: 10%; /* Posición por defecto, controlada por JS */
}

.depth-indicator-label {
  position: absolute;
  left: -50px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--accent-danger);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   SISMOGRAMA
   ═══════════════════════════════════════════════════════════════ */

.seismogram-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(0deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
  pointer-events: none;
  z-index: 15;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.seismogram-header {
  position: absolute;
  top: 10px;
  left: var(--spacing-md);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent-danger);
  border-radius: 50%;
  animation: dotPulse 1.5s infinite;
}

#seismogram-canvas {
  width: 100%;
  height: 80px;
}

/* ═══════════════════════════════════════════════════════════════
   ALERTA DE TSUNAMI
   ═══════════════════════════════════════════════════════════════ */

.tsunami-alert {
  position: absolute;
  bottom: var(--spacing-lg);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-xl);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.9) 0%, rgba(37, 99, 235, 0.9) 100%);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(96, 165, 250, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.3);
  z-index: 20;
  animation: tsunamiPulse 2s ease-in-out infinite;
  transition: opacity var(--transition-base), transform var(--transition-base);
}

.tsunami-alert.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(20px);
}

.tsunami-alert-icon {
  font-size: 1.5rem;
  animation: tsunamiWave 1.5s ease-in-out infinite;
}

.tsunami-alert-text {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.tsunami-alert-height {
  font-size: 0.75rem;
  opacity: 0.9;
}

@keyframes tsunamiPulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(59, 130, 246, 0.3); }
  50% { box-shadow: 0 8px 48px rgba(59, 130, 246, 0.5); }
}

@keyframes tsunamiWave {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-3px) rotate(-5deg); }
  75% { transform: translateY(2px) rotate(3deg); }
}

/* ═══════════════════════════════════════════════════════════════
   INFO PANEL (Panel Derecho)
   ═══════════════════════════════════════════════════════════════ */

.info-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  transition: var(--transition-base);
}

.info-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
}

.info-card-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.info-card-icon {
  font-size: 0.9rem;
}

.info-card-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.info-card-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.info-value-xl {
  font-size: 2rem;
}

.info-value-sm {
  font-size: 1rem;
}

.info-card-description {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--spacing-xs);
}

/* Línea de Tiempo Interactiva */
.timeline-container {
  margin-top: var(--spacing-sm);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.timeline-track {
  position: relative;
  height: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
}

.timeline-phase {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  transition: color var(--transition-fast);
}

.timeline-phase:last-child {
  border-right: none;
}

.timeline-phase.active {
  color: white;
  text-shadow: 0 0 4px rgba(255,255,255,0.8);
}

.phase-p.active { background: rgba(59, 130, 246, 0.3); }
.phase-s.active { background: rgba(245, 158, 11, 0.3); }
.phase-main.active { background: rgba(239, 68, 68, 0.3); }
.phase-coda.active { background: rgba(34, 197, 94, 0.3); }

.timeline-progress {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: rgba(255, 255, 255, 0.15);
  border-right: 2px solid var(--accent-primary);
  pointer-events: none;
  box-shadow: 2px 0 8px rgba(99, 102, 241, 0.5);
  transition: width 0.1s linear;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Filas de tiempo */
.info-time-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) 0;
}

.info-time-row + .info-time-row {
  border-top: 1px solid var(--border);
}

.info-time-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.info-time-value {
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════ */

#app-footer {
  height: var(--footer-height);
  background: rgba(10, 10, 20, 0.95);
  backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-lg);
  flex-shrink: 0;
  z-index: 100;
}

.footer-content {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  width: 100%;
}

.footer-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

.richter-legend {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.richter-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.richter-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.richter-text {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   UTILIDADES
   ═══════════════════════════════════════════════════════════════ */

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ─── Colores de magnitud (aplicados dinámicamente por JS) ─── */
.magnitude-color-1 { color: var(--m-micro); }
.magnitude-color-2 { color: var(--m-menor); }
.magnitude-color-3 { color: var(--m-leve); }
.magnitude-color-4 { color: var(--m-moderado); }
.magnitude-color-5 { color: var(--m-fuerte); }
.magnitude-color-6 { color: var(--m-mayor); }
.magnitude-color-7 { color: var(--m-gran); }
.magnitude-color-8 { color: var(--m-enorme); }

/* ─── Animación shake para la UI durante sismo ─── */
@keyframes uiShake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-2px, -1px); }
  20% { transform: translate(2px, 1px); }
  30% { transform: translate(-1px, 2px); }
  40% { transform: translate(1px, -2px); }
  50% { transform: translate(-2px, 1px); }
  60% { transform: translate(2px, -1px); }
  70% { transform: translate(-1px, -2px); }
  80% { transform: translate(1px, 2px); }
  90% { transform: translate(-2px, -1px); }
}

.ui-shaking {
  animation: uiShake var(--shake-speed, 0.15s) linear infinite;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
  :root {
    --panel-width: 260px;
  }
}

@media (max-width: 900px) {
  #app-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .glass-panel {
    border: none;
    border-bottom: 1px solid var(--glass-border);
  }

  #panel-controls {
    border-right: none;
  }

  #panel-info {
    border-left: none;
    border-top: 1px solid var(--glass-border);
  }

  #viewport-container {
    min-height: 300px;
  }

  .depth-gauge {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Nuevas Funciones (Toggle Antisísmico y PGA Bar)
   ═══════════════════════════════════════════════════════════════ */

/* Toggle Switch estilo iOS */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  transition: .4s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: .4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
  background-color: white;
}

/* Contenedor Gráfico PGA */
.pga-graph-container {
  width: 100%;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
}

.pga-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #f59e0b, #ef4444);
  transition: width 0.1s linear, background-color 0.1s linear;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE Y MÓVILES
   ═══════════════════════════════════════════════════════════════ */

#portrait-warning {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--text-primary);
}

.warning-content {
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (orientation: portrait) {
  #portrait-warning {
    display: flex;
  }
  #app-header, #app-main, #app-footer {
    display: none !important;
  }
}

@media (max-width: 1024px) {
  .glass-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    height: 100%;
    background: rgba(15, 23, 42, 0.95); /* Más oscuro para tapar canvas */
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
  }

  #panel-controls {
    left: 0;
  }

  #panel-info {
    right: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   MODALES Y BADGES
   ═══════════════════════════════════════════════════════════════ */

.version-badge {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.6rem;
  font-weight: 700;
  margin-left: 8px;
  vertical-align: middle;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.version-badge:hover {
  transform: scale(1.05);
  background: var(--accent-primary);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  padding: 0;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  transform: translateY(0);
  transition: transform 0.3s ease;
}

.modal-overlay.hidden .modal-content {
  transform: translateY(-20px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.1rem;
  margin: 0;
  color: var(--text-primary);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 60px);
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

.modal-body h3 {
  color: var(--text-primary);
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.modal-body ul {
  padding-left: 20px;
  margin-bottom: 0;
}

.modal-body li {
  margin-bottom: 8px;
}
