/**
 * Fijate Tools - Estilos para el Simulador 3D de Relatividad Especial
 * Diseño espacial Midnight Slate, HUD futurista, controles táctiles y Dark/Light mode.
 */

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

  /* Paleta Cósmica Relativista */
  --bg-deep: #080c14;
  --bg-surface: #0f172a;
  --bg-card: #141e33;
  --bg-input: #1a2642;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: #38bdf8;

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

  --accent-cyan: #38bdf8;
  --accent-purple: #a855f7;
  --accent-amber: #fbbf24;
  --accent-rose: #f43f5e;
  --accent-green: #34d399;

  --glow-cyan: rgba(56, 189, 248, 0.25);
  --glow-purple: rgba(168, 85, 247, 0.25);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --transition-fast: 0.18s ease;
}

[data-theme="light"] {
  --bg-deep: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #f1f5f9;
  --bg-input: #e2e8f0;
  --border-color: #cbd5e1;
  --border-focus: #0284c7;

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

  --accent-cyan: #0284c7;
  --accent-purple: #9333ea;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --accent-green: #059669;

  --glow-cyan: rgba(2, 132, 199, 0.15);
  --glow-purple: rgba(147, 51, 234, 0.15);

  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

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

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

.text-mono {
  font-family: var(--font-mono);
}

/* =========================================================================
   LAYOUT PRINCIPAL CANÓNICO
   ========================================================================= */
.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.25rem auto 3rem;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* =========================================================================
   SECCIÓN DE SIMULACIÓN Y VIEWPORT 3D
   ========================================================================= */
.sim-viewport-section {
  position: relative;
  width: 100%;
  background: #000000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
}

.canvas-container {
  position: relative;
  width: 100%;
  height: 65vh;
  min-height: 440px;
  max-height: 720px;
  background-color: #030712;
  cursor: grab;
}

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

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

/* HUD Overlay superpuesto */
.hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
}

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

.hud-badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hud-badge {
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

.hud-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.hud-actions-group {
  display: flex;
  gap: 0.5rem;
}

.btn-hud {
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
  min-height: 40px;
}

.btn-hud:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-hud.active {
  background: var(--accent-cyan);
  color: #04101e;
  border-color: var(--accent-cyan);
  font-weight: 600;
}

/* Telemetría inferior HUD */
.hud-bottom-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6rem;
  pointer-events: auto;
}

.hud-metric-card {
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
}

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

.hud-metric-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  margin-top: 0.15rem;
}

.hud-metric-sub {
  font-size: 0.7rem;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  margin-top: 0.1rem;
}

/* =========================================================================
   PANEL DE CONTROLES PRINCIPALES Y ACELERADOR
   ========================================================================= */
.control-dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .control-dashboard {
    grid-template-columns: 1.35fr 1fr;
  }
}

.control-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

/* Slider de velocidad relativista */
.speed-slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.speed-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.speed-display-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speed-number-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  width: 95px;
  text-align: right;
  min-height: 40px;
}

.speed-number-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.slider-relativity {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #38bdf8 0%, #a855f7 65%, #f43f5e 100%);
  outline: none;
  margin: 0.5rem 0;
  cursor: pointer;
}

.slider-relativity::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--accent-purple);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.7);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.slider-relativity::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Botones presets de velocidad */
.speed-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
}

@media (min-width: 600px) {
  .speed-presets-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

.btn-preset-speed {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-preset-speed:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-preset-speed.active {
  background: var(--accent-purple);
  color: #ffffff;
  border-color: var(--accent-purple);
  box-shadow: 0 0 10px var(--glow-purple);
}

/* Botones de acción rápida */
.speed-action-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.btn-action-speed {
  width: 100%;
  min-height: 42px;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

.btn-warp {
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

.btn-warp:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.btn-brake {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-brake:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: var(--accent-rose);
  color: var(--accent-rose);
}

/* Conmutadores de efectos relativistas */
.effects-toggles-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

@media (min-width: 500px) {
  .effects-toggles-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-height: 42px;
}

.toggle-label-area {
  display: flex;
  flex-direction: column;
}

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

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

/* Switch toggle */
.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;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: .25s ease;
  border-radius: 24px;
}

.slider-switch:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s ease;
  border-radius: 50%;
}

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

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

/* Selectores de Escena y Entorno */
.select-full {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  min-height: 40px;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 40px 0.5rem 0.75rem;
  font-family: var(--font-main);
  font-size: 0.9rem;
  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%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
  appearance: none;
}

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

/* =========================================================================
   MÓDULO DE LA PARADOJA DE LOS GEMELOS Y MINKOWSKI
   ========================================================================= */
.twins-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.twins-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .twins-grid {
    grid-template-columns: 1.1fr 1fr;
  }
}

.twin-comparison-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.twin-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.twin-card-earth {
  border-left: 4px solid var(--accent-cyan);
}

.twin-card-ship {
  border-left: 4px solid var(--accent-purple);
}

.twin-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.twin-avatar-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.twin-card-earth .twin-avatar-icon {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
}

.twin-card-ship .twin-avatar-icon {
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-purple);
}

.twin-age-val {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
}

.twin-time-val {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.twin-summary-banner {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.minkowski-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.minkowski-canvas-wrapper {
  position: relative;
  width: 100%;
  background: #080c14;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
  height: 290px;
}

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

/* =========================================================================
   SECCIÓN EDUCATIVA Y GUÍA TEÓRICA
   ========================================================================= */
.edu-guide-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

@media (min-width: 768px) {
  .edu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.edu-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.edu-card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.edu-card-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.formula-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-amber);
  margin-top: 0.35rem;
}

/* =========================================================================
   ACORDEÓN DE PREGUNTAS FRECUENTES (FAQ)
   ========================================================================= */
.faq-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.faq-item:hover {
  border-color: rgba(56, 189, 248, 0.4);
}

.faq-question {
  width: 100%;
  padding: 1rem 1.25rem;
  background: none;
  border: none;
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
}

.faq-icon {
  transition: transform var(--transition-fast);
  color: var(--text-dim);
}

.faq-item[open] .faq-icon {
  transform: rotate(180deg);
  color: var(--accent-cyan);
}

.faq-answer {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* =========================================================================
   MODAL DE CONFIRMACIÓN / GUÍA TEÓRICA
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

.modal-backdrop.active {
  display: flex;
}

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

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

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  min-width: 40px;
}

.btn-close-modal:hover {
  color: #ffffff;
  background: var(--bg-input);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-body h4 {
  font-family: var(--font-heading);
  color: var(--accent-cyan);
  margin-top: 0.5rem;
}

/* =========================================================================
   PUBLICIDAD ADSENSE CANÓNICA
   ========================================================================= */
.tools-ad-banner-section {
  width: 100%;
  margin: 1rem 0;
  display: flex;
  justify-content: center;
}
