/**
 * styles.css
 * Sistema de diseño de interfaz para el LABORATORIO VIRTUAL DE LEVITACIÓN MAGNÉTICA.
 * Estética: Fondo oscuro (#050811), azul eléctrico (#3b82f6), cian (#06b6d4) y violeta (#8b5cf6),
 * paneles translúcidos (glassmorphism), controles accesibles y diseño responsive.
 */

:root {
  color-scheme: dark;
  --brand-color: #22d3ee;

  --bg-deep: #050811;
  --bg-panel: rgba(13, 20, 38, 0.78);
  --bg-panel-elevated: rgba(19, 29, 54, 0.85);
  --bg-card-inner: rgba(8, 13, 26, 0.72);

  --electric-blue: #3b82f6;
  --cyan-glow: #06b6d4;
  --cyan-bright: #22d3ee;
  --violet-accent: #8b5cf6;
  --violet-bright: #a855f7;

  --status-stable: #10b981;
  --status-unstable: #f59e0b;
  --status-insufficient: #ef4444;
  --status-disabled: #64748b;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --border-glass: rgba(56, 189, 248, 0.16);
  --border-subtle: rgba(255, 255, 255, 0.08);

  --ease-lab: cubic-bezier(0.2, 0, 0, 1);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 7px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 12% 10%, rgba(37, 99, 235, 0.18), transparent 38%),
    radial-gradient(circle at 88% 14%, rgba(139, 92, 246, 0.16), transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(6, 182, 212, 0.12), transparent 45%);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  accent-color: var(--brand-color);
  overflow-x: hidden;
}

/* ============================================================================
   ENCABEZADO CIENTÍFICO Y BARRA SUPERIOR
   ============================================================================ */
.lab-header {
  max-width: 1640px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0.75rem;
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding: 1.35rem 1.65rem;
  background: var(--bg-panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.lab-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--cyan-bright);
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.3);
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 0.55rem;
}

.eyebrow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan-bright);
  box-shadow: 0 0 10px var(--cyan-bright);
}

.lab-title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.55rem, 2.6vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(95deg, #ffffff 0%, #7dd3fc 52%, #c084fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lab-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.96rem;
  max-width: 720px;
}

.view-mode-switcher {
  display: inline-flex;
  background: rgba(5, 8, 17, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.28rem;
  gap: 0.28rem;
  align-self: center;
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.48rem 0.88rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    transform 150ms var(--ease-lab),
    background-color 180ms var(--ease-lab),
    color 180ms var(--ease-lab);
}

.view-btn:hover {
  color: var(--text-main);
  transform: scale(1.02);
}

.view-btn.active {
  background: linear-gradient(135deg, var(--electric-blue), var(--violet-accent));
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

/* ============================================================================
   SECCIÓN: EXPERIMENTOS PRECONFIGURADOS
   ============================================================================ */
.presets-section {
  max-width: 1640px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 0.75rem;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.section-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan-bright);
  margin: 0;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}

@media (max-width: 960px) {
  .presets-grid {
    grid-template-columns: 1fr;
  }
}

.preset-card {
  text-align: left;
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.15rem;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition:
    transform 180ms var(--ease-lab),
    border-color 180ms var(--ease-lab),
    box-shadow 180ms var(--ease-lab);
}

.preset-card:hover {
  transform: translateY(-2px) scale(1.01);
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 10px 24px rgba(6, 182, 212, 0.14);
}

.preset-card.active {
  border-color: var(--cyan-bright);
  background: linear-gradient(145deg, rgba(14, 30, 58, 0.88), rgba(24, 20, 56, 0.82));
  box-shadow: 0 0 22px rgba(34, 211, 238, 0.2);
}

.preset-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cyan-bright);
}

.preset-card strong {
  font-size: 0.95rem;
}

.preset-card span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================================
   LAYOUT PRINCIPAL: SIMULADORES (A y B) + CENTRO DE ANÁLISIS FÍSICO
   ============================================================================ */
.lab-workspace {
  max-width: 1640px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 2.5rem;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 1.35rem;
  align-items: start;
}

@media (max-width: 1280px) {
  .lab-workspace {
    grid-template-columns: 1fr;
  }
}

.simulators-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.simulator-module {
  background: var(--bg-panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 1.35rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
}

.module-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.module-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c084fc;
  display: block;
  margin-bottom: 0.2rem;
}

.module-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
}

.module-status-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.status-pill {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.status-stable {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.45);
}

.status-unstable {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.45);
}

.status-insufficient {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.45);
}

.status-disabled {
  background: rgba(100, 116, 139, 0.22);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.35);
}

.status-reason-text {
  font-size: 0.76rem;
  color: var(--text-muted);
  max-width: 420px;
  text-align: right;
}

/* Cuerpo interno de cada simulador: Escena 3D + Controles */
.module-body {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 960px) {
  .module-body {
    grid-template-columns: 1fr;
  }
}

.scene-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.viewport-3d-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.24);
  background: #060a14;
  box-shadow: inset 0 0 32px rgba(6, 182, 212, 0.08);
}

.viewport-3d {
  width: 100%;
  height: 410px;
  cursor: grab;
}

.viewport-3d:active {
  cursor: grabbing;
}

.viewport-overlay-legend {
  position: absolute;
  top: 0.65rem;
  left: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  pointer-events: none;
}

.legend-chip {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  background: rgba(6, 10, 20, 0.82);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.pole-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pole-n { background: #ef4444; }
.pole-s { background: #3b82f6; }
.vec-fg { background: #f59e0b; }
.vec-fmag { background: #06b6d4; }
.vec-vel { background: #a855f7; }

.camera-hint {
  position: absolute;
  bottom: 0.55rem;
  right: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(6, 10, 20, 0.78);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  pointer-events: none;
}

/* Barra de Botones de Acción del Simulador */
.sim-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-lab {
  flex: 1;
  min-width: 120px;
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    transform 120ms var(--ease-lab),
    background-color 160ms var(--ease-lab),
    border-color 160ms var(--ease-lab),
    box-shadow 160ms var(--ease-lab);
}

.btn-lab:hover {
  transform: scale(1.02);
  border-color: rgba(34, 211, 238, 0.45);
}

.btn-lab:active {
  transform: scale(0.97);
}

.btn-lab.is-active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.35), rgba(6, 182, 212, 0.28));
  border-color: var(--cyan-bright);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.22);
}

/* ============================================================================
   CONTROLES DESLIZANTES Y TELEMETRÍA EN TIEMPO REAL
   ============================================================================ */
.controls-column {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.sliders-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.58rem;
}

.control-slider-card {
  background: var(--bg-card-inner);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.slider-label-row label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.slider-live-val {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cyan-bright);
}

/* Range Slider Styling (Siguiendo modern-web-guidance: slider + brand-consistent-forms) */
input[type="range"] {
  --slider-track-size: 0.42rem;
  --slider-thumb-size: 1.08rem;
  --slider-track-radius: 999px;
  --slider-thumb-radius: 50%;
  --slider-track-color: rgba(148, 163, 184, 0.22);
  --slider-fill-color: #22d3ee;
  --slider-thumb-color: #38bdf8;
  --slider-direction: to right;

  --attr-min: attr(min type(<number>), 0);
  --attr-max: attr(max type(<number>), 100);
  --control-value: attr(value type(<number>), 50);
  --slider-progress: calc(
    progress(var(--control-value), var(--attr-min), var(--attr-max)) * 100%
  );

  appearance: none;
  inline-size: 100%;
  block-size: 1.65rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]:dir(rtl) {
  --slider-direction: to left;
}

@supports not (opacity: progress(1, 0, 100)) {
  input[type="range"] {
    --slider-progress: calc(
      (var(--control-value) - var(--attr-min)) /
      (var(--attr-max) - var(--attr-min)) * 100%
    );
  }
}

/* WebKit / Blink */
input[type="range"]::-webkit-slider-runnable-track {
  block-size: var(--slider-track-size);
  border: 0;
  border-radius: var(--slider-track-radius);
  background: linear-gradient(
    var(--slider-direction),
    var(--slider-fill-color) var(--slider-progress),
    var(--slider-track-color) var(--slider-progress)
  );
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  inline-size: var(--slider-thumb-size);
  block-size: var(--slider-thumb-size);
  margin-block-start: calc(
    (var(--slider-track-size) - var(--slider-thumb-size)) / 2
  );
  border: 2px solid #ffffff;
  border-radius: var(--slider-thumb-radius);
  background: var(--slider-thumb-color);
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.65);
}

/* Firefox */
input[type="range"]::-moz-range-track {
  block-size: var(--slider-track-size);
  border: 0;
  border-radius: var(--slider-track-radius);
  background: var(--slider-track-color);
}

input[type="range"]::-moz-range-progress {
  block-size: var(--slider-track-size);
  border-radius: var(--slider-track-radius);
  background: var(--slider-fill-color);
}

input[type="range"]::-moz-range-thumb {
  inline-size: var(--slider-thumb-size);
  block-size: var(--slider-thumb-size);
  border: 2px solid #ffffff;
  border-radius: var(--slider-thumb-radius);
  background: var(--slider-thumb-color);
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.65);
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--slider-fill-color);
  outline-offset: 4px;
}

@supports not (accent-color: var(--brand-color)) {
  input[type="range"]::-webkit-slider-runnable-track {
    background: linear-gradient(to right, var(--brand-color) var(--progress, 50%), #334155 var(--progress, 50%));
  }
}

/* Indicadores numéricos en tiempo real de cada simulador */
.telemetry-readout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.48rem;
  background: rgba(5, 8, 17, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem;
}

.readout-cell {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 7px;
  padding: 0.4rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.readout-cell span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.readout-cell strong {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.82rem;
  color: #e0f2fe;
}

/* ============================================================================
   PANEL LATERAL: CENTRO DE ANÁLISIS FÍSICO
   ============================================================================ */
.physics-analysis-aside {
  position: sticky;
  top: 1.25rem;
  background: var(--bg-panel-elevated);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(139, 92, 246, 0.32);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
}

.aside-header h2 {
  margin: 0.15rem 0 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: #f8fafc;
}

.analysis-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  background: rgba(5, 8, 17, 0.65);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.analysis-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.42rem 0.5rem;
  border-radius: 5px;
  cursor: pointer;
}

.analysis-tab-btn.active {
  background: rgba(139, 92, 246, 0.28);
  color: #f3e8ff;
  border: 1px solid rgba(168, 85, 247, 0.45);
}

.analysis-active-caption {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cyan-bright);
  margin: 0;
}

.equation-card {
  background: var(--bg-card-inner);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--cyan-bright);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.equation-card.eq-violet {
  border-left-color: var(--violet-bright);
}

.eq-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.eq-math {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.84rem;
  color: #f8fafc;
}

.eq-live {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.78rem;
  color: #bae6fd;
}

.formula-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Diagrama de Vectores en Tiempo Real (SVG) */
.vector-diagram-box {
  background: #060a14;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.vector-svg {
  width: 100%;
  max-width: 270px;
  height: 205px;
}

.analysis-note-box {
  font-size: 0.76rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  line-height: 1.45;
}

.diagnostic-callout {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.75rem;
  color: #e0f2fe;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
}

.lab-footer {
  max-width: 1640px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-subtle);
}

@media (prefers-reduced-motion: reduce) {
  .preset-card,
  .view-btn,
  .btn-lab {
    transition: none !important;
  }
}

