/* ==========================================================================
   Test de Findrisk de diabetes tipo 2 - fijate.com
   Estilos canónicos con soporte Dark/Light Mode y diseño imprimible A4
   ========================================================================== */

: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: #0284c7;

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

  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;

  --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: #38bdf8;

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

  --primary: #38bdf8;
  --primary-hover: #7dd3fc;
  --primary-light: rgba(56, 189, 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;
}

/* Cabecera introductoria */
.intro-alert-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.intro-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.intro-alert-card strong {
  display: block;
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.intro-alert-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Rejilla de 2 columnas */
.findrisk-grid-wrapper {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  align-items: flex-start;
}

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

/* Tarjetas de preguntas */
.findrisk-questions-container {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.question-card {
  transition: border-color 0.15s ease;
}

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

.q-number {
  background: var(--primary);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

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

.q-hint-sub {
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin-bottom: 0.75rem;
  font-style: italic;
}

/* Opciones de respuesta */
.q-options-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.q-option-label {
  display: flex;
  cursor: pointer;
}

.q-option-label input {
  position: absolute;
  opacity: 0;
}

.q-opt-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.7rem 0.95rem;
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.q-option-label:hover .q-opt-box {
  border-color: var(--primary);
}

.q-option-label input:checked + .q-opt-box {
  background: var(--primary-light);
  border-color: var(--primary);
  font-weight: 600;
}

.q-opt-text {
  color: var(--text-main);
}

.q-opt-pts {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--bg-card);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

/* Mini calculadora de IMC */
.imc-quick-calc-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.95rem;
  margin-bottom: 0.85rem;
}

.calc-hint-title {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.imc-inputs-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.imc-field {
  flex: 1;
  min-width: 90px;
}

.imc-label {
  display: block;
  font-size: 0.74rem;
  color: var(--text-subtle);
  margin-bottom: 0.2rem;
}

.imc-field .form-input {
  height: 38px;
  font-size: 0.9rem;
}

.imc-result-col {
  padding-left: 0.5rem;
  text-align: center;
}

.imc-result-label {
  display: block;
  font-size: 0.74rem;
  color: var(--text-subtle);
}

.imc-res-val {
  font-size: 1.1rem;
  color: var(--primary);
}

/* Selector de sexo para cintura */
.sex-selector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.switch-sex-wrap {
  display: inline-flex;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2px;
}

.sex-pill {
  background: none;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.3rem 0.85rem;
  border-radius: 16px;
  cursor: pointer;
}

.sex-pill.active {
  background: var(--primary);
  color: #ffffff;
}

[data-theme="dark"] .sex-pill.active {
  color: #0b0f17;
}

/* Columna de resultados FINDRISC */
.card-findrisk-results {
  position: sticky;
  top: 1rem;
}

.score-hero-box {
  background: linear-gradient(135deg, var(--primary-light), var(--bg-card-subtle));
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  text-align: center;
  margin-bottom: 1.15rem;
  transition: all 0.2s ease;
}

.score-hero-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.score-number-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.35rem 0;
}

.score-number {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.score-max-sub {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 700;
}

.risk-level-badge {
  display: inline-block;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.3rem 0.95rem;
  border-radius: 20px;
  margin-top: 0.35rem;
}

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

.level-slight {
  background: #dbeafe;
  color: #2563eb;
  border: 1px solid #2563eb;
}

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

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

.level-very-high {
  background: var(--purple-light);
  color: var(--purple);
  border: 1px solid var(--purple);
}

/* Probabilidad y barra de progreso */
.risk-probability-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  margin-bottom: 1.15rem;
}

.risk-prob-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.risk-ratio-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.65rem;
}

.progress-bar-wrap {
  width: 100%;
  height: 10px;
  background: var(--border-color);
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 5px;
  transition: width 0.3s ease, background 0.3s ease;
}

/* Desglose de factores */
.factors-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.95rem 1.15rem;
  margin-bottom: 1.15rem;
}

.factors-title {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  font-weight: 600;
}

.factors-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--border-color);
}

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

/* Recomendaciones clínicas */
.recommendations-box {
  background: var(--bg-card-subtle);
  border-left: 3.5px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.15rem;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.recommendations-box strong {
  display: block;
  font-size: 0.92rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.recommendations-box ul {
  padding-left: 1.15rem;
  margin-top: 0.35rem;
}

/* Botones */
.results-actions-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.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;
  width: 100%;
  min-height: 40px;
}

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

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

/* Modal y tabla de baremos */
.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;
}

.baremo-table-wrap {
  overflow-x: auto;
  margin: 0.65rem 0 1rem;
}

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

.baremo-table th, .baremo-table td {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-color);
}

.baremo-table th {
  background: var(--bg-card-subtle);
  color: var(--text-main);
}

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

/* Estilos de impresión para informe clínico A4 */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header, .fijate-footer, .tools-ad-banner-section, .tool-ad-sidebar,
  .findrisk-grid-wrapper, .faq-section, .intro-alert-card {
    display: none !important;
  }
  .printable-clinical-report {
    display: block !important;
    max-width: 800px;
    margin: 0 auto;
    font-size: 12pt;
    line-height: 1.4;
  }
  .print-header {
    border-bottom: 2px solid #000;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
  }
  .print-summary-box {
    border: 1.5px solid #000;
    padding: 1rem;
    margin-bottom: 1.5rem;
    background: #f8fafc;
  }
  .print-summary-box p {
    margin: 0.35rem 0;
  }
  .print-details {
    margin-bottom: 2rem;
  }
  .print-footer {
    border-top: 1px solid #ccc;
    padding-top: 0.5rem;
    font-size: 9pt;
    color: #555;
  }
}
