/* B12 · copiloto con herramientas: modo, tarjetas de resultados, propuestas con confirmación e historial.
   Solo tokens de crm.css (claro y oscuro). El movimiento se apaga con «reducir movimiento» (regla global de crm.css). */

/* barra de modo y pestañas dentro de la ventana flotante */
.af-mode { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.af-mode::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.af-mode.ia { border-color: color-mix(in srgb, var(--info) 55%, transparent); color: #fff; }
.af-win.af-min .af-mode { display: none; }
.cp-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.cp-tab { flex: 1; min-height: 40px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; position: relative; padding: 0 6px; transition: color var(--dur-fast); }
.cp-tab:hover { color: var(--text); }
.cp-tab[aria-selected="true"] { color: var(--text); }
.cp-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10%; right: 10%; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.cp-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: var(--r-sm); }
.cp-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cp-pane[hidden] { display: none; }
.cp-scroll { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }

/* mensajes */
.af-msg.assistant { max-width: 100%; width: 100%; background: transparent; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cp-text { margin: 0; padding: 9px 12px; border-radius: var(--r-lg); background: var(--surface-3); font-size: var(--fs-base); line-height: 1.45; overflow-wrap: anywhere; }
.cp-meta { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.cp-meta .cp-chip { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-weight: 600; }
.cp-meta .cp-chip.ia { background: var(--info-soft); color: var(--info-ink); }

/* tarjeta de resultados (datos leídos: siempre texto plano) */
.cp-card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); overflow: hidden; min-width: 0; }
.cp-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 10px 12px 8px; }
.cp-card-head h4 { margin: 0; font-size: var(--fs-base); font-weight: 600; overflow-wrap: anywhere; }
.cp-card-head span { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.cp-notice { margin: 0; padding: 6px 12px; border-top: 1px dashed var(--line); font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 6px; align-items: flex-start; }
.cp-notice svg { width: 12px; height: 12px; flex: none; margin-top: 2px; }
.cp-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cp-kpi { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; background: var(--surface); color: inherit; text-decoration: none; min-width: 0; }
a.cp-kpi:hover { background: var(--surface-2); }
.cp-kpi:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.cp-kpi span { font-size: var(--fs-xs); color: var(--muted); }
.cp-kpi b { font-size: var(--fs-base); font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cp-kpi.err b { color: var(--err); }
.cp-kpi.warn b { color: var(--warn); }
.cp-rows { list-style: none; margin: 0; padding: 0; }
.cp-row { display: block; padding: 8px 12px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; min-width: 0; }
a.cp-row:hover { background: var(--surface-2); }
.cp-row:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.cp-row strong { display: block; font-size: var(--fs-base); font-weight: 600; overflow-wrap: anywhere; }
.cp-row small { display: block; margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }
.cp-row.err { box-shadow: inset 3px 0 0 var(--err); }
.cp-row.warn { box-shadow: inset 3px 0 0 var(--warn); }
.cp-empty { margin: 0; padding: 10px 12px; font-size: var(--fs-sm); color: var(--muted); border-top: 1px solid var(--line); }
.cp-more { margin: 0; padding: 6px 12px 8px; font-size: var(--fs-xs); color: var(--muted); border-top: 1px solid var(--line); }
.cp-sub { margin: 0; padding: 8px 12px 4px; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 1px solid var(--line); }
.cp-links { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 10px; border-top: 1px solid var(--line); }
.cp-link { font-size: var(--fs-sm); font-weight: 600; color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.cp-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

/* propuesta con vista previa */
.cp-proposal { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-2); min-width: 0; }
.cp-proposal[data-status="ejecutada"] { border-left-color: var(--ok); }
.cp-proposal[data-status="rechazada"], .cp-proposal[data-status="expirada"] { border-left-color: var(--line-strong); opacity: .85; }
.cp-proposal[data-status="fallida"] { border-left-color: var(--err); }
.cp-prop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 4px; }
.cp-prop-head b { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cp-prop-sum { margin: 0; padding: 2px 12px 8px; font-size: var(--fs-base); font-weight: 600; overflow-wrap: anywhere; }
.cp-prop-lines { margin: 0; padding: 8px 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: var(--fs-sm); }
.cp-prop-lines dt { color: var(--muted); }
.cp-prop-lines dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.cp-prop-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px 10px; border-top: 1px solid var(--line); }
.cp-prop-foot .cp-left { margin-right: auto; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.cp-prop-result { margin: 0; padding: 8px 12px 10px; border-top: 1px solid var(--line); font-size: var(--fs-sm); }

/* B17 · propuesta de edición: antes → después, avisos, confirmación reforzada y deshacer */
.cp-diff { border-top: 1px solid var(--line); padding: 4px 0 2px; }
.cp-diff-list { list-style: none; margin: 0; padding: 0; }
.cp-diff-row { padding: 7px 12px; border-top: 1px dashed var(--line); min-width: 0; }
.cp-diff-list > .cp-diff-row:first-child { border-top: 0; }
.cp-diff-what { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.cp-diff-what strong { font-size: var(--fs-sm); font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.cp-diff-what span { font-size: var(--fs-xs); color: var(--muted); }
.cp-diff-vals { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 3px; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.cp-before { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); overflow-wrap: anywhere; }
.cp-arrow { color: var(--muted); }
.cp-after { color: var(--text); font-weight: 650; overflow-wrap: anywhere; }
.cp-delta { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.cp-delta.up { background: var(--ok-soft); color: var(--ok-ink); }
.cp-delta.down { background: var(--warn-soft); color: var(--warn-ink); }
.cp-more-rows { padding: 2px 12px 6px; }
.cp-more-rows > summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 600; padding: 6px 0; min-height: 32px; display: flex; align-items: center; }
.cp-more-rows > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.cp-more-rows .cp-diff-row { padding-left: 0; padding-right: 0; }
.cp-warns { list-style: none; margin: 6px 12px 4px; padding: 8px 10px; border-radius: var(--r-md); background: var(--warn-soft); color: var(--warn-ink); display: grid; gap: 4px; font-size: var(--fs-sm); }
.cp-warns li { display: flex; gap: 6px; align-items: flex-start; overflow-wrap: anywhere; }
.cp-warns svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.cp-skip { margin: 0; padding: 0 0 0 16px; font-size: var(--fs-xs); color: var(--muted); display: grid; gap: 2px; }
.cp-strong { margin: 6px 12px 0; padding: 10px; border: 1px solid color-mix(in srgb, var(--err) 45%, var(--line)); border-radius: var(--r-md); background: var(--err-soft); display: grid; gap: 8px; }
.cp-strong-text { margin: 0; display: flex; gap: 6px; align-items: flex-start; font-size: var(--fs-sm); color: var(--err-ink); font-weight: 600; }
.cp-strong-text svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.cp-strong-field { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); flex-wrap: wrap; }
.cp-count-input { width: 90px; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text); font: inherit; font-variant-numeric: tabular-nums; }
.cp-count-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.cp-proposal.is-edit .cp-prop-foot .btn.primary { min-width: 9.5em; justify-content: center; }
.cp-undone { color: var(--muted); }
.cp-choices { display: grid; gap: 10px; }
.cp-choice { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-right: 10px; }
.cp-choice .cp-row { flex: 1; border-top: 0; min-width: 0; }
.cp-choice .btn { flex: none; }

/* ayuda: qué puedo pedirte */
.cp-help h4 { margin: 0 0 6px; font-size: var(--fs-sm); font-weight: 600; }
.cp-help-group { display: flex; flex-direction: column; gap: 6px; }
.cp-help-list { display: flex; flex-wrap: wrap; gap: 6px; }
.cp-ex { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: var(--r-md); padding: 6px 10px; font: inherit; font-size: var(--fs-sm); text-align: left; cursor: pointer; transition: background var(--dur-fast), border-color var(--dur-fast); max-width: 100%; overflow-wrap: anywhere; }
.cp-ex:hover { background: var(--surface-3); border-color: var(--accent); }
.cp-ex:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.cp-no { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: var(--fs-sm); }
.cp-no li { padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-3); }
.cp-no b { display: block; }
.cp-no span { color: var(--muted); font-size: var(--fs-xs); }

/* historial */
.cp-hist { display: grid; gap: 10px; }
.cp-hist-note { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.cp-hist-item .cp-prop-sum { padding-bottom: 4px; }
.cp-hist-by { padding: 0 12px 8px; font-size: var(--fs-xs); color: var(--muted); }

/* catálogo de herramientas (Configuración › Asistente IA) */
.cp-tools { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.cp-tools th, .cp-tools td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.cp-tools th { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; border-top: 0; }
.cp-tools code { font-size: var(--fs-xs); }
.cp-tools-wrap { overflow-x: auto; }

@media (max-width: 480px) {
  .cp-kpis { grid-template-columns: 1fr; }
  .cp-tab { min-height: 44px; }
  .cp-ex, .cp-link { min-height: 36px; }
}

/* ajuste de espacio: chips en una sola fila con desplazamiento y más alto útil para el chat */
.af-body-wrap { max-height: 640px; }
.af-body-wrap > .af-body { height: min(580px, calc(100vh - 110px)); }
.af-quick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-top: 8px; flex: none; }
.af-quick .af-chip { flex: none; white-space: nowrap; }
.cp-tab { white-space: nowrap; flex: 1 1 0; }
.cp-tab[id="cp-tab-help"] { flex-grow: 1.9; }

/* B17: el rótulo del modo («IA · Claude Code …») no empuja los controles de la barra */
.af-mode { min-width: 0; max-width: 15em; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 20px; }
.af-mode::before { display: inline-block; margin-right: 6px; vertical-align: middle; }
@media (max-width: 480px) { .af-mode { max-width: 9em; } }

/* B18 · modo completo: candado, barra de estado y distintivo permanente (color de advertencia) */
.af-full { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.af-full[hidden] { display: none; }
.af-full-open { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); background: transparent; color: var(--text-2); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.af-full-open:hover { border-color: var(--warn); color: var(--text); }
.af-full-open:focus-visible, .af-full-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.af-full-open svg { width: 14px; height: 14px; }
.af-full-form { display: grid; gap: 6px; font-size: var(--fs-sm); }
.af-full-form label { font-weight: 600; }
.af-full-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.af-full-input { flex: 1 1 120px; min-width: 0; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text); font: inherit; }
.af-full-note { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.af-full-err { margin: 0; font-size: var(--fs-sm); color: var(--err-ink); background: var(--err-soft); padding: 6px 8px; border-radius: var(--r-md); }
.af-full-on-row { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r-md); background: var(--warn-soft); color: var(--warn-ink); }
.af-full-on-row > svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.af-full-on-row > div { flex: 1; min-width: 0; display: grid; gap: 2px; }
.af-full-on-row small { font-size: var(--fs-xs); }
.af-full-on-row .btn { flex: none; }
.af-full-left { display: block; margin-top: 4px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.af-full-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 99px; background: var(--warn); color: #14110d; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .03em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.af-full-badge[hidden] { display: none; }
.af-win.af-full-on { box-shadow: 0 0 0 2px var(--warn), var(--shadow-3); }
.af-win.af-full-on .af-mode { display: none; }
.cp-strong-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.cp-word-input { width: 130px; text-transform: uppercase; }
@media (max-width: 480px) { .af-full-on-row { flex-wrap: wrap; padding: 6px 8px; } .af-full-on-row small { display: none; } .af-full-on-row .btn { width: 100%; justify-content: center; } .af-full-left { display: none; } }

/* Más espacio para el chat: ventana más alta, avisos y pestañas compactos */
.af-body-wrap { max-height: 760px; }
.af-body-wrap > .af-body { height: min(700px, calc(100vh - 80px)); }
.cp-tab { min-height: 30px; font-size: var(--fs-xs); }
.af-quick { padding: 4px 8px 2px; gap: 4px; }
.af-quick .af-chip { padding: 2px 8px; min-height: 24px; font-size: var(--fs-xs); }
.af-full { padding: 4px 8px; }
.af-full-on-row { align-items: center; gap: 6px; padding: 3px 8px; }
.af-full-on-row > div { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.af-full-on-row strong { font-size: var(--fs-xs); }
.af-full-on-row .btn { min-height: 24px; padding: 0 8px; font-size: var(--fs-xs); }
.af-full-left { display: inline; margin: 0; }
.af-full-open { min-height: 24px; padding: 2px 8px; font-size: var(--fs-xs); }
@media (max-width: 480px) { .af-full-left { display: inline; } .af-full-on-row .btn { width: auto; } .cp-tab { min-height: 34px; } }
