/* =====================================================================
   Interpretador de Prueba de Esfuerzo y Ergoespirometría Deportiva
   Fijate Tools - Hoja de Estilos Corporativa (Midnight Slate)
   ===================================================================== */

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

  /* Paleta Base Oscura (Midnight Slate) */
  --bg-page: #0b0f17;
  --bg-card: #131b26;
  --bg-card-hover: #182332;
  --bg-input: #1a2434;
  --border-subtle: #233144;
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-bright: #ffffff;

  --accent-blue: #3b82f6;
  --accent-teal: #06b6d4;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.5);

  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-bright: #020817;

  --shadow-card: 0 4px 16px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px -4px rgba(0, 0, 0, 0.1);
}

/* Base & Contención */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  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;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-bright);
  margin-top: 0;
  letter-spacing: -0.015em;
  font-weight: 700;
}

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

.font-bold {
  font-weight: 700;
}

/* Layout Canónico */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

.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%;
}

/* Bloque Hero y Descripción */
.tool-intro-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.75rem 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.tool-intro-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.tool-title-group h2 {
  font-size: 1.65rem;
  margin-bottom: 0.5rem;
  line-height: 1.25;
}

.tool-title-group p {
  color: var(--text-muted);
  font-size: 0.98rem;
  margin: 0;
  max-width: 760px;
  line-height: 1.55;
}

.btn-pill-help {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-pill-help:hover {
  background: var(--accent-blue);
  color: #ffffff;
}

/* Presets rápidos */
.preset-bar {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

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

.presets-container {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-preset {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-preset:hover {
  border-color: var(--accent-blue);
  background: var(--bg-card-hover);
  color: var(--accent-blue);
}

.btn-preset.is-active {
  background: rgba(59, 130, 246, 0.18);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  font-weight: 600;
}

/* Tarjetas y Formulario */
.calculator-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.75rem 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-card);
}

.card-section-title {
  font-size: 1.15rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-bright);
}

.card-section-title svg {
  color: var(--accent-blue);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.form-grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

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

.label-hint {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}

.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-unit input,
.form-group select,
.form-group input[type="text"],
.form-group input[type="number"] {
  width: 100%;
  min-height: 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.85rem;
  color: var(--text-bright);
  font-family: var(--font-main);
  font-size: 0.95rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-with-unit input {
  padding-right: 3.5rem;
  font-family: var(--font-mono);
}

.input-unit {
  position: absolute;
  right: 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  pointer-events: none;
  font-weight: 500;
}

.input-with-unit input:focus,
.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Selector de Modalidad (Segmented Control) */
.modality-selector {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 4px;
  gap: 4px;
  margin-bottom: 1.5rem;
}

.modality-option {
  position: relative;
  cursor: pointer;
}

.modality-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.modality-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.modality-option input:checked + .modality-label {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* Acordeón de Parámetros Avanzados / Clínicos */
.details-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  margin-top: 1rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

details[open] .details-toggle {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}

.details-content {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  padding: 1.25rem;
}

/* =====================================================================
   Sección de Resultados y Diagnóstico
   ===================================================================== */
#results-section {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPIs principales */
.kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--border-subtle);
}

.kpi-card-vo2::before { background: linear-gradient(90deg, #3b82f6, #06b6d4); }
.kpi-card-cardio::before { background: linear-gradient(90deg, #ef4444, #f59e0b); }
.kpi-card-power::before { background: linear-gradient(90deg, #10b981, #06b6d4); }

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

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

.kpi-val-group {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.kpi-val {
  font-size: 2.25rem;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--text-bright);
  line-height: 1;
}

.kpi-unit {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  margin-top: 0.35rem;
}

.badge-score-6 { background: rgba(16, 185, 129, 0.18); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-score-5 { background: rgba(6, 182, 212, 0.18); color: #06b6d4; border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-score-4 { background: rgba(59, 130, 246, 0.18); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-score-3 { background: rgba(245, 158, 11, 0.18); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-score-2, .badge-score-1 { background: rgba(239, 68, 68, 0.18); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }

.kpi-footer-metric {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  display: flex;
  justify-content: space-between;
}

/* Banners de Diagnóstico Fisiológico */
.diag-banner {
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid transparent;
}

.diag-banner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.diag-banner-header h4 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-bright);
}

.diag-banner p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-main);
}

.diag-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  text-transform: uppercase;
}

/* Estados de RER */
.status-valid, .status-valid-high {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
}
.status-valid .diag-tag, .status-valid-high .diag-tag {
  background: var(--accent-green);
  color: #ffffff;
}

.status-submaximal {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
}
.status-submaximal .diag-tag {
  background: var(--accent-red);
  color: #ffffff;
}

.status-moderate {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
}
.status-moderate .diag-tag {
  background: var(--accent-yellow);
  color: #0f172a;
}

/* Estados de Agujero Aeróbico */
.gap-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.35);
}
.gap-warning .diag-tag {
  background: var(--accent-yellow);
  color: #000000;
}

.gap-success {
  background: rgba(6, 182, 212, 0.08);
  border-color: rgba(6, 182, 212, 0.35);
}
.gap-success .diag-tag {
  background: var(--accent-teal);
  color: #ffffff;
}

.gap-info {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.35);
}
.gap-info .diag-tag {
  background: var(--accent-blue);
  color: #ffffff;
}

/* Bloque visual de umbrales */
.thresholds-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.threshold-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  position: relative;
}

.threshold-box-vt1 { border-top: 4px solid var(--accent-green); }
.threshold-box-vt2 { border-top: 4px solid var(--accent-red); }

.threshold-badge {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}

.threshold-box-vt1 .threshold-badge { color: var(--accent-green); }
.threshold-box-vt2 .threshold-badge { color: var(--accent-red); }

.threshold-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.threshold-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.92rem;
}

.threshold-metric-row:last-child {
  border-bottom: none;
}

.threshold-metric-row .metric-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-bright);
}

/* Tablas de Zonas de Entrenamiento */
.zones-table-wrapper {
  overflow-x: auto;
  margin: 1.25rem 0 2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

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

.zones-table th {
  background: var(--bg-input);
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: var(--text-bright);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.zones-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

.zones-table tr:hover td {
  background: var(--bg-card-hover);
}

.metric-pill {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-bright);
}

.zone-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.zone-name-cell {
  display: flex;
  align-items: center;
}

.zone-subname {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
}

.cell-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  max-width: 380px;
  line-height: 1.45;
}

/* Barra de Acciones del Informe */
.report-actions-bar {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.btn-action-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent-blue);
  color: #ffffff;
  border: none;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  transition: all var(--transition-fast);
}

.btn-action-primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.btn-action-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

/* Modales Accesibles (Sin window.alert) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

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

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.35rem;
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

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

/* Guía SEO y FAQ */
.seo-guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2.25rem;
  margin-top: 3rem;
  line-height: 1.65;
}

.seo-guide-section h2 {
  font-size: 1.45rem;
  margin-bottom: 1rem;
}

.seo-guide-section h3 {
  font-size: 1.15rem;
  margin-top: 1.75rem;
  margin-bottom: 0.65rem;
}

.seo-guide-section p, .seo-guide-section li {
  color: var(--text-main);
  font-size: 0.95rem;
}

.faq-details {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 0.85rem;
  background: var(--bg-input);
}

.faq-summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-bright);
}

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

/* Estilos de Impresión */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header,
  .fijate-footer,
  .tool-ad-sidebar,
  .tools-ad-banner-section,
  .preset-bar,
  .report-actions-bar,
  .affiliate-showcase-container {
    display: none !important;
  }
  .tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .kpi-card, .threshold-box, .zones-table-wrapper, .calculator-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
}

/* Responsividad Móvil */
@media (max-width: 768px) {
  .thresholds-split {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .tool-intro-card, .calculator-card {
    padding: 1.25rem;
  }
  .kpis-grid {
    grid-template-columns: 1fr;
  }
  .report-actions-bar {
    justify-content: stretch;
  }
  .report-actions-bar button {
    width: 100%;
    justify-content: center;
  }
}
