/* ==========================================================================
   Conversor de glucosa y HbA1c - fijate.com
   Estilos canónicos con soporte Dark/Light Mode y diseño clínico reactivo
   ========================================================================== */

: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: #4f46e5;

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

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;

  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --purple: #9333ea;
  --purple-light: #f3e8ff;

  --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: #818cf8;

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

  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-light: rgba(129, 140, 248, 0.15);

  --success: #4ade80;
  --success-light: rgba(74, 222, 128, 0.15);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.15);
  --danger: #f87171;
  --danger-light: rgba(248, 113, 113, 0.15);
  --purple: #c084fc;
  --purple-light: rgba(192, 132, 252, 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;
}

/* Barra de presets rápidos */
.quick-presets-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

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

.quick-chips-group {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  flex: 1;
}

.preset-chip {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 36px;
}

.preset-chip:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* Rejilla de módulos */
.converters-grid-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

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

/* Tarjetas de conversión */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

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

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

.badge-tag {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
}

.module-desc {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.45;
}

/* Caja de inputs interactivos */
.interactive-converter-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.15rem;
}

@media (max-width: 600px) {
  .interactive-converter-box {
    flex-direction: column;
    align-items: stretch;
  }
  .converter-swap-icon {
    transform: rotate(90deg);
    margin: 0 auto;
  }
}

.converter-input-unit {
  flex: 1;
}

.converter-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

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

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

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

.form-input {
  width: 100%;
  height: 48px;
  padding: 0 0.85rem;
  font-size: 1.25rem;
  font-weight: 700;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

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

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

.converter-swap-icon {
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Tarjeta de evaluación de estado metabólico */
.status-eval-card {
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.85rem;
  transition: all 0.2s ease;
}

.status-eval-card strong {
  display: block;
  margin-bottom: 0.15rem;
}

.status-hypo {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.status-normal {
  background: var(--success-light);
  border: 1px solid var(--success);
  color: var(--success);
}

.status-hyper {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  color: var(--warning);
}

.status-severe {
  background: var(--purple-light);
  border: 1px solid var(--purple);
  color: var(--purple);
}

.formula-caption {
  font-size: 0.76rem;
  color: var(--text-subtle);
  text-align: right;
}

/* Tarjeta resumen eAG */
.eag-summary-card {
  background: linear-gradient(135deg, var(--primary-light), var(--bg-card-subtle));
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  text-align: center;
  margin-bottom: 0.85rem;
}

.eag-card-title {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.eag-values-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 0.35rem;
}

.eag-num {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.eag-unit {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
}

.eag-separator {
  font-size: 1.4rem;
  color: var(--text-subtle);
}

.eag-hint {
  font-size: 0.8rem;
  color: var(--text-subtle);
}

/* Tabla de correlación */
.table-card {
  margin-top: 1rem;
}

.table-scroll-wrap {
  overflow-x: auto;
  margin-top: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

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

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

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

.correlation-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.correlation-table tbody tr:hover {
  background: var(--bg-card-subtle);
}

.row-normal {
  border-left: 4px solid var(--success);
}

.row-prediabetes {
  border-left: 4px solid var(--warning);
}

.row-diabetes-target {
  border-left: 4px solid #2563eb;
}

.row-diabetes-high {
  border-left: 4px solid var(--danger);
}

.row-diabetes-severe {
  border-left: 4px solid var(--purple);
}

/* 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;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0 1.25rem;
  height: 44px;
  cursor: pointer;
  border: none;
  min-height: 40px;
}

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

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