/**
 * Test de edad auditiva - Estilos corporativos Midnight Slate
 * Fijate Tools
 */

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

  /* Paleta base en modo oscuro */
  --bg-page: #0b0f17;
  --bg-card: #111827;
  --bg-card-subtle: #1e293b;
  --bg-input: #0f172a;
  --border-color: #1e293b;
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-cyan: #38bdf8;
  --accent-cyan-hover: #0ea5e9;
  --accent-glow: rgba(56, 189, 248, 0.25);

  --accent-green: #22c55e;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-violet: #8b5cf6;

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

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.35);
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #0284c7;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --accent-cyan: #0284c7;
  --accent-cyan-hover: #0369a1;
  --accent-glow: rgba(2, 132, 199, 0.2);

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

/* 1. Layout general */
body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  line-height: 1.5;
}

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

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

.text-muted {
  color: var(--text-muted);
}

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* 2. Tarjetas y contenedores */
.card-main,
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 2rem;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .card-main,
  .tool-card {
    padding: 2rem;
  }
}

.hero-box {
  text-align: center;
  margin-bottom: 1.75rem;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-bottom: 0.75rem;
}

.hero-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
  color: var(--text-main);
}

@media (min-width: 768px) {
  .hero-title {
    font-size: 2.25rem;
  }
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto;
}

/* 3. Barra de calibración y ajustes */
.calibration-bar {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 2rem;
}

.calibration-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-items: center;
}

@media (min-width: 768px) {
  .calibration-grid {
    grid-template-columns: auto 1fr auto;
  }
}

.calib-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.calib-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.select-custom {
  width: 100%;
  min-width: 160px;
  height: 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0 2rem 0 0.75rem;
  font-size: 0.9rem;
  appearance: none;
  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 0.75rem center;
  background-size: 16px;
  cursor: pointer;
  box-sizing: border-box;
}

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

.vol-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-slider {
  flex: 1 1 0%;
  height: 6px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  outline: none;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 42px;
  padding: 0 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

/* 4. Escenario principal de barrido */
.sweep-stage {
  background: var(--bg-card-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 2rem;
}

.live-display-box {
  margin-bottom: 1.5rem;
}

.live-freq-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.live-freq-val {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent-cyan);
  line-height: 1.1;
  text-shadow: 0 0 20px var(--accent-glow);
}

@media (min-width: 768px) {
  .live-freq-val {
    font-size: 4.25rem;
  }
}

.live-age-preview {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-top: 0.35rem;
}

/* Osciloscopio */
.canvas-wrapper {
  max-width: 580px;
  margin: 0 auto 1.5rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #020617;
}

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

/* Barra de progreso de frecuencia */
.progress-track {
  max-width: 580px;
  height: 8px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  margin: 0 auto 1.75rem;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8 0%, #a855f7 70%, #ec4899 100%);
  border-radius: var(--radius-full);
  transition: width 0.08s linear;
}

/* Botones de acción principales */
.btn-action-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 54px;
  padding: 0.85rem 2.25rem;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: none;
  border-radius: var(--radius-full);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-action-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(2, 132, 199, 0.55);
}

.btn-action-primary:active {
  transform: translateY(0);
}

/* El botón gigante viral: ¡He dejado de oírlo! */
.btn-action-stop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 64px;
  padding: 1rem 2.75rem;
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  border: none;
  border-radius: var(--radius-full);
  color: #ffffff;
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(225, 29, 72, 0.6);
  animation: pulseStop 1.4s infinite alternate;
  user-select: none;
}

@keyframes pulseStop {
  from {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(225, 29, 72, 0.5);
  }
  to {
    transform: scale(1.04);
    box-shadow: 0 0 35px rgba(225, 29, 72, 0.8);
  }
}

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

.sweep-instruction {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

.sweep-instruction kbd {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

/* 5. Tarjeta de resultado viral */
.results-card {
  display: none;
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
  border: 2px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow-glow);
  margin-bottom: 2.5rem;
  text-align: center;
}

[data-theme="light"] .results-card {
  background: linear-gradient(180deg, #ffffff 0%, #f0f9ff 100%);
  border-color: #38bdf8;
}

.res-header {
  margin-bottom: 1.5rem;
}

.res-eyebrow {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
}

.res-age-huge {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0.25rem 0;
  line-height: 1.1;
}

@media (min-width: 768px) {
  .res-age-huge {
    font-size: 3.75rem;
  }
}

.res-freq-cutoff {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
}

.res-badge-wrap {
  margin: 1.25rem 0;
}

.res-badge {
  display: inline-block;
  padding: 0.45rem 1.25rem;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 700;
}

.badge-prodigy { background: rgba(34, 197, 94, 0.2); color: #22c55e; border: 1px solid #22c55e; }
.badge-teen { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid #38bdf8; }
.badge-youth { background: rgba(139, 92, 246, 0.2); color: #a855f7; border: 1px solid #a855f7; }
.badge-adult-young { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid #60a5fa; }
.badge-adult-mid { background: rgba(20, 184, 166, 0.2); color: #14b8a6; border: 1px solid #14b8a6; }
.badge-mature { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border: 1px solid #f59e0b; }
.badge-senior-start { background: rgba(249, 115, 22, 0.2); color: #f97316; border: 1px solid #f97316; }
.badge-senior { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid #f87171; }
.badge-elder { background: rgba(156, 163, 175, 0.2); color: #9ca3af; border: 1px solid #9ca3af; }
.badge-elder-plus { background: rgba(100, 116, 139, 0.2); color: #94a3b8; border: 1px solid #94a3b8; }

.res-desc-box {
  max-width: 640px;
  margin: 0 auto 1.75rem;
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Gráfico de espectro comparativo */
.spectrum-bar-wrap {
  max-width: 640px;
  margin: 0 auto 2rem;
  text-align: left;
}

.spectrum-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
}

.spectrum-bar {
  height: 14px;
  background: linear-gradient(90deg, #94a3b8 0%, #f97316 25%, #f59e0b 45%, #60a5fa 65%, #a855f7 85%, #22c55e 100%);
  border-radius: var(--radius-full);
  position: relative;
  margin-bottom: 0.5rem;
}

.spectrum-pin {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 26px;
  background: #ffffff;
  border: 4px solid var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: left 0.4s ease;
}

.spectrum-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Acciones en resultados */
.res-actions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.75rem;
}

.btn-primary-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 48px;
  padding: 0 1.75rem;
  background: var(--accent-cyan);
  border: none;
  border-radius: var(--radius-sm);
  color: #0b0f17;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.btn-primary-share:hover {
  opacity: 0.9;
}

/* Formulario para añadir al duelo */
.duel-add-form {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  max-width: 520px;
  margin: 0 auto;
}

.duel-add-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--text-main);
}

.duel-input-row {
  display: flex;
  gap: 0.5rem;
}

.input-text {
  flex: 1 1 0%;
  height: 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0 1rem;
  font-size: 0.95rem;
}

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

.btn-add-duel {
  height: 44px;
  padding: 0 1.25rem;
  background: var(--accent-green);
  border: none;
  border-radius: var(--radius-sm);
  color: #0b0f17;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

/* 6. Modo comprobación paso a paso */
.step-check-section {
  margin-bottom: 2.5rem;
}

.section-heading-sm {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--text-main);
}

.section-desc-sm {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.step-buttons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.btn-step-freq {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 0.5rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 64px;
}

.btn-step-freq:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

.btn-step-freq.is-playing {
  border-color: var(--accent-rose);
  background: rgba(225, 29, 72, 0.15);
  box-shadow: 0 0 15px rgba(225, 29, 72, 0.4);
}

.step-freq-num {
  font-size: 1.05rem;
  font-weight: 700;
}

.step-freq-age {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.step-test-status {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  min-height: 1.4rem;
  font-weight: 600;
}

/* 7. Clasificación familiar y amigos (Duelo) */
.duel-leaderboard-section {
  margin-bottom: 2.5rem;
}

.duel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.duel-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.duel-table th,
.duel-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.duel-table th {
  background: rgba(15, 23, 42, 0.5);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.duel-table tr:last-child td {
  border-bottom: none;
}

.duel-rank {
  font-weight: 700;
  white-space: nowrap;
}

.duel-empty-msg {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.btn-remove-duel {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.btn-remove-duel:hover {
  color: var(--accent-rose);
  background: rgba(225, 29, 72, 0.1);
}

.btn-text-sm {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.btn-text-sm:hover {
  color: var(--accent-rose);
}

/* 8. Sección didáctica y FAQ (SEO) */
.guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .guide-section {
    padding: 2.5rem 2rem;
  }
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

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

.guide-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

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

.guide-card-p {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

/* Acordeón FAQ */
.faq-wrap {
  margin-top: 2rem;
}

.faq-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  overflow: hidden;
  background: var(--bg-card-subtle);
}

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

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

/* 9. Modales accesibles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
  padding: 1.75rem;
  position: relative;
  box-sizing: border-box;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

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

.card-preview-wrap {
  width: 100%;
  margin-bottom: 1.25rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #020617;
}

#card-preview-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.modal-actions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 480px) {
  .modal-actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 10. Adaptabilidad en pantallas móviles */
@media (max-width: 768px) {
  .tool-layout {
    padding: 0 0.75rem;
    margin-top: 1rem;
  }

  .card-main,
  .tool-card {
    padding: 1.25rem;
  }

  .btn-action-primary,
  .btn-action-stop {
    width: 100%;
    box-sizing: border-box;
  }

  .duel-input-row {
    flex-direction: column;
  }

  .btn-add-duel {
    width: 100%;
  }

  .res-actions-grid button {
    width: 100%;
  }
}
