/* ==========================================================================
   Clientes y Cotizaciones — mismos tokens de app.css y piezas de inventario/compras
   Teléfono: lista o detalle a pantalla completa (clases de diseño de Compras: .comp, is-comp);
   las acciones de la cotización (WhatsApp, PDF, Duplicar, Convertir) quedan abajo, en la
   zona del pulgar. Ventana ancha: lista a la izquierda y detalle a la derecha.
   Estados de la cotización y del crédito: siempre ícono + texto (nunca solo color).
   ========================================================================== */

/* Encabezado del detalle: «Más acciones» a la derecha */
.ficha-head-end { margin-left: auto; display: flex; align-items: center; }
.ficha-head-end .icon-btn { width: var(--tap); height: var(--tap); }

/* ---------- Estados de la cotización (ícono + texto) ---------- */
.qb-borrador { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.qb-enviada { background: var(--info-soft); color: var(--info); }
.qb-aceptada { background: var(--ok-soft); color: var(--ok); }
.qb-rechazada { background: var(--crit-soft); color: var(--crit); }
.qb-vencida { background: var(--warn-soft); color: var(--warn); }
.qb-convertida { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Detalle de la cotización ---------- */
.cq-total { display: flex; align-items: baseline; gap: var(--s2); margin: var(--s2) 0 0; }
.cq-total-l { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.cq-total .num { font-size: var(--fs-2xl); font-weight: 800; }
.cq-venta { display: flex; gap: var(--s3); align-items: flex-start; margin: 0 var(--s4) var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-ink); }
.cq-venta svg.ic { width: 24px; height: 24px; flex: none; }
.cq-venta-t { margin: 0; font-weight: 800; }
.cq-venta .help { margin: 2px 0 0; color: var(--ink); }
.cq-pasos { list-style: none; counter-reset: paso; margin: 0 var(--s4) var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: var(--s2); }
.cq-pasos li { counter-increment: paso; display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: 600; }
.cq-pasos li::before { content: counter(paso); flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--surface); font-size: var(--fs-xs); font-weight: 800; }
.cq-pasos svg.ic { width: 20px; height: 20px; color: var(--ink-2); flex: none; }

.cq-l .ol-main { gap: 3px; }
.cq-l-sub { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; }
.cq-tot { margin: var(--s3) 0 0; padding-top: var(--s3); border-top: 1px solid var(--line); display: grid; gap: var(--s2); }
.cq-tot > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.cq-tot dt { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; display: grid; }
.cq-tot dd { margin: 0; font-weight: 700; }
.cq-tot-sub { font-size: var(--fs-xs); font-weight: 600; }
.cq-tot-g dt { font-size: var(--fs-md); color: var(--ink); font-weight: 800; }
.cq-tot-g dd { font-size: var(--fs-xl); font-weight: 800; }
.cq-desc-gral { margin: var(--s3) calc(var(--s4) * -1) 0; width: calc(100% + var(--s4) * 2); border-top: 1px solid var(--line); }
.fcard .cart-auth { margin: var(--s3) 0 0; }
.fcard > .help svg.ic { width: 16px; height: 16px; vertical-align: -3px; }
.cq-cli-n { margin: 0; font-weight: 800; font-size: var(--fs-lg); overflow-wrap: anywhere; }
.cq-cli-n .comp-link { font-size: var(--fs-lg); }
.cq-est { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: 0; font-size: var(--fs-sm); }
.cq-est-acc { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.cq-est-acc .btn { flex: 1 1 auto; }

/* Historial completo de cambios de estado (y envíos) */
.cq-hist { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: 0; }
.cq-h { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--s3); padding: var(--s2) 0; position: relative; }
.cq-h + .cq-h::before { content: ""; position: absolute; left: 15px; top: -6px; height: 12px; border-left: 2px solid var(--line-strong); }
.cq-h-ic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.cq-h-ic svg.ic { width: 18px; height: 18px; }
.cq-h-t { display: grid; gap: 1px; font-size: var(--fs-sm); min-width: 0; }
.cq-h-t strong { font-weight: 800; }
.cq-h-m { color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; }
.cq-h-n { overflow-wrap: anywhere; }
.cq-h-auto .cq-h-t strong::after { content: " (automático)"; font-weight: 600; color: var(--ink-2); }
.cq-h-envio .cq-h-ic { background: var(--surface); }

/* Acciones móviles de la cotización: 4 botones grandes con ícono y texto */
.cq-bar { gap: var(--s2); }
.cq-act {
  flex: 1 1 0; min-width: 0; min-height: 64px; padding: 6px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--ink);
  font: inherit; font-size: var(--fs-xs); font-weight: 800; line-height: 1.15; text-align: center; cursor: pointer;
}
.cq-act svg.ic { width: 24px; height: 24px; }
.cq-act > span { overflow-wrap: anywhere; }
.cq-act:active { background: var(--surface-2); }
.cq-act.is-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.cq-act.is-primary:active { background: var(--accent-press); }
.cq-act[aria-disabled="true"] { background: var(--surface-2); color: var(--ink-2); border-style: dashed; }
.cq-act:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Hojas de cotización */
.cq-res .result { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; color: inherit; padding-inline: var(--s5); }
.cq-res .result:focus-visible { outline-offset: -3px; border-radius: var(--r-md); }
.cq-res .result[aria-disabled="true"] { color: var(--ink-2); }
.sheet .cq-res { margin: 0 calc(var(--s5) * -1); }
.cq-plus { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--surface); }
.cq-plus svg.ic { width: 18px; height: 18px; }
.cqprod-help { margin: var(--s2) 0 0; }
.cq-notas { min-height: 76px; padding-block: var(--s2); resize: vertical; line-height: 1.4; }
.cq-motivos { margin-top: var(--s1); }
.cq-conv-p, .cq-conv-w { display: flex; gap: var(--s2); align-items: flex-start; margin: 0 0 var(--s3); font-size: var(--fs-sm); font-weight: 600; }
.cq-conv-p svg.ic, .cq-conv-w svg.ic { width: 20px; height: 20px; flex: none; }
.cq-conv-w { color: var(--warn); }
/* Con la API (V034): el impuesto incluido en los totales, la cotización emitida y lo que costaría hoy convertirla */
.cq-tot-imp dt, .cq-tot-imp dd { font-size: var(--fs-xs); color: var(--ink-2); font-weight: 600; }
.cq-emitida .crok-lead { display: flex; gap: var(--s2); align-items: center; font-size: var(--fs-md); }
.cq-emitida .crok-lead svg.ic { width: 24px; height: 24px; flex: none; color: var(--ok); }
.cq-emitida:focus { outline: none; }
.cqc-lista { list-style: none; margin: 0 0 var(--s3); padding: 0; display: grid; gap: var(--s2); }
.cqc-l { display: grid; gap: 2px; padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.cqc-l.is-off { background: var(--surface-2); color: var(--ink-2); }
.cqc-n { font-weight: 700; }
.cqc-p { font-size: var(--fs-sm); color: var(--ink-2); }
.cqc-ex { display: flex; gap: var(--s1); align-items: flex-start; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.cqc-ex svg.ic { width: 18px; height: 18px; flex: none; }
.cqc-ex.is-warn { color: var(--warn); }
.cqc-ex.is-crit { color: var(--crit); }
.cqc-tot { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); margin: 0 0 var(--s3); font-size: var(--fs-sm); font-weight: 600; }
.cqc-tot strong { font-size: var(--fs-lg); font-weight: 800; }
#sheet-cqmas .opt-row, #sheet-ctmas .opt-row { width: 100%; }
.opt-row.is-danger { color: var(--crit); }

/* ---------- Clientes ---------- */
.ct-contacto { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); margin: 0 var(--s4) var(--s3); }
.ct-ca {
  min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--ink);
  font: inherit; font-size: var(--fs-xs); font-weight: 800; text-decoration: none; cursor: pointer;
}
.ct-ca svg.ic { width: 22px; height: 22px; }
.ct-ca:active { background: var(--surface-2); }
.ct-ca[aria-disabled="true"] { background: var(--surface-2); color: var(--ink-2); border-style: dashed; }
.ct-cred-e { margin: 0 0 var(--s3); }
.ct-uso { display: flex; align-items: center; gap: var(--s3); margin: var(--s3) 0 0; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.ct-uso .ord-bar { flex: 0 0 140px; height: 10px; border-radius: 5px; }
.ct-venc { display: inline-flex; align-items: center; gap: 4px; color: var(--crit); }
.ct-venc svg.ic { width: 18px; height: 18px; }
.ct-sub-h { margin: var(--s4) 0 0; }
.ct-ab-r { display: grid; justify-items: end; gap: 2px; }
.ct-ab-r .link-btn { min-height: var(--tap); min-width: var(--tap); display: inline-flex; align-items: center; justify-content: flex-end; font-size: var(--fs-sm); }
.ct-anulado { text-decoration: line-through; color: var(--ink-2); }
.ct-pct { display: flex; gap: var(--s2); align-items: flex-start; margin: 0 0 var(--s2); font-size: var(--fs-sm); }
.ct-pct svg.ic { width: 20px; height: 20px; flex: none; }
/* Con la API (V033): avisos del plan y de la cuenta, y las ventas que paga un abono */
.ct-plan { display: flex; gap: var(--s2); align-items: flex-start; margin: 0 0 var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r-md);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-size: var(--fs-sm); color: var(--ink); }
.ct-plan svg.ic { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.cta-docs { list-style: none; margin: var(--s2) 0; padding: 0; display: grid; gap: var(--s2); }
.cta-doc { padding: var(--s2) var(--s3); border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: var(--s1); }
.cta-doc .check-row { margin: 0; }
.cta-doc .check-row > span { display: grid; gap: 2px; min-width: 0; }
.cta-doc .p-meta { margin: 0; font-weight: 400; }
.cta-doc-m .input { width: 100%; text-align: right; }
.cta-doc-m .input:disabled { opacity: .55; }
.cta-doc .field-error { margin: 0; }
.ct-dup { margin: calc(var(--s2) * -1) 0 var(--s3); }
.ctp-list { list-style: none; margin: 0 0 var(--s3); padding: 0; display: grid; gap: var(--s2); }
.ctp-li { padding: var(--s2) var(--s3); border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); }
.ctp-p { display: grid; gap: 2px; margin-bottom: var(--s2); }
.ctp-p .p-meta { margin: 0; }
.ctp-in { display: flex; align-items: center; gap: var(--s2); }
.ctp-in .input { flex: 1 1 auto; min-width: 0; text-align: right; }
.ctp-in .icon-btn { border: 1px solid var(--line-strong); background: var(--surface); }
.ch-list .rp-tags { margin-top: 2px; }

/* Selector de cliente de la venta: precios especiales y crédito */
.opt-tags { display: flex; flex-wrap: wrap; gap: 4px var(--s3); margin-top: 2px; }

/* Nueva venta: precio especial o cotizado en la línea, cliente con precios, venta desde cotización */
.cl-pact { display: flex; gap: 6px; align-items: center; margin: 4px 0 0; font-size: var(--fs-sm); font-weight: 700; color: var(--accent-ink); }
.cl-pact svg.ic { width: 18px; height: 18px; flex: none; }
.row-sub { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 700; color: var(--accent-ink); }
.row-sub svg.ic { width: 16px; height: 16px; }
.cart-cot { display: flex; gap: var(--s2); align-items: center; min-height: var(--tap); margin: var(--s2) var(--s4) 0; padding: var(--s2) var(--s3); border-radius: var(--r-md); background: var(--accent-soft); font-size: var(--fs-sm); color: var(--ink); text-decoration: none; }
.cart-cot svg.ic { width: 18px; height: 18px; flex: none; color: var(--accent-ink); }
.cart-cot .grow { flex: 1; min-width: 0; }
.cart-cot .code { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.cart-cot:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Cobrar: crédito del cliente */
.credit-box.is-warn { background: var(--warn-soft); }
.credit-warn { display: flex; gap: 6px; align-items: flex-start; margin: var(--s2) 0 0 !important; font-size: var(--fs-sm); font-weight: 700; color: var(--warn); }
.credit-warn svg.ic { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.credit-note { display: flex; gap: 6px; align-items: flex-start; margin: var(--s2) 0 0 !important; font-size: var(--fs-sm); color: var(--ink-2); }
.credit-note svg.ic { width: 18px; height: 18px; flex: none; margin-top: 2px; }

/* Prototipo: vista del mensaje de WhatsApp y del documento (el visor no abre ventanas, no descarga ni imprime) */
.cq-wa-txt { margin: var(--s3) 0; padding: var(--s3); max-height: 40vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  border-radius: var(--r-md); background: var(--surface-2); color: var(--ink); font: inherit; font-size: var(--fs-sm); line-height: 1.45; }
.cq-doc-prev { margin: var(--s3) 0; padding: var(--s4); max-height: 52vh; overflow: auto; border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--papel); color: var(--papel-tinta); }
.cq-doc-prev .oc-doc { font-size: 10pt; }
.cq-doc-prev .oc-lines { min-width: 520px; }

/* Teléfonos angostos (360 px y menos) */
@container app (max-width: 380px) {
  .cq-bar { gap: 6px; }
  .cq-act { padding-inline: 2px; }
  .ct-contacto, .cq-pasos { margin-inline: var(--s3); }
}

/* Ventana ancha: las acciones de la cotización no ocupan todo el ancho */
@container app (min-width: 840px) {
  .cq-bar .cq-act { flex: 0 1 132px; }
}

@media (forced-colors: active) {
  .qb-borrador, .qb-enviada, .qb-aceptada, .qb-rechazada, .qb-vencida, .qb-convertida, .cq-h-ic, .cq-plus { border: 1px solid CanvasText; }
  .cq-act, .ct-ca { border: 1px solid ButtonText; }
  .cq-act.is-primary { outline: 2px solid Highlight; outline-offset: -4px; }
}
