/* ═════════════ Asistente ═════════════ */
.asst-launcher{position:fixed;z-index:850;right:24px;bottom:24px;display:flex;align-items:center;gap:10px;height:58px;padding:0 20px 0 7px;border-radius:999px;background:color-mix(in srgb,var(--bg-2) 80%,transparent);border:1px solid var(--border-2);box-shadow:0 18px 40px -12px rgba(0,0,20,.55);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);font-weight:620;font-size:14.5px;transition:transform .35s var(--ease),bottom .35s var(--ease),opacity .3s}
.asst-launcher:hover{transform:translateY(-3px)}
.al-orb{position:relative;display:grid;place-items:center;width:44px;height:44px;border-radius:50%;background:var(--grad) border-box;box-shadow:var(--glow)}
.al-orb::after{content:"";position:absolute;inset:-4px;border-radius:50%;border:1px solid rgba(120,120,255,.5);animation:ripple 2.8s infinite}
.al-orb img{width:26px;filter:brightness(0) invert(1)}
body.asst-open .asst-launcher{opacity:0;pointer-events:none;transform:scale(.9)}
body.ck-visible .asst-launcher{bottom:128px}
.asst-nudge{position:fixed;z-index:850;right:24px;bottom:94px;max-width:260px;padding:14px 34px 14px 16px;border-radius:18px 18px 6px 18px;background:var(--surface-solid);border:1px solid var(--border-2);box-shadow:var(--glass-shadow);font-size:14px;font-weight:540;animation:toastIn .5s var(--ease-spring);cursor:pointer}
.an-close{position:absolute;right:8px;top:8px;color:var(--text-3)}
.an-close .icon{width:16px}
.asst{position:fixed;z-index:900;right:24px;bottom:24px;width:min(410px,calc(100% - 32px));height:min(640px,calc(100dvh - 120px));display:flex;flex-direction:column;border-radius:28px;background:color-mix(in srgb,var(--bg-2) 90%,transparent);border-color:var(--border-2);overflow:hidden;animation:asstIn .45s var(--ease-spring);transform-origin:100% 100%}
@keyframes asstIn{from{opacity:0;transform:scale(.9) translateY(20px)}}
.asst-head{display:flex;align-items:center;gap:10px;padding:14px 14px 12px;border-bottom:1px solid var(--border)}
.asst-head .icon-btn{width:36px;height:36px;border-radius:12px}
.asst-orb{position:relative;display:grid;place-items:center;width:42px;height:42px;border-radius:14px;background:var(--grad) border-box;flex-shrink:0}
.asst-orb img{width:24px;filter:brightness(0) invert(1)}
.asst-orb .sync-dot{position:absolute;right:-2px;bottom:-2px;border:2px solid var(--bg-2);width:12px;height:12px}
.asst-id{display:grid;flex:1;line-height:1.3}
.asst-id small{font-size:12px;color:var(--text-3)}
.asst-log{flex:1;overflow-y:auto;padding:16px 14px;display:flex;flex-direction:column;gap:10px;scrollbar-width:thin;overscroll-behavior:contain}
.msg{max-width:90%;padding:11px 14px;border-radius:18px;font-size:14.5px;line-height:1.55;animation:msgIn .35s var(--ease)}
@keyframes msgIn{from{opacity:0;transform:translateY(8px)}}
.msg.bot{align-self:flex-start;background:var(--surface-2);border:1px solid var(--border);border-bottom-left-radius:6px}
.msg.user{align-self:flex-end;background:var(--grad) border-box;color:#fff;border-bottom-right-radius:6px}
.msg strong{font-weight:680}
.msg-actions,.msg-chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
.msg-actions .chip{background:var(--grad) border-box;color:#fff;border:0;font-weight:620}
.msg-actions .chip .icon{width:15px;height:15px}
.msg-chips .chip{font-size:13px;padding:7px 11px;text-align:left}
.typing-dots{display:inline-flex;gap:4px;padding:4px 2px}
.typing-dots i{width:7px;height:7px;border-radius:50%;background:var(--text-3);animation:dotb 1.1s infinite}
.typing-dots i:nth-child(2){animation-delay:.15s}.typing-dots i:nth-child(3){animation-delay:.3s}
@keyframes dotb{50%{transform:translateY(-4px);opacity:.4}}
.asst-form{display:flex;gap:8px;padding:10px 12px 6px;border-top:1px solid var(--border)}
.asst-form input{flex:1;min-width:0;height:46px;padding:0 16px;border-radius:999px;border:1px solid var(--border-2);background:var(--surface);font-size:15px}
.asst-form input:focus{outline:0;border-color:var(--blue);box-shadow:0 0 0 4px rgba(18,96,255,.16)}
.asst-send{display:grid;place-items:center;width:46px;height:46px;border-radius:50%;background:var(--grad) border-box;color:#fff;flex-shrink:0;box-shadow:var(--glow)}
.asst-note{padding:4px 16px 12px;font-size:11px;color:var(--text-3);text-align:center}

/* ═════════════ Cookies ═════════════ */
.consent-banner{position:fixed;z-index:860;left:50%;bottom:20px;transform:translateX(-50%);width:min(980px,calc(100% - 32px));display:flex;align-items:center;gap:16px;padding:16px 18px;border-radius:24px;background:color-mix(in srgb,var(--bg-2) 90%,transparent);border-color:var(--border-2);animation:ckIn .6s var(--ease-spring)}
@keyframes ckIn{from{opacity:0;transform:translate(-50%,30px)}}
.ck-ico{display:grid;place-items:center;width:46px;height:46px;border-radius:15px;background:var(--grad) border-box;color:#fff;flex-shrink:0}
.ck-text{flex:1;font-size:13.5px;color:var(--text-2)}
.ck-text strong{display:block;color:var(--text);font-size:15px;margin-bottom:2px}
.ck-text a{text-decoration:underline;color:var(--text)}
.ck-actions{display:flex;gap:8px;flex-wrap:wrap}
.ck-actions.end{justify-content:flex-end;margin-top:20px}
.ck-cats{display:grid;gap:10px;margin-top:16px}
.ck-cat{display:flex;align-items:center;gap:16px;padding:14px 16px;border-radius:18px;border:1px solid var(--border);background:var(--surface);cursor:default}
label.ck-cat{cursor:pointer}
.ck-cat div{flex:1}
.ck-cat p{font-size:13px;color:var(--text-2);margin-top:3px}
.ck-cat.off{opacity:.65}
.ck-always{font-size:12px;font-weight:650;color:var(--success);white-space:nowrap}
.ck-cat.off .ck-always{color:var(--text-3)}
.toggle{-webkit-appearance:none;appearance:none;position:relative;width:46px;height:28px;border-radius:28px;background:var(--border-2);cursor:pointer;flex-shrink:0;transition:background .3s}
.toggle::after{content:"";position:absolute;left:3px;top:3px;width:22px;height:22px;border-radius:50%;background:#fff;box-shadow:0 2px 6px rgba(0,0,0,.25);transition:transform .35s var(--ease-spring)}
.toggle:checked{background:var(--blue)}
.toggle:checked::after{transform:translateX(18px)}

/* Posición del coach de la demo junto al lanzador */
@media (min-width:721px){.coach{right:auto;left:24px}}

@media (max-width:720px){
  .asst-launcher,.asst-nudge{display:none}
  .asst{inset:auto 0 0 0;width:100%;height:min(88dvh,720px);border-radius:26px 26px 0 0;animation:sheetIn .45s var(--ease)}
  @keyframes sheetIn{from{transform:translateY(100%)}}
  .asst-note{padding-bottom:max(12px,env(safe-area-inset-bottom))}
  .consent-banner{flex-direction:column;align-items:stretch;bottom:calc(var(--dock-h) + 16px);gap:12px;padding:16px}
  .consent-banner .ck-ico{display:none}
  .ck-actions .btn{flex:1}
  .ck-actions [data-ck="settings"]{flex-basis:100%;order:3}
}

/* ═════════════ Chat en vivo ═════════════ */
.asst-human{position:relative}
.asst-human .dot{position:absolute;top:6px;right:6px;width:8px;height:8px;border-radius:50%;background:var(--success);display:none;box-shadow:0 0 0 2px var(--bg-2)}
.asst-human.active .dot{display:block}
.asst-livebar{display:flex;align-items:center;gap:8px;padding:8px 14px;font-size:12.5px;color:var(--text-2);background:var(--surface);border-bottom:1px solid var(--border)}
.asst-livebar [data-live-status]{flex:1}
.asst-livebar .link-btn{display:inline-flex;align-items:center;gap:4px;font-size:12.5px;color:var(--cyan)}
.asst-livebar .link-btn .icon{width:14px;height:14px}
.asst.is-live .asst-orb{background:linear-gradient(135deg,#1fd49a,#0891b2)}
.msg.live-card{max-width:100%;width:100%}
.live-note{font-size:13px;color:var(--text-2);margin:4px 0 10px}
.live-form{display:grid;gap:8px}
.live-form input,.live-form textarea{width:100%;padding:10px 12px;border-radius:12px;border:1px solid var(--border-2);background:var(--surface);font-size:14px;resize:vertical}
.live-form input:focus,.live-form textarea:focus{outline:0;border-color:var(--blue)}
.live-form .check{font-size:12px}
.msg.agent{border-color:color-mix(in srgb,var(--success) 45%,transparent)}
.agent-name{display:block;font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--success);margin-bottom:2px}
.msg.system{align-self:center;max-width:92%;padding:6px 12px;font-size:12px;color:var(--text-3);background:transparent;border:1px dashed var(--border-2);border-radius:999px;text-align:center}
.asst-launcher.has-unread .al-orb::before,.dock-assistant.has-unread .dock-orb::before{content:"";position:absolute;top:-3px;right:-3px;width:14px;height:14px;border-radius:50%;background:var(--danger);box-shadow:0 0 0 3px var(--bg);z-index:2}
.dock-orb{position:relative}

/* ── Atención humana y casos (v3.2) ── */
.asst.is-waiting .asst-orb{background:linear-gradient(135deg,#ffb547,#ff7a59)}
.asst-livebar[data-tone="wait"] .sync-dot{background:var(--warn);animation:pulse 1.4s infinite}
.asst-livebar[data-tone="ok"] .sync-dot{background:var(--success)}
.live-hint{font-size:12px;color:var(--text-3);margin:2px 2px -2px}
.live-err{font-size:12.5px;color:var(--danger);margin:0}
.live-form .link-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;font-size:13px;color:var(--cyan);padding:4px;font-weight:600}
.live-form .link-btn .icon{width:15px;height:15px}
.live-form input.bad,.live-form textarea.bad{border-color:var(--danger)}
.live-form .btn.is-loading{opacity:.7;pointer-events:none}
.msg.wait-msg{max-width:100%;width:100%;display:grid;gap:6px}
.msg.wait-msg .link-btn{display:inline-flex;align-items:center;gap:6px;font-size:13px;font-weight:600;color:var(--cyan);justify-self:start}
.msg.wait-msg .link-btn .icon{width:15px;height:15px}
.wait-card{display:flex;gap:12px;align-items:flex-start}
.wait-card strong{display:block;font-size:14px}
.wait-card p{font-size:13px;color:var(--text-2);margin:2px 0 8px}
.wait-card small{font-size:12px;color:var(--text-3);font-variant-numeric:tabular-nums}
.wait-ring{position:relative;width:34px;height:34px;flex-shrink:0;border-radius:50%;border:3px solid var(--surface-3);border-top-color:var(--warn);animation:spin 1s linear infinite}
.wait-ring i{position:absolute;inset:6px;border-radius:50%;background:var(--grad) border-box;opacity:.25}
.wait-bar{height:6px;border-radius:999px;background:var(--surface-3);overflow:hidden;margin-bottom:4px}
.wait-bar i{display:block;height:100%;width:100%;border-radius:inherit;background:linear-gradient(90deg,#ffb547,#ff7a59);transition:width 1s linear}
.case-known{list-style:none;margin:0;padding:8px 10px;border-radius:12px;background:var(--surface);border:1px solid var(--border);display:grid;gap:4px;font-size:13px}
.case-known li{display:flex;justify-content:space-between;gap:10px;min-width:0}
.case-known span{color:var(--text-3)}
.case-known b{font-weight:600;text-align:right;overflow-wrap:anywhere}
.msg.case-ok{border-color:rgba(31,212,154,.45)!important;background:rgba(31,212,154,.1)!important}
@media (prefers-reduced-motion:reduce){.wait-ring{animation:none}.wait-bar i{transition:none}}
.live-form .check input{width:18px;height:18px;min-width:18px;flex:none;padding:0;margin-top:2px}
/* v3.3 · Archivos del visitante */
.asst-clip{display:grid;place-items:center;width:46px;height:46px;border-radius:50%;border:1px solid var(--border-2);background:var(--surface);color:var(--text-2);flex-shrink:0}
.asst-clip:hover{color:var(--text);border-color:var(--blue)}
.asst-clip .icon{width:20px;height:20px}
.asst-file{display:inline-flex;align-items:center;gap:8px;max-width:100%}
.asst-file .icon{width:18px;height:18px;flex:none}
.asst-file>span{display:grid;min-width:0}
.asst-file b{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.asst-file small{font-size:11px;opacity:.8}
.asst-up{display:block;font-size:11px;opacity:.8;margin-top:4px}
.msg.user.failed{opacity:.5;text-decoration:line-through}
.live-form .asst-attach{display:flex;align-items:center;gap:8px;padding:9px 12px;border-radius:12px;border:1px dashed var(--border-2);font-size:13px;color:var(--text-2);cursor:pointer;position:relative}
.live-form .asst-attach:hover,.live-form .asst-attach:focus-within{border-color:var(--blue);color:var(--text)}
.live-form .asst-attach .icon{width:18px;height:18px;flex:none}
.live-form .asst-attach input{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;padding:0}
.asst-files{list-style:none;margin:0;padding:0;display:grid;gap:6px}
.asst-files:empty{display:none}
.asst-files li{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 10px;border-radius:10px;background:var(--surface);font-size:12px}
/* v4.1: estado de envío del chat humano */
.msg.user.is-sending{opacity:.65}
.msg.user.is-failed{opacity:.85;outline:1px dashed rgba(255,255,255,.6)}
.msg-fail{display:block;margin-top:.35rem;font-size:.78em;opacity:.95}
.msg-retry{background:rgba(255,255,255,.18);color:inherit;border:0;border-radius:999px;padding:.15rem .6rem;font:inherit;cursor:pointer;margin-left:.3rem}
.msg-retry:focus-visible{outline:2px solid #fff;outline-offset:2px}
