/* ==========================================================================
   Temporizador de ayuno intermitente con cronología celular - Estilos canónicos
   Fijate Tools - Responsive, Dark/Light Mode, Touch Friendly
   ========================================================================== */

:root {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #0ea5e9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-primary: #10b981;
  --accent-primary-hover: #059669;
  --accent-blue: #0ea5e9;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-danger: #ef4444;
  --accent-danger-hover: #dc2626;
  --ring-track: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --bg-primary: #0b1329;
  --bg-card: #131f37;
  --bg-card-hover: #1c2b4d;
  --bg-input: #0f1a30;
  --border-color: #1e2e4f;
  --border-focus: #38bdf8;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent-primary: #10b981;
  --accent-primary-hover: #34d399;
  --accent-blue: #38bdf8;
  --accent-purple: #a78bfa;
  --accent-amber: #fbbf24;
  --accent-danger: #f87171;
  --accent-danger-hover: #ef4444;
  --ring-track: #1e2c4a;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  width: 100%;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--text-primary);
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Layout */
.main-wrapper {
  flex: 1 0 auto;
  width: 100%;
}

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

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

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Introducción / Encabezado */
.intro-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.intro-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-primary);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.intro-title {
  font-size: 1.6rem;
  line-height: 1.25;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.intro-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 800px;
}

/* Panel de control superior */
.timer-controller-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: flex-end;
}

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

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

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 44px;
  padding: 0 40px 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-primary);
  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='%2364748b' 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;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.form-select option,
.form-select optgroup {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.form-input-datetime {
  height: 44px;
  padding: 0 0.85rem;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-primary);
  display: none;
}

.btn-actions-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 44px;
  padding: 0 1.5rem;
  background: var(--accent-primary);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 44px;
  padding: 0 1.5rem;
  background: var(--accent-danger);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: var(--accent-danger-hover);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 44px;
  padding: 0 1rem;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Área central del temporizador (reloj + datos biológicos) */
.timer-dashboard {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  align-items: center;
}

.timer-visual-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.timer-canvas-box {
  position: relative;
  width: 280px;
  height: 280px;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas-timer {
  width: 280px;
  height: 280px;
  max-width: 100%;
  display: block;
}

/* Información del estado biológico */
.timer-info-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.hud-tiles-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.hud-tile {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hud-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.hud-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tarjeta de estado celular actual */
.current-stage-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 1.2rem;
}

.current-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.current-stage-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.current-stage-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text-primary);
}

.current-stage-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Sección de la Cronología Biológica */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

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

.section-title {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Lista de etapas celulares */
.stages-timeline-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.stage-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  transition: all 0.2s ease;
}

.stage-card.stage-current {
  border-color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.05);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.stage-card.stage-past {
  opacity: 0.85;
  border-left: 3px solid var(--accent-primary);
}

.stage-card.stage-future {
  opacity: 0.7;
}

.stage-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.stage-time-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.stage-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

.stage-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.stage-card-detail {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Buscador de bebidas */
.beverage-search-box {
  margin-bottom: 1.25rem;
}

.beverage-input-search {
  width: 100%;
  height: 44px;
  padding: 0 1rem;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

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

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

.beverage-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.beverage-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.beverage-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.bev-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-safe {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-breaks {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.beverage-note {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* FAQ Acordeón */
.faq-accordion-item {
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}

.faq-accordion-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-question {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.faq-answer {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Responsivo Móvil */
@media (max-width: 900px) {
  .timer-dashboard {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 1.25rem 1rem;
    gap: 1.25rem;
  }

  .timer-visual-col {
    margin: 0 auto;
    width: 100%;
  }

  .hud-tiles-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .current-stage-card {
    text-align: left;
  }

  .controls-grid {
    grid-template-columns: 1fr;
  }

  .btn-actions-row {
    flex-direction: column;
  }

  .btn-primary, .btn-danger, .btn-outline {
    width: 100%;
    min-height: 40px;
  }

  .tool-layout {
    padding: 0 0.75rem;
    margin: 1rem auto 2rem;
  }
}

@media (max-width: 520px) {
  .hud-tiles-grid {
    grid-template-columns: 1fr;
  }

  .timer-dashboard {
    padding: 1rem 0.75rem;
  }
}

/* Estilos para impresión */
@media print {
  header, footer, .tool-ad-sidebar, .tools-ad-banner-section, .btn-actions-row, .beverage-search-box {
    display: none !important;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  .section-card, .timer-controller-card, .timer-dashboard {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
  }
}
