/* =========================================================
   ASISTENTE · chat flotante (usa los colores de styles.css)
   ========================================================= */
.chat-launch {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 80;
  display: inline-flex; align-items: center; gap: .65rem; height: 60px; padding: 0 1.3rem 0 .45rem;
  border: 0; border-radius: 999px; cursor: pointer; font: 800 .98rem/1 var(--f); color: #160b00;
  background: linear-gradient(135deg, var(--accent), #ff9a3d); box-shadow: 0 18px 40px -12px rgba(255,122,26,.75), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .35s var(--ease), box-shadow .3s;
  animation: launchIn .7s var(--ease) .8s both;
}
@keyframes launchIn { from { transform: translateY(30px) scale(.8); opacity: 0; } }
.chat-launch:hover { transform: translateY(-3px); box-shadow: 0 24px 50px -12px rgba(255,122,26,.85); }
.chat-launch:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.cl-ico { position: relative; width: 50px; height: 50px; border-radius: 50%; background: #141414; display: grid; place-items: center; flex: none; }
.cl-ico svg { position: absolute; width: 26px; height: 26px; transition: transform .35s var(--ease), opacity .25s; }
.i-open { fill: var(--accent); } .i-open circle { fill: #141414; }
.i-close { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; opacity: 0; transform: rotate(-90deg); }
.chat-launch[aria-expanded="true"] .i-open { opacity: 0; transform: rotate(90deg) scale(.6); }
.chat-launch[aria-expanded="true"] .i-close { opacity: 1; transform: none; }
.cl-dot { position: absolute; top: 4px; right: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--wa); border: 2px solid var(--bg); }
.chat-launch.seen .cl-dot { display: none; }

.chat-teaser { position: fixed; right: 18px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 79; max-width: 260px; padding: .9rem 2.2rem .9rem 1rem; border-radius: 16px 16px 4px 16px; background: var(--card-2); border: 1px solid var(--line-2); box-shadow: 0 20px 40px -16px rgba(0,0,0,.8); font-size: .92rem; cursor: pointer; animation: teaser .5s var(--ease); }
.chat-teaser[hidden] { display: none; }
.chat-teaser p { margin: 0; color: var(--muted); } .chat-teaser b { color: var(--accent); }
.ct-close { position: absolute; top: 6px; right: 8px; background: none; border: 0; color: var(--dim); font-size: 1.2rem; cursor: pointer; line-height: 1; padding: 4px; }
@keyframes teaser { from { opacity: 0; transform: translateY(10px) scale(.96); } }

.chat-panel {
  position: fixed; right: 18px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 81;
  width: min(400px, calc(100vw - 36px)); height: min(640px, calc(100vh - 120px)); height: min(640px, calc(100dvh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: rgba(24,24,24,.97); backdrop-filter: blur(20px) saturate(1.2); -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid var(--line-2); border-radius: 24px; box-shadow: 0 40px 90px -20px rgba(0,0,0,.85), 0 0 0 1px rgba(255,122,26,.08);
  transform-origin: 100% 100%; animation: panelIn .42s var(--ease);
}
.chat-panel[hidden] { display: none; }
@keyframes panelIn { from { opacity: 0; transform: translateY(16px) scale(.94); } }
.chat-panel::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.cp-head { display: flex; align-items: center; gap: .75rem; padding: 1rem 1rem .9rem; border-bottom: 1px solid var(--line); }
.cp-ava { width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; flex: none; }
.cp-ava svg { width: 22px; height: 22px; fill: #160b00; }
.cp-title { flex: 1; min-width: 0; line-height: 1.25; }
.cp-title b { display: block; font-weight: 800; font-size: 1rem; }
.cp-title small { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .76rem; }
.cp-live { width: 7px; height: 7px; border-radius: 50%; background: var(--wa); box-shadow: 0 0 0 3px rgba(37,211,102,.2); }
.cp-wa, .cp-x { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; border: 1px solid var(--line-2); background: transparent; cursor: pointer; flex: none; transition: background .2s, border-color .2s; }
.cp-wa svg { width: 20px; height: 20px; fill: var(--wa); }
.cp-x svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.cp-wa:hover { background: rgba(37,211,102,.12); border-color: var(--wa); }
.cp-x:hover { background: rgba(255,255,255,.06); }

.cp-body { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; overscroll-behavior: contain; }
.cp-body::-webkit-scrollbar { width: 6px; } .cp-body::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
.msg { max-width: 88%; padding: .75rem .95rem; border-radius: 18px; font-size: .94rem; line-height: 1.5; animation: msgIn .35s var(--ease); overflow-wrap: anywhere; }
.msg p { margin: 0 0 .5rem; } .msg p:last-child { margin: 0; }
.msg ul { margin: .3rem 0 .5rem; padding-left: 1.1rem; } .msg li { margin: .15rem 0; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.msg.bot { align-self: flex-start; background: var(--card-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; color: #dcd8d1; }
.msg.bot b { color: var(--ink); }
.msg.user { align-self: flex-end; background: var(--accent); color: #160b00; font-weight: 500; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.urgent { border-color: rgba(255,77,61,.55); }
.msg-alert { display: flex; gap: .5rem; align-items: flex-start; margin: 0 0 .6rem; padding: .55rem .7rem; border-radius: 10px; background: rgba(255,77,61,.14); color: #ffb3aa; font-size: .84rem; font-weight: 700; }
.msg-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .75rem; }
.msg-btn { display: inline-flex; align-items: center; gap: .45rem; min-height: 38px; padding: .5rem .85rem; border-radius: 999px; font: 700 .84rem/1.1 var(--f); text-decoration: none; cursor: pointer; border: 1.5px solid transparent; transition: transform .2s, background .2s; }
.msg-btn:hover { transform: translateY(-1px); }
.msg-btn.wa { background: var(--wa); color: #08200f; }
.msg-btn.wa svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.msg-btn.diag { background: transparent; color: var(--accent); border-color: rgba(255,122,26,.5); }
.msg-btn.diag:hover { background: rgba(255,122,26,.12); }
.typing { align-self: flex-start; display: flex; gap: 5px; padding: .9rem 1rem; background: var(--card-2); border: 1px solid var(--line); border-radius: 18px 18px 18px 6px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); animation: typing 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }

.cp-sugs { display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; margin-top: .2rem; }
.cp-sug { text-align: left; padding: .6rem .85rem; border-radius: 14px; border: 1px solid rgba(255,122,26,.35); background: rgba(255,122,26,.06); color: var(--ink); font: 500 .88rem/1.35 var(--f); cursor: pointer; transition: background .2s, border-color .2s, transform .2s; animation: msgIn .4s var(--ease) both; }
.cp-sug:nth-child(2) { animation-delay: .08s; } .cp-sug:nth-child(3) { animation-delay: .16s; } .cp-sug:nth-child(4) { animation-delay: .24s; }
.cp-sug:hover { background: rgba(255,122,26,.14); border-color: var(--accent); transform: translateX(3px); }

.cp-form { display: flex; align-items: flex-end; gap: .5rem; padding: .75rem .75rem .4rem; border-top: 1px solid var(--line); }
.cp-form textarea { flex: 1; min-height: 46px; max-height: 120px; resize: none; overflow-y: hidden; padding: .75rem .95rem; border-radius: 16px; font-size: 1rem; line-height: 1.35; }
.cp-send { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); cursor: pointer; display: grid; place-items: center; flex: none; transition: transform .2s, opacity .2s; }
.cp-send svg { width: 20px; height: 20px; fill: none; stroke: #160b00; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.cp-send:hover { transform: scale(1.06); }
.cp-send:disabled { opacity: .4; cursor: default; transform: none; }
.cp-note { margin: 0; padding: .1rem 1rem .75rem; font-size: .72rem; color: var(--dim); text-align: center; }

.ask-ai { margin-top: 1rem; width: 100%; white-space: normal; text-align: center; }

@keyframes panelUp { from { transform: translateY(40px); opacity: 0; } }
@media (max-width: 600px) {
  .chat-launch { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); padding: 0 .45rem; }
  .chat-launch .cl-txt { display: none; }
  .chat-teaser { right: 14px; bottom: calc(86px + env(safe-area-inset-bottom)); max-width: calc(100vw - 100px); }
  .chat-panel { inset: 0; right: 0; bottom: 0; width: 100%; height: 100%; border-radius: 0; border: 0; animation-name: panelUp; }
  .chat-open .chat-launch, .chat-open .chat-teaser { display: none; }
  .cp-head { padding-top: calc(1rem + env(safe-area-inset-top)); }
  .cp-note { padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
  html.chat-open, html.chat-open body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-launch { animation: none; }
}
