/* ==========================================================================
   Asistente de hipoglucemia y regla del 15 - fijate.com
   Estilos canónicos con temporizador circular y diseño de urgencias clínicas
   ========================================================================== */

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

  /* Tema claro */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #dc2626;

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

  --primary: #dc2626;
  --primary-hover: #b91c1c;
  --primary-light: #fee2e2;

  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  --bg-app: #0b0f17;
  --bg-card: #131b29;
  --bg-card-subtle: #1c2638;
  --border-color: #26334a;
  --border-focus: #f87171;

  --text-main: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-subtle: #94a3b8;

  --primary: #f87171;
  --primary-hover: #ef4444;
  --primary-light: rgba(239, 68, 68, 0.18);

  --success: #4ade80;
  --success-light: rgba(74, 222, 128, 0.15);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.15);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

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

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
}

/* Layout */
.tool-layout {
  max-width: 1200px;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

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

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

/* Tarjeta de emergencia grave (Glucagón) */
.emergency-callout-card {
  background: var(--primary-light);
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.emergency-icon-wrap {
  font-size: 1.8rem;
  line-height: 1;
}

.emergency-text strong {
  display: block;
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.emergency-text p {
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.45;
}

.emergency-tel-link {
  display: inline-block;
  background: var(--primary);
  color: #ffffff !important;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-decoration: none;
}

[data-theme="dark"] .emergency-tel-link {
  color: #0b0f17 !important;
}

/* Rejilla de los 3 pasos */
.protocol-grid-wrapper {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 1.25rem;
  align-items: stretch;
}

@media (max-width: 1024px) {
  .protocol-grid-wrapper {
    grid-template-columns: 1fr;
  }
}

/* Tarjetas de paso */
.card-step {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.card-timer-focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.step-badge {
  background: var(--primary);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  text-transform: uppercase;
}

[data-theme="dark"] .step-badge {
  color: #0b0f17;
}

.card-title {
  font-size: 1.15rem;
  color: var(--text-main);
}

/* Formularios */
.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-input {
  width: 100%;
  height: 44px;
  padding: 0 0.85rem;
  font-size: 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
}

.form-input:focus {
  border-color: var(--border-focus);
}

.form-input.text-large {
  font-size: 1.25rem;
  font-weight: 700;
  height: 48px;
}

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

.input-unit-wrapper .form-input {
  padding-right: 65px;
}

.input-suffix {
  position: absolute;
  right: 12px;
  font-size: 0.85rem;
  color: var(--text-subtle);
  font-weight: 600;
}

.helper-text {
  display: block;
  font-size: 0.78rem;
  color: var(--text-subtle);
  margin-top: 0.35rem;
}

/* Opciones de 15 g */
.selector-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.fast-carb-options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.carb-option-card {
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.carb-option-card:hover {
  border-color: var(--primary);
}

.carb-option-card.active {
  background: var(--primary-light);
  border-color: var(--primary);
}

.carb-opt-icon {
  font-size: 1.4rem;
}

.carb-opt-name {
  display: block;
  font-size: 0.88rem;
  color: var(--text-main);
}

.carb-opt-desc {
  display: block;
  font-size: 0.74rem;
  color: var(--text-subtle);
}

.forbidden-callout {
  background: var(--bg-card-subtle);
  border-left: 3px solid var(--warning);
  padding: 0.65rem 0.85rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-top: auto;
}

.forbidden-icon {
  font-size: 1rem;
  line-height: 1.2;
}

/* Temporizador Circular */
.timer-warning-text {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 1rem;
  text-align: center;
}

.timer-dial-container {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0.5rem auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-circle-bg {
  fill: none;
  stroke: var(--bg-card-subtle);
  stroke-width: 14;
}

.timer-circle-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 596.9; /* 2 * PI * 95 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s linear;
}

.timer-center-info {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.timer-display {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.timer-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-subtle);
  margin-top: 0.35rem;
}

.timer-controls-row {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.btn-timer-main {
  flex: 2;
}

.audio-toggle-bar {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-subtle);
}

.audio-switch-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

/* Paso 3: Resolución */
.recheck-result-box {
  margin: 1.15rem 0;
  border-radius: var(--radius-md);
  padding: 1.15rem;
  font-size: 0.88rem;
  line-height: 1.5;
}

.result-resolved {
  background: var(--success-light);
  border: 1.5px solid var(--success);
  color: var(--text-main);
}

.result-repeated {
  background: var(--primary-light);
  border: 1.5px solid var(--primary);
  color: var(--text-main);
}

.result-resolved strong, .result-repeated strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.btn-log-episode {
  margin-top: auto;
}

/* Botones genéricos */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0 1.15rem;
  height: 44px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  min-height: 40px;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

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

[data-theme="dark"] .btn-primary {
  color: #0b0f17;
}

.btn-secondary {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1.5px solid var(--border-color);
}

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

.btn-text-action {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
}

/* Historial de episodios */
.history-card {
  margin-top: 1rem;
}

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

.history-actions-top {
  display: flex;
  gap: 1rem;
}

.episodes-table-wrap {
  overflow-x: auto;
}

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

.episodes-table th {
  background: var(--bg-card-subtle);
  padding: 0.65rem 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border-color);
}

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

.empty-history-text {
  font-size: 0.85rem;
  color: var(--text-subtle);
  text-align: center;
  padding: 1.25rem;
  font-style: italic;
}

/* FAQ */
.faq-section {
  margin-top: 1.5rem;
}

.faq-item {
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}

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

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

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

/* Modales */
.fijate-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 23, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.fijate-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.fijate-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

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

.fijate-modal-title {
  font-size: 1.15rem;
  color: var(--text-main);
}

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

.fijate-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-section-h4 {
  font-size: 0.98rem;
  color: var(--text-main);
  margin: 1rem 0 0.4rem;
}

.modal-section-h4:first-child {
  margin-top: 0;
}

.formula-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--primary);
  margin-bottom: 0.45rem;
}

.fijate-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}
