/*
 * dibo-graficas.css — selectores compartidos del motor de gráficas DIBO.
 * Los consumen tanto informe-sibo.html (donde antes vivían inline en <style>)
 * como el futuro cuaderno.html. Cero reescritura: los bloques se mueven
 * verbatim respetando el orden original — la cascada CSS es sensible al
 * orden, invertir reglas con la misma especificidad cambia el render.
 *
 * Lo que NO está aquí (sigue inline en informe-sibo.html porque es shell del
 * informe, no motor de gráficas):
 *   - Shell del informe: .section-area, .sec-grid, .sec-header, .sec-title,
 *     .sec-sub, .caja-bloqueada, .caja-vacia, .caja-placeholder-tecnologia,
 *     .sm-item, .preset-btn, sidebar, modal disclaimer, .empty-pad.
 *   - Overview shell: .user-status-line, .ov-note.
 *   - Panel "Hoja de Crisis" (.crisis-panel-*, .sb-crisis-*).
 *   - @media print del informe (.print-*, #print-document overrides).
 *   - Mobile protections a nivel de shell.
 *
 * Tokens (var(--gd), var(--text2), var(--bg-card), …) siguen resolviéndose
 * desde css/tokens.css, que ambos HTML cargarán como hasta ahora.
 */

/* ── BRISTOL SECTION ── */
.bristol-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.br-card.full { grid-column: 1 / -1; }

.br-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-width: 0;
}
/* Modificador: padding vertical y gap más pequeños — para cajas con mucha
   altura interna desaprovechada (Signos asociados, Episodios destacables). */
.br-card.br-card-compact { padding: .85rem 1.15rem; gap: .4rem; }
.br-card-hd { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.br-card-title {
  font-size: 12.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text2);
  margin-right: auto;
}
.br-card.expanded { grid-column: 1 / -1; }
.br-expand-btn {
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .12s, background .12s;
}
.br-expand-btn:hover { color: var(--gd); background: var(--bg-card); }
.br-card-empty {
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  border-radius: var(--radius-md);
  padding: .75rem 1rem;
  font-size: 12px; line-height: 1.45;
  color: var(--text2);
}
.br-card-empty .empty-status {
  color: var(--warn-text);
  font-weight: 600;
  margin-top: .4rem;
}

.br-chart-wrap { width: 100%; }
.br-chart-wrap svg { width: 100%; height: auto; display: block; }

.br-tipo-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; border: 1px solid currentColor;
}
.br-flag-badge {
  display: inline-flex; align-items: center; padding: 1px 8px;
  border-radius: 999px; font-size: 10.5px; font-weight: 600;
  border: 1px solid currentColor; margin-right: 4px;
}

.br-signo-row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: .75rem; padding: 3px 0; }
.br-signo-label { font-size: 12px; color: var(--text); font-weight: 500; }
.br-signo-bar-bg { background: var(--bg-card); border-radius: 999px; height: 10px; overflow: hidden; }
.br-signo-bar-fg { height: 100%; border-radius: 999px; }
.br-signo-count { text-align: right; font-size: 12px; font-weight: 700; color: var(--text); }

.br-donut-row { display: grid; grid-template-columns: 130px 1fr; gap: 1rem; align-items: center; }
.br-donut-legend { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; }
.br-donut-legend .li { display: grid; grid-template-columns: 12px 1fr auto; gap: .5rem; align-items: center; }
.br-donut-legend .li .sw { width: 11px; height: 11px; border-radius: 3px; }
.br-donut-legend .li .lbl { color: var(--text2); }
.br-donut-legend .li .val { font-weight: 700; color: var(--text); }

.br-ep-list {
  display: flex; flex-direction: column; gap: .5rem;
  max-height: 180px; overflow-y: auto;
  padding-right: 4px;
  position: relative; /* contiene el scroll; usado para cálculo de offset */
}
.br-card.expanded .br-ep-list { max-height: 600px; }
.br-ep-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: .65rem .9rem;
  scroll-margin-top: 8px;
}
.br-ep-hd { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin-bottom: .25rem; }
.br-ep-fecha { font-size: 12px; font-weight: 700; color: var(--text); }
.br-ep-hora { font-size: 11px; color: var(--text3); }
.br-ep-flags { display: flex; flex-wrap: wrap; gap: 4px; margin: .25rem 0; }
.br-ep-ctx { font-size: 11.5px; color: var(--text2); line-height: 1.4; }
.br-ep-ctx-line { margin-top: 2px; }
.br-ep-ctx-line strong { color: var(--text); font-weight: 600; }

/* Mini-timeline al inicio de Episodios destacables */
.br-ep-timeline {
  position: relative;
  height: 38px;
  margin: 0;  /* el gap del .br-card-compact controla la separación */
}
.br-ep-timeline-track {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bg-card);
  border-radius: 999px;
}
.br-ep-timeline-dot {
  position: absolute;
  top: 11.5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  border: 1.5px solid var(--bg-white);
  box-shadow: var(--shadow-thumb);
  transition: transform .12s;
  padding: 0;
}
.br-ep-timeline-dot.multi { width: 10px; height: 10px; }
.br-ep-timeline-dot:hover { transform: translate(-50%, -50%) scale(1.35); }
.br-ep-timeline-dot.active {
  transform: translate(-50%, -50%) scale(1.3);
  border-width: 2.5px;
  transition: transform .15s ease-out, border-width .15s ease-out;
}
/* Triángulo que sigue al scroll de la lista de tarjetas: bajo la barra, apex hacia arriba */
.br-ep-timeline-pointer {
  position: absolute;
  top: 14px;
  left: 0;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 7px solid var(--gd);
  transform: translateX(-50%);
  transition: left .15s ease-out;
  pointer-events: none;
}
.br-ep-timeline-label {
  position: absolute;
  top: 22px;
  font-size: 9px;
  color: var(--text3);
  white-space: nowrap;
  line-height: 1;
}

.br-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.br-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.br-table th {
  background: var(--pale); color: var(--gd);
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em;
  padding: 6px 8px; text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.br-table td { padding: 6px 8px; border-bottom: 1px solid #f0ece6; vertical-align: top; }
.br-table tr:last-child td { border-bottom: none; }
.br-table tr:nth-child(even) td { background: #faf9f7; }

/* Tabla colapsable */
.br-table-card { padding: 0; gap: 0; }
.br-table-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  transition: background .12s;
  -webkit-tap-highlight-color: transparent;
}
.br-table-card > summary::-webkit-details-marker,
.br-table-card > summary::marker { display: none; content: ''; }
.br-table-card > summary:hover { background: var(--bg-card); }
.br-collapse-meta {
  font-size: 11.5px;
  color: var(--text3);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.br-collapse-meta .arrow {
  display: inline-block;
  transition: transform .2s;
  font-size: 11px;
}
.br-table-card[open] > summary .arrow { transform: rotate(180deg); }
.br-table-card > .br-table-wrap {
  max-height: 400px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

/* ── PESO SECTION ── */
.peso-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }

/* ── TENSIÓN SECTION ── */
.tension-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.tension-legend { display: flex; flex-wrap: wrap; gap: 1rem; padding: .35rem 0; font-size: 12px; color: var(--text2); }
.tension-legend .li { display: inline-flex; align-items: center; gap: 5px; }
.tension-legend .sw { width: 14px; height: 3px; border-radius: 2px; flex-shrink: 0; }

/* ── REMEDIOS / FÁRMACOS / COMIDA SECTIONS ── */
.remedios-grid,
.farmacos-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.comida-grid   { display: grid; grid-template-columns: 1fr; gap: 1rem; }

/* ── SÍNTOMAS SECTION ── */
.sintomas-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.sint-card-sub {
  font-size: 11px; color: var(--text3);
  margin-top: .25rem; line-height: 1.4;
}
.sint-bubble-legend {
  display: flex; flex-wrap: wrap; gap: .55rem .8rem;
  margin-top: .5rem; font-size: 11px; color: var(--text2);
}
.sint-bubble-legend .li { display: inline-flex; align-items: center; gap: 5px; }
.sint-bubble-legend .sw { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.sint-day-legend {
  display: flex; flex-wrap: wrap; gap: .5rem .9rem;
  margin-top: .5rem; font-size: 11px; color: var(--text2);
}
.sint-day-legend .li { display: inline-flex; align-items: center; gap: 5px; }
.sint-day-legend .sw { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* Chips bar */
.sint-chips-wrap {
  grid-column: 1 / -1;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .9rem 1.15rem 1rem;
  display: flex; flex-direction: column; gap: .55rem;
}
.sint-chips-help {
  font-size: 11px; color: var(--text3); line-height: 1.45;
}
.sint-chips-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: .4rem;
}
.sint-chip {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-white);
  color: var(--gd);
  border: 1.5px solid var(--gd);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sint-chip.selected { background: var(--gd); color: var(--ink-on-dark); }
.sint-chip.disabled {
  background: var(--bg-card);
  color: var(--text3);
  border-color: var(--border);
  cursor: not-allowed;
  opacity: .7;
}

/* Detail table cells */
.sint-cell {
  display: inline-grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 5px;
  min-width: 56px;
}
.sint-cell .v { font-weight: 700; color: var(--text); font-size: 12px; text-align: right; }
.sint-cell .bar {
  background: var(--bg-card);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}
.sint-cell .bar > i {
  display: block; height: 100%;
  background: var(--gd);
  border-radius: 999px;
}
.sint-cell.zero { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.sint-cell.zero .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--pale-border);
  display: inline-block;
}
.sint-cell.zero .v { color: var(--text3); font-weight: 500; font-size: 11.5px; }

/* Línea pequeña con el desglose por modo. Aparece bajo la tabla detallada y bajo
   "Cómo te has sentido" — mismo texto, mismo estilo base. La variante .sint-table-footer
   añade border-top y padding lateral porque vive dentro del details (sin padding propio). */
.sint-mode-count {
  font-size: 11.5px;
  color: var(--text3);
  padding-top: 4px;
}
.sint-table-footer {
  padding: 8px 16px 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Tabla Síntomas — habilita scroll horizontal cuando los chips activan muchas columnas.
   Reemplaza el width:100% por min-width:max-content para que las celdas no se compriman. */
.sint-table-card > .br-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sint-table-card .br-table {
  width: auto;
  min-width: 100%;
  min-width: max-content;
}
.sint-table-card .br-table th,
.sint-table-card .br-table td { white-space: nowrap; }

/* Lista pastillas (Fármacos: medicamentos y suplementos) */
.farm-pill {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .75rem;
  background: var(--bg-card);
  border-left: 4px solid var(--gd);
  border-radius: 4px;
  padding: 8px 12px;
}
.farm-pill-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.farm-pill-count {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
/* Badge tipo en tabla de fármacos */
.farm-tipo-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.farm-tipo-badge.rx  { background: #E0F0EE; color: #0F7F71; }
.farm-tipo-badge.pro { background: #FBE5D2; color: #CD6410; }

/* Caja unificada Medicamentos + Suplementos */
.farm-medsupl-scroll {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}
.br-card.expanded .farm-medsupl-scroll { max-height: 520px; }
.farm-subblock { display: flex; flex-direction: column; gap: 7px; }
.farm-subtitle {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.farm-subtitle.rx  { color: #0F7F71; }
.farm-subtitle.pro { color: #CD6410; }
/* Leyenda gráfica apilada */
.farm-evo-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  margin-top: .5rem;
  font-size: 11px;
  color: var(--text2);
}
.farm-evo-legend .li { display: inline-flex; align-items: center; gap: 5px; }
.farm-evo-legend .sw { width: 11px; height: 11px; border-radius: 3px; }
.farm-evo-strip-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text2);
  margin: 0 0 .2rem;
}
.farm-evo-strip-note {
  font-weight: 400;
  font-size: 10.5px;
  color: var(--text3);
}
.farm-evo-strip-empty {
  font-size: 11px;
  color: var(--text3);
  font-style: italic;
  padding: .25rem 0 .4rem;
}
.farm-evo-block { padding: .55rem 0; }
.farm-evo-block + .farm-evo-block {
  border-top: 1px solid var(--border);
  margin-top: .25rem;
}

/* Lista vertical de frecuencia de remedios. Altura calculada para ~6 filas;
   el resto queda accesible vía scroll. En modo expandido la caja muestra más sin scroll. */
.freq-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 170px;
  overflow-y: auto;
  padding-right: 4px;
}
.br-card.expanded .freq-list { max-height: 400px; }
.freq-row {
  display: grid;
  grid-template-columns: 1fr 28% 36px;
  align-items: center;
  gap: .75rem;
}
.freq-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.freq-bar-bg {
  background: var(--bg-card);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}
.freq-bar-fg {
  height: 100%;
  border-radius: 999px;
  background: var(--gd);
}
.freq-count {
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.freq-row.otros .freq-name { font-style: italic; color: var(--text3); }
.freq-row.otros .freq-bar-fg { background: var(--text3); }

/* Nota al pie de cajas Remedios */
.rmd-note {
  margin-top: .5rem;
  font-size: 10.5px;
  color: var(--text3);
  font-style: italic;
  line-height: 1.4;
}

/* Línea pequeña al pie de la caja "Distribución por franja" en Comida: conteo de días
   atípicos en el período. Mismo patrón que .sint-mode-count. */
.comida-atipico-note {
  font-size: 11.5px;
  color: var(--text3);
  padding-top: 4px;
}

@media (max-width: 700px) {
  .freq-list { max-height: 170px; }
  .farm-medsupl-scroll { max-height: 220px; }
}

@media (max-width: 700px) {
  .bristol-grid,
  .remedios-grid,
  .farmacos-grid,
  .comida-grid,
  .sintomas-grid { grid-template-columns: 1fr; }
  .sint-chips-bar { grid-template-columns: repeat(3, 1fr); }
  .br-donut-row { grid-template-columns: 100px 1fr; gap: .6rem; }
  .br-signo-row { grid-template-columns: 90px 1fr 30px; gap: .5rem; }
  .br-table-card > .br-table-wrap { max-height: 300px; }
  .br-ep-list { max-height: 160px; }
  .br-expand-btn { display: none; }
}
