/* Copiloto flotante (cw-*). Negro, crema y dorado del CRM; bordes sutiles; iconos Lucide pequeños. Estados: botón · minimizado · flotante · ampliado. */
.cw-ic { display: inline-flex; flex: none; }
.cw-ic svg { width: 16px; height: 16px; }

/* botón de acceso (abajo a la derecha) */
.cw-fab { position: fixed; right: 20px; bottom: 20px; z-index: 80; width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid rgba(222, 162, 2, .55); border-radius: 50%; background: var(--primary); color: var(--accent); cursor: pointer; box-shadow: 0 4px 14px rgba(20, 17, 13, .25); transition: transform .15s, box-shadow .15s; }
.cw-fab:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(20, 17, 13, .3); }
.cw-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cw-fab .cw-ic svg { width: 22px; height: 22px; }
.cw-fab-dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #4ade80; border: 2px solid var(--primary); }
.cw-fab[hidden], .cw-win[hidden] { display: none; }

/* ventana */
.cw-win { position: fixed; right: 20px; bottom: 20px; z-index: 80; width: min(460px, calc(100vw - 24px)); height: min(640px, calc(100dvh - 40px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 12px 36px rgba(20, 17, 13, .22); overflow: hidden; }
.cw-win.expand { width: min(940px, calc(100vw - 40px)); height: min(860px, calc(100dvh - 40px)); }
.cw-win.min { height: auto; width: min(300px, calc(100vw - 24px)); border-radius: 99px; }
.cw-win.dragging { opacity: .94; user-select: none; }
.cw-win.full-on { border-color: var(--accent); }

.cw-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 14px; background: var(--side-bg); color: #fff; cursor: grab; touch-action: none; min-height: 48px; }
.cw-win.expand .cw-head, .cw-win.min .cw-head { cursor: default; }
.cw-win.min .cw-head { cursor: pointer; }
.cw-dot { width: 8px; height: 8px; border-radius: 50%; background: #8a8071; flex: none; }
.cw-dot.on { background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .2); }
.cw-title { display: grid; line-height: 1.15; min-width: 0; }
.cw-title strong { font-size: var(--fs-base); }
.cw-avail { font-size: .7rem; color: rgba(255, 255, 255, .65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-spacer { flex: 1; }
.cw-ctl { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: var(--r-sm, 8px); background: transparent; color: rgba(255, 255, 255, .85); cursor: pointer; }
.cw-ctl:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.cw-ctl:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cw-ctl[aria-expanded="true"] { background: rgba(222, 162, 2, .22); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cw-ctl.dark { color: var(--text); } .cw-ctl.dark:hover { background: var(--surface-3); }
.cw-ctl[hidden] { display: none; }

/* modo completo: estado discreto */
.cw-full { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border: 1px solid rgba(255, 255, 255, .28); border-radius: 99px; background: transparent; color: rgba(255, 255, 255, .8); font: inherit; font-size: .7rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.cw-full .cw-ic svg { width: 12px; height: 12px; }
.cw-full:hover { border-color: rgba(255, 255, 255, .55); color: #fff; }
.cw-full.on { border-color: var(--accent); color: var(--accent); background: rgba(222, 162, 2, .14); }
.cw-full-time { font-variant-numeric: tabular-nums; color: #fff; }
.cw-full[hidden] { display: none; }
.cw-win.min .cw-full-t { display: none; }
.cw-pop { position: absolute; top: 6px; right: 8px; z-index: 6; width: min(310px, calc(100% - 16px)); padding: 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg, 12px); box-shadow: 0 8px 24px rgba(20, 17, 13, .2); display: grid; gap: 8px; }
.cw-pop[hidden] { display: none; }
.cw-pop-t { margin: 0; font-size: var(--fs-sm); font-weight: 700; }
.cw-pop-n { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.cw-pop-form { display: grid; gap: 8px; }
.cw-pop-row { display: flex; gap: 6px; }
.cw-pass { flex: 1; min-width: 0; height: 34px; }
.cw-err { margin: 0; padding: 6px 8px; border-radius: var(--r-md, 10px); background: var(--err-soft); color: var(--err-ink); font-size: var(--fs-sm); }

/* cuerpo y pestañas */
.cw-body { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cw-body[hidden] { display: none; }
.cw-tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--surface); }
.cw-tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; position: relative; }
.cw-tab:hover { color: var(--text); }
.cw-tab[aria-selected="true"] { color: var(--text); }
.cw-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 14%; right: 14%; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.cw-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.cw-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cw-pane[hidden] { display: none; }
.cw-scroll { flex: 1; overflow: auto; padding: 10px 12px 14px; display: grid; gap: 10px; align-content: start; }

/* chat */
.cw-log { flex: 1; min-height: 0; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cw-msg { max-width: 92%; font-size: var(--fs-base); line-height: 1.4; }
.cw-msg p { margin: 0; white-space: pre-wrap; }
.cw-msg.user { align-self: flex-end; padding: 8px 12px; border-radius: 14px 14px 4px 14px; background: var(--accent-soft); color: var(--text); }
.cw-msg.assistant { align-self: stretch; max-width: 100%; display: flex; flex-direction: column; gap: 8px; }
.cw-hello { color: var(--text-2); }
.cw-wait { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-sm); }
.cw-ctx { display: flex; gap: 6px; padding: 4px 12px 6px; overflow-x: auto; scrollbar-width: thin; flex: none; }
.cw-chip { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--surface); color: var(--text-2); font: inherit; font-size: var(--fs-xs); white-space: nowrap; cursor: pointer; }
.cw-chip:hover { background: var(--accent-soft); border-color: var(--accent); }
.cw-chip .cw-ic svg { width: 12px; height: 12px; color: var(--accent-ink); }
.cw-compose { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px 12px; border-top: 1px solid var(--line); }
.cw-input { flex: 1; resize: none; min-height: 40px; max-height: 132px; line-height: 1.35; padding: 9px 12px; border-radius: var(--r-md, 10px); overflow-y: auto; }
.cw-send { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border: 0; border-radius: var(--r-md, 10px); background: var(--primary); color: #fff; font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.cw-send:hover:not(:disabled) { background: var(--primary-hover); }
.cw-send:disabled { opacity: .55; cursor: progress; }
.cw-send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* historial de conversaciones (superpuesto) */
.cw-overlay { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--surface); }
.cw-overlay[hidden] { display: none; }
.cw-ov-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.cw-ov-search { position: relative; display: flex; align-items: center; margin: 8px 12px 0; }
.cw-scroll > .cw-ov-search { margin: 0; }
.cw-ov-search > .cw-ic { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.cw-search { width: 100%; height: 36px; padding-left: 32px; }
.cw-conv-list { flex: 1; overflow: auto; padding: 8px 12px; display: grid; gap: 4px; align-content: start; }
.cw-conv { display: grid; text-align: left; padding: 8px 10px; border: 1px solid transparent; border-radius: var(--r-md, 10px); background: transparent; font: inherit; color: var(--text); cursor: pointer; }
.cw-conv:hover { background: var(--surface-2); border-color: var(--line); }
.cw-conv.cur { background: var(--accent-soft); }
.cw-conv strong { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-conv small { color: var(--muted); font-size: var(--fs-xs); }
.cw-ov-note, .cw-note { margin: 0; padding: 8px 12px; font-size: var(--fs-xs); color: var(--muted); }
.cw-scroll > .cw-note { padding: 0; }
.cw-empty { margin: 0; padding: 14px 4px; color: var(--muted); font-size: var(--fs-sm); text-align: center; }

/* explorar */
.cw-ex-list { display: grid; gap: 10px; }
.cw-ex-group h4 { margin: 0 0 6px; font-size: var(--fs-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cw-ex-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.cw-ex { padding: 5px 10px; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); text-align: left; cursor: pointer; }
.cw-ex:hover { background: var(--accent-soft); border-color: var(--accent); }
.cw-ex-chips.acts .cw-ex { border-style: dashed; }
.cw-no { font-size: var(--fs-sm); }
.cw-no summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); }
.cw-no ul { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.cw-no li { display: grid; font-size: var(--fs-xs); } .cw-no li span { color: var(--muted); }

/* acciones */
.cw-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cw-select { height: 34px; width: 100%; font-size: var(--fs-sm); }
.cw-act-list { display: grid; gap: 8px; }

@media (max-width: 560px) {
  .cw-win, .cw-win.expand { right: 0; bottom: 0; left: 0; top: auto; width: 100%; height: min(86dvh, 100dvh); border-radius: 14px 14px 0 0; }
  .cw-win.min { left: auto; right: 8px; bottom: 8px; width: min(300px, calc(100vw - 16px)); height: auto; border-radius: 99px; }
  .cw-fab { right: 12px; bottom: 12px; }
  .cw-send span { display: none; } .cw-send { padding: 0 12px; }
  .cw-ctl { width: 34px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) { .cw-fab { transition: none; } }

/* adjuntos y voz */
.cw-file { display: none; }
.cw-tool { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-md, 10px); background: var(--surface); color: var(--text-2); cursor: pointer; }
.cw-tool:hover { border-color: var(--accent); background: var(--accent-soft); }
.cw-tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cw-tool .cw-ic svg { width: 18px; height: 18px; }
.cw-tool.on { background: var(--err-soft); border-color: var(--err); color: var(--err-ink); animation: cw-pulse 1.4s ease-in-out infinite; }
.cw-ctl.on { color: var(--accent-ink); }
@keyframes cw-pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--err) 22%, transparent); } }
@media (prefers-reduced-motion: reduce) { .cw-tool.on { animation: none; } }
.cw-tray { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px 0; flex: none; max-height: 96px; overflow-y: auto; }
.cw-att { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 30px; padding: 0 4px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); font-size: var(--fs-xs); color: var(--text-2); }
.cw-att img { width: 24px; height: 24px; object-fit: cover; border-radius: 5px; flex: none; }
.cw-att .cw-ic { width: 24px; display: inline-flex; justify-content: center; flex: none; }
.cw-att .cw-ic svg { width: 15px; height: 15px; }
.cw-att-n { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-att-x { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; }
.cw-att-x:hover { background: var(--line); color: var(--text); }
.cw-att-x .cw-ic svg { width: 13px; height: 13px; }
.cw-att.prep { padding: 0 10px; }
.cw-att.sm { height: 26px; background: var(--surface); }
.cw-att.sm img { width: 20px; height: 20px; }
.cw-att-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.cw-msg.user .cw-att-row:first-child { margin-top: 0; }
.cw-voice { margin: 6px 12px 0; padding: 5px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); font-size: var(--fs-xs); flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-voice.err { background: var(--err-soft); color: var(--err-ink); white-space: normal; }
.cw-pane.drop { outline: 2px dashed var(--accent); outline-offset: -6px; background: var(--accent-soft); }
@media (max-width: 520px) { .cw-tool { width: 36px; } }
