/* ============================================================
 * theme.css — TEMA de la guía de división sintética (capa LIBRE).
 * Prefijo: ds- (división sintética).
 * Solo estilos de los widgets propios del tema. NO redefine clases guia-*.
 * Sin hex hardcodeados: usa var(--guia-*).
 * ============================================================ */

/* ===== Shared widget helpers ===== */
.ds-wg-lead {
  font-size: 0.95rem;
  color: var(--guia-ink);
  margin-bottom: 12px;
  line-height: 1.5;
}

/* ===== Widget: tableau interactivo ===== */
.ds-tableau-wrap {
  border: 1px solid var(--guia-line);
  border-radius: 10px;
  padding: 16px;
  background: var(--guia-cream);
}

.ds-tableau {
  display: grid;
  grid-template-columns: 2.5rem repeat(var(--cols), 1fr);
  grid-template-rows: auto auto 2px auto;
  gap: 0;
  border: 2px solid var(--guia-ink);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  background: #fff;
}

.ds-t-cell {
  padding: 10px 8px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.2s;
}

.ds-t-sep {
  background: var(--guia-deep);
  color: #fff;
  font-weight: 700;
}

.ds-t-top {
  background: #fff;
  border-bottom: 1px solid var(--guia-line);
  color: var(--guia-ink);
}

.ds-t-mid {
  background: #fff;
  color: var(--guia-navy);
  border-bottom: none;
}

.ds-t-mid-sep {
  background: var(--guia-deep);
}

.ds-t-empty {
  /* primer slot del medio queda vacío */
}

.ds-t-hline {
  background: var(--guia-ink);
  height: 2px;
  grid-row: 3;
}

.ds-t-bot {
  background: var(--guia-cream);
  color: var(--guia-green);
  font-weight: 700;
}

.ds-t-residuo {
  color: var(--guia-muted) !important;
  border-left: 2px dashed var(--guia-line);
}

.ds-t-active {
  background: #fff3cd !important;
  outline: 2px solid var(--guia-orange);
  outline-offset: -2px;
}

.ds-t-placeholder {
  display: block;
  width: 20px;
  height: 3px;
  background: var(--guia-line);
  border-radius: 2px;
  margin: auto;
}

.ds-t-val { font-size: 1rem; font-weight: 700; }
.ds-t-val.mid { color: var(--guia-navy); }
.ds-t-val.bot { color: var(--guia-green); }
.ds-t-val.bot.res { color: var(--guia-muted); }

/* Paso activo */
.ds-t-paso {
  margin-top: 12px;
}

.ds-t-prompt {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--guia-ink);
  margin-bottom: 10px;
}

.ds-t-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ds-t-opt {
  min-width: 56px;
}

.ds-t-fb {
  min-height: 1.4em;
  font-size: 0.88rem;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  display: block;
}
.ds-t-fb.ok { background: #d1fae5; color: #065f46; }
.ds-t-fb.miss { background: #fee2e2; color: #991b1b; }

/* Done */
.ds-t-done {
  padding: 12px 14px;
  background: #d1fae5;
  border-radius: 8px;
  border-left: 4px solid var(--guia-green);
}
.ds-t-done-msg {
  font-size: 0.92rem;
  color: #065f46;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 10px;
}

.ds-replay {
  display: inline-block;
  padding: 6px 14px;
  background: var(--guia-cream);
  border: 1px solid var(--guia-line);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--guia-ink);
}
.ds-replay:hover { background: var(--guia-line); }

/* Encabezado del tableau */
.ds-t-header {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--guia-muted);
  margin-bottom: 8px;
}
.ds-t-a-label { font-weight: 700; color: var(--guia-orange); }
.ds-t-divisor { font-weight: 600; color: var(--guia-ink); }


/* ===== Widget: tableau-intro ===== */
.ds-t-intro {
  border: 1px solid var(--guia-line);
  border-radius: 10px;
  padding: 16px;
  background: var(--guia-cream);
}

.ds-ti-grid {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  grid-template-rows: auto auto 2px auto;
  gap: 0;
  border: 2px solid var(--guia-ink);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
  font-size: 0.88rem;
  text-align: center;
}

.ds-ti-a {
  grid-column: 1; grid-row: 1 / 5;
  background: var(--guia-deep);
  color: #fff;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  padding: 8px;
}

.ds-ti-top {
  grid-column: 2; grid-row: 1;
  padding: 10px 12px;
  background: #fff;
  font-weight: 600;
  border-bottom: 1px solid var(--guia-line);
}

.ds-ti-sep { grid-column: 2; grid-row: 2; height: 6px; background: var(--guia-cream); }

.ds-ti-mid {
  grid-column: 2; grid-row: 2;
  padding: 8px 12px;
  background: #fff;
  color: var(--guia-navy);
  font-weight: 600;
}

.ds-ti-hline {
  grid-column: 1 / 3; grid-row: 3;
  background: var(--guia-ink);
  height: 2px;
}

.ds-ti-bot {
  grid-column: 2; grid-row: 4;
  padding: 10px 12px;
  background: var(--guia-cream);
  font-weight: 600;
  color: var(--guia-green);
}

.ds-ti-res { color: var(--guia-muted); }

.ds-ti-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ds-ti-leg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--guia-ink);
}

.ds-swatch {
  width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0;
}
.ds-swatch-dv { background: var(--guia-orange); }
.ds-swatch-pr { background: var(--guia-navy); }
.ds-swatch-rs { background: var(--guia-green); }
.ds-swatch-re { background: var(--guia-muted); }


/* ===== Widget: desglose-factorizacion ===== */
.ds-dfac {
  border: 1px solid var(--guia-line);
  border-radius: 10px;
  padding: 16px;
  background: var(--guia-cream);
}

.ds-dfac-stage {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--guia-line);
  margin: 10px 0;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  transition: opacity 0.25s;
}

.ds-dfac-content { text-align: center; }

.ds-dg-in {
  animation: dg-slide 0.22s ease both;
}
@keyframes dg-slide {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ds-dfac-ctrl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.ds-dfac-count {
  font-size: 0.8rem;
  color: var(--guia-muted);
}

.ds-nav.primary {
  background: var(--guia-orange);
  color: #fff;
  border-color: var(--guia-orange);
}
.ds-nav.primary:hover { opacity: 0.9; }


/* ===== Widget: leer-resultado ===== */
.ds-lr {
  border: 1px solid var(--guia-line);
  border-radius: 10px;
  padding: 16px;
  background: var(--guia-cream);
}

.ds-lr-row {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.ds-lr-cell {
  min-width: 48px;
  padding: 10px 12px;
  background: var(--guia-cream);
  border: 2px solid var(--guia-green);
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--guia-green);
}

.ds-lr-last {
  border-color: var(--guia-muted);
  color: var(--guia-muted);
  border-style: dashed;
}

.ds-lr-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.ds-lr-fb { font-size: 0.88rem; min-height: 1.4em; padding: 4px 8px; border-radius: 6px; }
.ds-lr-fb.ok { background: #d1fae5; color: #065f46; }
.ds-lr-fb.miss { background: #fee2e2; color: #991b1b; }


/* ===== Herramienta libre (tool) ===== */
.ds-tool-wrap { padding: 4px 0; }

.ds-tool-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.ds-tool-btn {
  text-align: left;
  padding: 10px 14px !important;
  white-space: normal;
}

.ds-tool-slot {
  margin-top: 8px;
}


/* ===== Responsive ===== */
@media (max-width: 540px) {
  .ds-tableau {
    font-size: 0.9rem;
  }
  .ds-t-cell {
    padding: 8px 4px;
    min-height: 36px;
  }
  .ds-dfac-ctrl {
    flex-wrap: wrap;
  }
}
