/* ==========================================================================
   Fijate Tools - Simulador de agujero negro 3D y lente gravitacional
   Paleta: Midnight Slate Cósmica, Acento Azul Einstein (#38bdf8) y Ámbar de Acreción (#f59e0b)
   ========================================================================== */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Tema Oscuro por defecto (Cosmos profundo) */
  --bg-space: #05070e;
  --bg-card: #0b0f19;
  --bg-card-sub: #111827;
  --bg-panel: rgba(11, 15, 25, 0.85);
  --bg-panel-border: rgba(56, 189, 248, 0.18);
  --bg-input: #151d30;
  --bg-input-hover: #1c2742;

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

  --primary-color: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-light: rgba(56, 189, 248, 0.12);

  --accent-accretion: #f59e0b;
  --accent-accretion-hover: #d97706;
  --accent-accretion-light: rgba(245, 158, 11, 0.14);

  --accent-doppler-blue: #38bdf8;
  --accent-doppler-red: #ef4444;

  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #38bdf8;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.18);
}

/* Tema Claro */
[data-theme="light"],
body.light-theme {
  --bg-space: #f0f4f8;
  --bg-card: #ffffff;
  --bg-card-sub: #f8fafc;
  --bg-panel: rgba(255, 255, 255, 0.92);
  --bg-panel-border: rgba(14, 165, 233, 0.25);
  --bg-input: #e2e8f0;
  --bg-input-hover: #cbd5e1;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --primary-color: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: rgba(2, 132, 199, 0.1);

  --accent-accretion: #d97706;
  --accent-accretion-hover: #b45309;
  --accent-accretion-light: rgba(217, 119, 6, 0.12);

  --border-color: #e2e8f0;
  --border-focus: #0284c7;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.12);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-space);
  color: var(--text-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title {
  font-family: var(--font-heading);
  letter-spacing: -0.015em;
  font-weight: 700;
}

.mono,
code,
.telemetry-val,
.stat-val {
  font-family: var(--font-mono);
}

/* ==========================================================================
   Contenedor Principal de la Herramienta
   ========================================================================== */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

@media (max-width: 768px) {
  .card-main {
    padding: 1rem;
    gap: 1.25rem;
  }
}

/* ==========================================================================
   Barra de Presets Celestes Rápidos
   ========================================================================== */
.presets-bar-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.presets-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
  width: 100%;
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 52px;
  text-align: left;
}

.preset-btn:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
  transform: translateY(-2px);
}

.preset-btn.active {
  border-color: var(--primary-color);
  background: var(--primary-light);
  box-shadow: var(--shadow-glow);
}

.preset-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.preset-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* ==========================================================================
   Viewport 3D Inmersivo WebGL
   ========================================================================== */
.viewport-section {
  position: relative;
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #020307;
  border: 1px solid var(--border-color);
  box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.8);
}

.canvas-container {
  position: relative;
  width: 100%;
  height: 560px;
  min-height: 380px;
  max-height: 75vh;
  cursor: grab;
  touch-action: none;
}

.canvas-container:active {
  cursor: grabbing;
}

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

/* HUD Overlay sobre Canvas */
.viewport-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.hud-telemetry-badge {
  background: rgba(5, 7, 14, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  pointer-events: auto;
}

.hud-target-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hud-target-status {
  font-size: 0.75rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.hud-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.hud-status-dot.infall {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse-infall 1s infinite alternate;
}

@keyframes pulse-infall {
  0% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 1; }
}

.hud-actions {
  display: flex;
  gap: 0.4rem;
  pointer-events: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-hud {
  height: 38px;
  min-height: 38px;
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(11, 15, 25, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-hud:hover {
  background: var(--bg-card-sub);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-hud.btn-infall-action {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.btn-hud.btn-infall-action:hover {
  background: rgba(245, 158, 11, 0.35);
  border-color: #f59e0b;
}

.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
}

.hud-bottom-info {
  background: rgba(5, 7, 14, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  pointer-events: auto;
}

.hud-fps-box {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.hud-fps-val {
  font-weight: 700;
  color: #10b981;
}

/* ==========================================================================
   Workspace Ergonómico en 2 Columnas
   ========================================================================== */
.workspace-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  width: 100%;
}

@media (max-width: 992px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

/* Bloques de Configuración y Telemetría */
.panel-box {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.panel-title-icon {
  color: var(--primary-color);
}

/* Grupos de Control */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.control-val-badge {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--primary-color);
}

.control-help {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Sliders con estilo moderno */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: var(--bg-input);
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
  cursor: pointer;
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 2px solid #ffffff;
  cursor: pointer;
}

/* Selectores Canónicos */
select.control-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  min-height: 42px;
  padding: 0 40px 0 0.85rem;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-family: var(--font-main);
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

select.control-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

select.control-select option {
  background-color: #0b0f19;
  color: #f1f5f9;
}

[data-theme="light"] select.control-select option,
body.light-theme select.control-select option {
  background-color: #ffffff;
  color: #0f172a;
}

/* Toggles e Interruptores */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  min-height: 44px;
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.toggle-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.toggle-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

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

.slider-switch {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-input);
  transition: 0.25s;
  border-radius: 24px;
  border: 1px solid var(--border-color);
}

.slider-switch::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.25s;
  border-radius: 50%;
}

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

input:checked + .slider-switch::before {
  transform: translateX(20px);
}

/* ==========================================================================
   Tarjetas de Telemetría y Ecuaciones Calculadas
   ========================================================================== */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

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

.telemetry-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  overflow: hidden;
}

.telemetry-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--primary-color);
}

.telemetry-card.highlight::before {
  background: var(--accent-accretion);
}

.telemetry-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.telemetry-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.telemetry-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.telemetry-unit {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.telemetry-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Tarjeta especial de Dilatación Temporal / Espaguetización */
.relativistic-effect-box {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), rgba(245, 158, 11, 0.05));
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.relativistic-effect-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.relativistic-effect-text {
  font-size: 0.82rem;
  color: var(--text-main);
  line-height: 1.45;
}

.relativistic-highlight {
  font-weight: 700;
  color: var(--accent-accretion);
}

/* ==========================================================================
   Sección Educativa y Teórica (Relatividad General)
   ========================================================================== */
.educational-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.75rem;
}

.educational-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.edu-card {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

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

.edu-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  color: var(--primary-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.edu-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
}

.edu-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.edu-card-formula {
  margin-top: 0.35rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--primary-color);
}

/* ==========================================================================
   Modales Canónicos (Sin alerts)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(5, 7, 14, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-modal-close {
  width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal-close:hover {
  background: var(--primary-light);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.55;
}

/* Modo Pantalla Completa */
.canvas-container.fullscreen-mode {
  position: fixed;
  inset: 0;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  z-index: 9990;
  border-radius: 0;
}
