/* ═══════════ Asistente IA (chat) ═══════════ */
.chat-fab { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 70; display: flex; align-items: center; gap: 12px;
  height: 62px; padding: 0 22px 0 8px; border-radius: 40px; background: #000; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 2px var(--y);
  transition: transform .3s var(--ease), bottom .35s var(--ease); animation: chat-in .5s var(--ease) both .8s; }
.chat-fab:hover { transform: translateY(-2px); }
.chat-fab[hidden] { display: none; }
.chat-fab__n { position: absolute; top: -6px; right: -4px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--bad); color: #fff;
  font-family: var(--f-d); font-weight: 800; font-size: 15px; line-height: 24px; text-align: center; box-shadow: 0 0 0 3px #000; }
.chat-fab__n[hidden] { display: none; }
.chat-fab--aviso { animation: chat-aviso 1.6s ease-in-out 3; }
@keyframes chat-aviso { 0%, 100% { transform: none; } 15% { transform: translateY(-6px); } 30% { transform: none; } 45% { transform: translateY(-3px); } }
.chat-fab svg { width: 46px; height: 46px; padding: 10px; border-radius: 50%; background: var(--y); fill: none; stroke: #000; stroke-width: 2; stroke-linejoin: round; }
.chat-fab svg .b { fill: #000; stroke: none; }
.chat-fab__t { display: grid; line-height: 1.05; text-align: left; }
.chat-fab__t b { font-family: var(--f-d); font-weight: 800; font-size: 18px; text-transform: uppercase; letter-spacing: .03em; }
.chat-fab__t small { font-size: 12px; color: #bdbdbd; }
body:has(.sticky-buy.show) .chat-fab { bottom: calc(84px + env(safe-area-inset-bottom)); }
@keyframes chat-in { from { opacity: 0; transform: translateY(20px) scale(.9); } }

.chat { position: fixed; right: 20px; bottom: 20px; z-index: 100; width: min(420px, calc(100vw - 40px)); height: min(680px, calc(100dvh - 40px)); display: flex; flex-direction: column;
  background: #0b0b0b; color: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.08);
  opacity: 0; transform: translateY(16px) scale(.98); transform-origin: bottom right; transition: opacity .25s, transform .35s var(--ease); }
.chat.open { opacity: 1; transform: none; }
.chat[hidden] { display: none; }

.chat__hd { position: relative; display: flex; align-items: center; gap: 6px; padding: 18px 10px 12px 16px; background: #000; border-bottom: 1px solid var(--line-d); }
.chat__stripe { position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--stripes); }
.chat__who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.chat__who b { display: block; font-family: var(--f-d); font-weight: 800; font-size: 20px; text-transform: uppercase; letter-spacing: .03em; line-height: 1; }
.chat__who small { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mute-d); margin-top: 3px; }
.chat__av svg { width: 38px; height: 38px; padding: 8px; border-radius: 50%; background: var(--y); fill: none; stroke: #000; stroke-width: 2; stroke-linejoin: round; }
.chat__av svg .b { fill: #000; stroke: none; }
.chat__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(25,164,99,.25); }
.chat__ib { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: #fff; }
.chat__ib:hover { background: var(--steel-2); }
.chat__ib svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chat__log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; scroll-behavior: smooth;
  background: radial-gradient(120% 60% at 50% 0%, #1a1a1a 0%, #0b0b0b 60%); }
.chat__m { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.45; word-wrap: break-word; }
.chat__m p { margin: 0; }
.chat__m p + p, .chat__m p + ul, .chat__m ul + p { margin-top: 6px; }
.chat__m ul { margin: 4px 0; padding-left: 18px; }
.chat__m li { margin: 2px 0; }
.chat__m a { color: var(--y); text-decoration: underline; text-underline-offset: 2px; }
.chat__m b { color: #fff; }
.chat__m--bot { align-self: flex-start; background: var(--steel-2); border-top-left-radius: 4px; color: #eaeaea; }
.chat__m--me { align-self: flex-end; background: var(--y); color: #000; border-top-right-radius: 4px; font-weight: 500; white-space: pre-wrap; }
.chat__m--err { background: #2a1513; border: 1px solid rgba(214,58,47,.4); }
.chat__hello { border: 1px solid rgba(255,176,0,.25); }
.chat__typing { display: flex; align-items: center; gap: 4px; color: var(--mute-d); font-size: 13px; }
.chat__typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--y); animation: chat-dot 1s infinite ease-in-out; }
.chat__typing i:nth-child(2) { animation-delay: .15s; }
.chat__typing i:nth-child(3) { animation-delay: .3s; }
.chat__typing span { margin-left: 6px; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.chat__chips { display: flex; gap: 8px; padding: 0 14px 10px; overflow-x: auto; scrollbar-width: none; }
.chat__chips:empty { display: none; }
.chat__chip { flex: none; padding: 8px 14px; border-radius: 30px; border: 1px solid rgba(255,176,0,.5); color: var(--y); font-size: 14px; font-weight: 600; background: rgba(255,176,0,.06); }
.chat__chip:hover { background: var(--y); color: #000; }

.chat__in { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line-d); background: #000; }
.chat__in textarea { flex: 1; resize: none; min-height: 46px; max-height: 140px; padding: 12px 14px; border-radius: 14px; border: 1px solid #2a2a2a; background: var(--steel); color: #fff; font-size: 16px; line-height: 1.35; overflow-y: hidden; }
.chat__in textarea:focus { outline: none; border-color: var(--y); }
.chat__send { width: 46px; height: 46px; flex: none; border-radius: 14px; background: var(--y); display: grid; place-items: center; }
.chat__send:disabled { opacity: .5; }
.chat__send svg { width: 22px; height: 22px; fill: none; stroke: #000; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chat__legal { margin: 0; padding: 0 14px 10px; background: #000; font-size: 11px; line-height: 1.35; color: #8a8a8a; }
.chat__legal a { text-decoration: underline; }

/* Tarjetas de producto (vitrina) */
.chat-cards { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; scroll-snap-type: x mandatory; scrollbar-width: none; flex: none; }
.chat-cards::-webkit-scrollbar { display: none; }
.chat-card { flex: none; width: 210px; scroll-snap-align: start; display: flex; flex-direction: column; background: var(--paper); color: #000; border-radius: 14px; overflow: hidden; }
.chat-cards--1 .chat-card { width: 100%; flex-direction: row; }
.chat-card__img { position: relative; display: block; height: 150px; flex: none; background: radial-gradient(70% 60% at 50% 35%, #fff 0%, #f1ede2 55%, #e2ddcf 100%); }
.chat-card__img::after { content: ''; position: absolute; left: 18%; right: 18%; bottom: 8%; height: 10px; border-radius: 50%; background: radial-gradient(closest-side, rgba(0,0,0,.25), transparent); }
.chat-cards--1 .chat-card__img { width: 128px; height: auto; min-height: 150px; }
.chat-card__img img, .chat-card__img .packshot { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.chat-card__b { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; flex: 1; min-width: 0; }
.chat-card__brand { font-family: var(--f-d); font-weight: 700; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute-l); }
.chat-card__name { font-family: var(--f-d); font-weight: 800; font-size: 19px; line-height: 1; text-transform: uppercase; }
.chat-card__row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.chat-card__price { font-family: var(--f-d); font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; }
.chat-card__price s { font-size: 14px; color: var(--mute-l); font-weight: 600; }
.chat-card__disp { font-size: 12px; font-weight: 700; color: var(--ok); }
.chat-card__disp[data-k="ultimas"] { color: var(--warn); }
.chat-card__disp[data-k="agotado"] { color: var(--bad); }
.chat-card__sel { width: 100%; height: 38px; border-radius: 8px; border: 1px solid #cfc9bb; background: #fff; padding: 0 8px; font-size: 14px; color: #000; }
.chat-card__add { margin-top: auto; height: 42px; border-radius: 8px; background: #000; color: #fff; font-family: var(--f-d); font-weight: 800; font-size: 16px; letter-spacing: .05em; text-transform: uppercase; }
.chat-card__add:hover:not(:disabled) { background: var(--y); color: #000; }
.chat-card__add:disabled { background: #cfc9bb; color: #666; cursor: default; }
.chat-card__add[data-hecho], .chat-card__add[data-hecho]:hover { background: var(--ok); color: #fff; }

/* Cajas: cesta, pago, pedido, comparar */
.chat-box { align-self: stretch; background: #151515; border: 1px solid #2a2a2a; border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.chat-box h4 { margin: 0 0 8px; font-family: var(--f-d); font-weight: 800; font-size: 18px; text-transform: uppercase; color: var(--y); }
.chat-box ul { margin: 0 0 10px; padding: 0; list-style: none; display: grid; gap: 6px; }
.chat-box li small { color: var(--mute-d); }
.chat-box__v { display: inline-block; font-weight: 700; font-size: 12px; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--y); color: #000; }
.chat-box__v[data-k="quitar"] { background: var(--bad); color: #fff; }
.chat-box__btns { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-box__ok { margin: 0; color: var(--mute-d); }
.chat-box__sum { margin: 0 0 10px; }
.chat-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 10px; background: var(--steel-2); color: #fff; font-family: var(--f-d); font-weight: 800; font-size: 16px; letter-spacing: .05em; text-transform: uppercase; }
.chat-btn--y { background: var(--y); color: #000; }
.chat-btn--block { width: 100%; }
.chat-btn--block + .chat-btn--block { margin-top: 8px; }
.chat-btn--wa { background: #25d366; color: #000; }
.chat-btn--wa svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.chat-wa { align-self: flex-start; }
.chat-link { display: inline-block; margin-top: 10px; color: var(--y); font-weight: 700; text-decoration: underline; }
.chat-ped label { display: grid; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--mute-d); }
.chat-ped input { height: 44px; border-radius: 10px; border: 1px solid #2a2a2a; background: #0b0b0b; color: #fff; padding: 0 12px; font-size: 16px; }
.chat-ped input:focus { outline: none; border-color: var(--y); }
.chat-ped small { display: block; margin-top: 8px; color: #8a8a8a; font-size: 12px; }
.chat-cmp__wrap { overflow-x: auto; }
.chat-cmp table { border-collapse: collapse; width: 100%; font-size: 13px; }
.chat-cmp th, .chat-cmp td { padding: 6px 8px; text-align: left; border-bottom: 1px solid #262626; vertical-align: top; }
.chat-cmp thead th { font-family: var(--f-d); font-size: 15px; text-transform: uppercase; line-height: 1.05; min-width: 110px; }
.chat-cmp thead th small { display: block; font-family: var(--f-t); text-transform: none; font-size: 11px; color: var(--mute-d); font-weight: 500; margin-top: 2px; }
.chat-cmp tbody th { color: var(--mute-d); font-weight: 600; white-space: nowrap; }
.chat-cmp td { font-variant-numeric: tabular-nums; font-weight: 700; }

/* Móvil: pantalla completa */
@media (max-width: 640px) {
  .chat-fab { height: 58px; width: 58px; padding: 0; justify-content: center; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
  .chat-fab svg { width: 50px; height: 50px; }
  .chat-fab__t { display: none; }
  .chat { inset: 0; width: 100%; height: 100dvh; border-radius: 0; transform: translateY(30px); }
  .chat__hd { padding-top: calc(16px + env(safe-area-inset-top)); }
  .chat__legal { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .chat__m { max-width: 92%; }
  html.chat-on, html.chat-on body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .chat, .chat-fab { transition: none; animation: none; } .chat__log { scroll-behavior: auto; } }
@media print { .chat, .chat-fab { display: none !important; } }
