/* ==========================================================================
   Botón flotante + chat con la asistente (ver assets/js/components/chat-widget.js).
   ========================================================================== */
.chat-widget {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
  pointer-events: none;
}
.chat-widget > * { pointer-events: auto; }
@media (min-width: 768px) { .chat-widget { right: 24px; bottom: 24px; } }

.chat-widget__button {
  position: relative;
  width: 60px; height: 60px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--color-primary); color: #fff;
  box-shadow: 0 10px 26px rgba(200, 16, 46, .45);
  transition: transform .2s var(--ease), background .2s;
}
.chat-widget__button:hover { transform: scale(1.07); background: var(--color-accent-red); }
.chat-widget__button .icon { width: 30px; height: 30px; }
.chat-widget__button::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--color-primary);
  animation: chat-pulse 2.2s ease-out infinite;
}
.chat-widget__dot {
  position: absolute; top: 3px; right: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--color-whatsapp); border: 2px solid #fff;
}
@keyframes chat-pulse {
  0% { transform: scale(1); opacity: .8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.chat-widget__bubble {
  position: relative;
  max-width: 250px;
  background: #fff; color: var(--color-text);
  border-radius: 16px 16px 4px 16px;
  padding: 14px 34px 14px 16px;
  box-shadow: var(--shadow-lg);
  font-size: .86rem; line-height: 1.4;
  animation: bubble-in .35s var(--ease);
}
.chat-widget__bubble[hidden] { display: none; }
.chat-widget__bubble strong { display: block; font-family: var(--font-display); margin-bottom: 2px; }
.chat-widget__bubble-close {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; color: var(--color-text-soft);
}
.chat-widget__bubble-close:hover { background: var(--color-bg-alt); }
.chat-widget__bubble-close .icon { width: 14px; height: 14px; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(10px) scale(.95); } }

@media (prefers-reduced-motion: reduce) {
  .chat-widget__button::before { animation: none; }
}

/* ---------- Ícono del botón (abrir / cerrar) ---------- */
.chat-widget__ico { display: grid; place-items: center; }
.chat-widget__ico .icon { width: 28px; height: 28px; }
.chat-widget__ico--close { display: none; }
.chat-widget.is-open .chat-widget__ico--open { display: none; }
.chat-widget.is-open .chat-widget__ico--close { display: grid; }
.chat-widget.is-open .chat-widget__button::before,
.chat-widget.is-open .chat-widget__dot { display: none; }

/* ---------- Panel del chat ---------- */
.chat-panel {
  display: flex; flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 120px));
  background: #fff; color: var(--color-text);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  animation: bubble-in .25s var(--ease);
  transform-origin: bottom right;
}
.chat-panel[hidden] { display: none; }
@media (max-width: 599px) {
  .chat-widget.is-open { inset: 0; right: 0; bottom: 0; }
  .chat-widget.is-open .chat-widget__button { display: none; }
  .chat-panel { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
}

.chat-panel__head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 10px 12px 14px;
  background: var(--color-dark); color: #fff;
  border-bottom: 3px solid var(--color-primary);
}
.chat-panel__avatar { width: 40px; height: 40px; flex: none; }
.chat-panel__avatar img { width: 100%; height: 100%; }
.chat-panel__who { flex: 1; min-width: 0; line-height: 1.25; }
.chat-panel__who strong { display: block; font-family: var(--font-display); font-size: 1rem; }
.chat-panel__who span { display: flex; align-items: center; gap: 6px; font-size: .74rem; color: rgba(255, 255, 255, .75); }
.chat-panel__online { width: 8px; height: 8px; border-radius: 50%; background: var(--color-whatsapp); flex: none; }
.chat-panel__icon-btn {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 1.15rem; color: #fff;
}
.chat-panel__icon-btn:hover { background: rgba(255, 255, 255, .12); }
.chat-panel__icon-btn .icon { width: 20px; height: 20px; }

.chat-panel__body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 14px; display: flex; flex-direction: column; gap: 10px;
  background: #F4F1EC;
}
.chat-msg { display: flex; flex-direction: column; gap: 6px; max-width: 86%; }
.chat-msg--bot { align-self: flex-start; }
.chat-msg--user { align-self: flex-end; align-items: flex-end; }
.chat-msg__bubble {
  padding: 10px 13px; border-radius: 16px; font-size: .9rem; line-height: 1.45;
  overflow-wrap: anywhere; box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.chat-msg--bot .chat-msg__bubble { background: #fff; border-bottom-left-radius: 4px; }
.chat-msg--user .chat-msg__bubble { background: var(--color-primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg__bubble a { color: inherit; text-decoration: underline; }
.chat-msg__acciones { display: flex; flex-direction: column; gap: 6px; }
.chat-accion {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border-radius: 12px;
  font-family: var(--font-display); font-weight: 700; font-size: .85rem; color: #fff;
  background: var(--color-whatsapp); box-shadow: 0 4px 12px rgba(37, 211, 102, .3);
  transition: transform .15s var(--ease), filter .15s;
}
.chat-accion:hover { transform: translateY(-1px); filter: brightness(.95); }
.chat-accion--persona { background: var(--color-dark); box-shadow: none; }
.chat-accion .icon { width: 18px; height: 18px; }
.chat-pedido {
  background: #fff; border-radius: 12px; padding: 10px 12px;
  border: 1.5px dashed var(--color-accent); font-size: .82rem;
  display: grid; gap: 4px;
}
.chat-pedido strong { font-family: var(--font-display); font-size: .85rem; }
.chat-pedido div { display: flex; justify-content: space-between; gap: 10px; }
.chat-pedido__total { border-top: 1px solid var(--color-border); padding-top: 6px; margin-top: 2px; font-weight: 800; color: var(--color-primary); }

.chat-typing { display: flex; gap: 4px; padding: 14px 16px; }
.chat-typing i { width: 7px; height: 7px; border-radius: 50%; background: #B9B2A8; animation: chat-typing 1.2s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: .15s; }
.chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-typing { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-panel__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 2px; background: #F4F1EC; }
.chat-panel__chips[hidden] { display: none; }
.chat-chip {
  padding: 7px 12px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: #fff; border: 1.5px solid rgba(200, 16, 46, .35); color: var(--color-primary);
  transition: background .15s, color .15s;
}
.chat-chip:hover { background: var(--color-primary); color: #fff; }

.chat-panel__form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid var(--color-border); }
.chat-panel__form textarea {
  flex: 1; resize: none; max-height: 120px;
  font: inherit; font-size: 16px; line-height: 1.35; color: var(--color-text);
  border: 1.5px solid var(--color-border); border-radius: 14px; padding: 9px 12px; background: var(--color-bg-alt);
}
.chat-panel__form textarea:focus { outline: 0; border-color: var(--color-primary); background: #fff; }
.chat-panel__form button {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--color-primary); color: #fff;
}
.chat-panel__form button:disabled, .chat-panel__form textarea:disabled { opacity: .55; cursor: default; }
.chat-panel__form button .icon { width: 20px; height: 20px; }
.chat-panel__foot {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px 10px; font-size: .75rem; color: var(--color-text-soft); background: #fff;
}
.chat-panel__foot .icon { width: 14px; height: 14px; color: var(--color-whatsapp); }
.chat-panel__foot:hover { color: var(--color-text); }
