/* Estilos para el Simulador de tiempos de triatlón con transiciones */
:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-primary: #0b0f17;
  --bg-card: #111827;
  --bg-card-subtle: #1a2333;
  --bg-input: #1f293d;
  --border-color: #27354f;
  --border-focus: #0ea5e9;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-heading: #ffffff;
  
  /* Colores por disciplina de triatlón */
  --color-swim: #06b6d4;
  --color-t1: #64748b;
  --color-bike: #f59e0b;
  --color-t2: #64748b;
  --color-run: #10b981;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #0284c7;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-heading: #0f172a;
}

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

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.kpi-num {
  font-family: var(--font-heading);
}

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

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

.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  margin-bottom: 2rem;
}

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

/* Selector de distancias */
.distance-selector-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.btn-distance {
  flex: 1 1 calc(20% - 0.5rem);
  min-width: 120px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 0.75rem 0.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.2s ease;
}

.btn-distance:hover {
  border-color: var(--color-swim);
}

.btn-distance.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(16, 185, 129, 0.15));
  border-color: var(--color-swim);
  box-shadow: 0 0 0 1px var(--color-swim);
}

.dist-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
}

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

/* Presets rápidos */
.presets-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 0.75rem;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-md);
}

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

.btn-preset {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-preset:hover {
  background: var(--border-color);
  color: #fff;
}

.btn-preset.active {
  background: var(--color-swim);
  color: #fff;
  border-color: var(--color-swim);
}

/* Filas de sectores */
.sector-fieldset {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--bg-card-subtle);
}

.sector-legend {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sector-swim .sector-legend { color: var(--color-swim); }
.sector-t1 .sector-legend { color: var(--color-t1); }
.sector-bike .sector-legend { color: var(--color-bike); }
.sector-t2 .sector-legend { color: var(--color-t2); }
.sector-run .sector-legend { color: var(--color-run); }

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

@media (min-width: 640px) {
  .form-grid-2 { grid-template-columns: 1fr 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .form-grid-4 { grid-template-columns: repeat(4, 1fr); }
}

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

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

.time-duo {
  display: flex;
  gap: 0.5rem;
}

.time-subfield {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.time-subfield span {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.form-control {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem;
  padding: 0.55rem 0.75rem;
  min-height: 40px;
  font-family: var(--font-main);
  transition: border-color 0.2s ease;
}

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

select.form-control {
  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 12px center;
  padding-right: 40px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.86rem;
  cursor: pointer;
  margin-top: 0.25rem;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-swim);
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.5rem;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  width: 100%;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}

/* Resultados */
.results-box {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.hero-kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .hero-kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

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

.kpi-highlight {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(16, 185, 129, 0.1));
  border-color: var(--color-swim);
}

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

.kpi-num {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-heading);
  font-family: var(--font-mono);
  line-height: 1.1;
}

.kpi-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Barra de progreso segmentada */
.progress-bar-container {
  margin-bottom: 2rem;
}

.progress-segmented {
  display: flex;
  height: 24px;
  border-radius: 9999px;
  overflow: hidden;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
}

.progress-segment {
  height: 100%;
  transition: width 0.4s ease;
}

.segment-swim { background: var(--color-swim); }
.segment-t1 { background: var(--color-t1); }
.segment-bike { background: var(--color-bike); }
.segment-t2 { background: var(--color-t2); }
.segment-run { background: var(--color-run); }

.progress-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.82rem;
  justify-content: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Tarjetas de desglose de sectores */
.sectors-summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

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

.sector-summary-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  border-top: 4px solid var(--border-color);
}

.card-swim { border-top-color: var(--color-swim); }
.card-t1 { border-top-color: var(--color-t1); }
.card-bike { border-top-color: var(--color-bike); }
.card-t2 { border-top-color: var(--color-t2); }
.card-run { border-top-color: var(--color-run); }

.sector-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.sector-card-time {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-heading);
  margin-bottom: 0.5rem;
}

.sector-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: auto;
}

/* Cuadro nutricional */
.nutrition-box {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(16, 185, 129, 0.08));
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--color-bike);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 2rem;
}

.nutrition-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0 0 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

@media (min-width: 640px) {
  .nutrition-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.nutrition-item {
  background: var(--bg-card);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.nutrition-val {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-heading);
}

/* Plan copiable */
.plan-export-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1.5rem;
}

.plan-export-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.plan-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 1rem;
  line-height: 1.45;
  resize: vertical;
  min-height: 160px;
}

.btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  border-color: var(--color-swim);
  color: var(--color-swim);
}

.btn-copied {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #10b981 !important;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 99999;
}

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

.modal-dialog {
  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: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-heading);
}

.modal-btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
}

.modal-body {
  padding: 1.5rem;
  line-height: 1.6;
  font-size: 0.92rem;
  color: var(--text-main);
}

.error-msg {
  color: #ef4444;
  font-weight: 600;
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header,
  .fijate-footer,
  .tool-ad-sidebar,
  .tools-ad-banner-section,
  .distance-selector-bar,
  .presets-bar,
  .plan-export-header button,
  #form-triathlon,
  .modal-overlay {
    display: none !important;
  }
  .tool-layout,
  .tool-with-sidebar,
  .tool-main-content,
  .card-main {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }
}
