/* ============================================================================
 * assistant.css — Widget de chat IA (vanilla, mobile-first, premium)
 * Namespace .pa-*  (Panini Assistant). No colisiona con el resto del sitio.
 * ========================================================================== */
.pa-root {
  --pa-yellow: #FFD400;
  --pa-ink: #16181d;
  --pa-muted: #8a8f98;
  --pa-line: #ececef;
  --pa-bot: #f3f4f6;
  --pa-user: #FFE98A;
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* burbuja flotante */
.pa-bubble {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #FFE24D, #FFD400);
  color: #1a1505;
  box-shadow: 0 10px 30px rgba(0,0,0,.22);
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, box-shadow .2s ease;
}
.pa-bubble:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 36px rgba(0,0,0,.28); }
.pa-bubble:active { transform: scale(.96); }
.pa-bubble svg { width: 28px; height: 28px; }
/* El botón amarillo ya NO pulsa: la vida queda solo en el dot de estado. */
.pa-bubble__dot {
  position: absolute; top: 3px; right: 3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #25c065; border: none;
  box-shadow: 0 0 0 2px rgba(26,21,5,.16), 0 0 0 0 rgba(37,192,101,.6);
  animation: pa-dot-pulse 2.1s ease-out infinite;
}
/* anillo vivo expandiéndose (sin tapar el dot) */
.pa-bubble__dot::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(37,192,101,.5);
  animation: pa-dot-ring 2.1s ease-out infinite; pointer-events: none;
}
@keyframes pa-dot-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes pa-dot-ring { 0% { transform: scale(.7); opacity: .7; } 70% { transform: scale(1.9); opacity: 0; } 100% { opacity: 0; } }
/* color del estado según disponibilidad */
.pa-avail--ausente .pa-bubble__dot { background: #e0a000; box-shadow: 0 0 0 2px rgba(26,21,5,.16); }
.pa-avail--ausente .pa-bubble__dot::after { box-shadow: 0 0 0 1px rgba(224,160,0,.5); }
.pa-avail--fuera_horario .pa-bubble__dot { background: #9aa0a8; box-shadow: 0 0 0 2px rgba(26,21,5,.16); animation: none; }
.pa-avail--fuera_horario .pa-bubble__dot::after { animation: none; opacity: 0; }

/* ventana */
.pa-window {
  position: absolute;
  right: 0; bottom: 74px;
  width: 376px; max-width: calc(100vw - 24px);
  height: 564px; max-height: calc(100vh - 110px);
  background: #fff;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 20px;
  box-shadow: 0 18px 50px -12px rgba(16,18,28,.32), 0 8px 24px -8px rgba(16,18,28,.18);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: pa-in .26s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes pa-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.pa-root[hidden] { display: none; }
.pa-window[hidden] { display: none; }

/* header */
.pa-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
  background: linear-gradient(120deg, #1b1e25, #2a2e38);
  color: #fff;
}
.pa-head__avatar {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  background: var(--pa-yellow); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #1a1505; font-weight: 800; font-size: 1.05rem;
  box-shadow: 0 0 0 2px rgba(255,255,255,.15);
}
.pa-head__info { flex: 1; min-width: 0; line-height: 1.2; }
.pa-head__name { font-weight: 700; font-size: .95rem; }
.pa-head__label { font-size: .68rem; color: #c7ccd4; margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.pa-head__label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #1faa5a; box-shadow: 0 0 0 0 rgba(31,170,90,.6); animation: pa-pulse 2.4s ease-out infinite; }
@keyframes pa-pulse { 0% { box-shadow: 0 0 0 0 rgba(31,170,90,.5); } 70% { box-shadow: 0 0 0 6px rgba(31,170,90,0); } 100% { box-shadow: 0 0 0 0 rgba(31,170,90,0); } }
.pa-avail--ausente .pa-head__label::before { background: #e0a000; animation: none; }
.pa-avail--fuera_horario .pa-head__label::before { background: #9aa0a8; animation: none; }
.pa-head__close {
  background: rgba(255,255,255,.12); border: none; color: #fff; cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.pa-head__close:hover { background: rgba(255,255,255,.22); }

/* mensajes */
.pa-body {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  background:
    radial-gradient(circle at 18% 12%, rgba(255,212,0,.05), transparent 42%),
    radial-gradient(circle at 88% 78%, rgba(26,115,232,.04), transparent 40%),
    #f7f8fa;
  -webkit-overflow-scrolling: touch;
}
/* agrupación tipo WhatsApp: menos separación entre burbujas del mismo lado */
.pa-msg--bot + .pa-msg--bot, .pa-msg--user + .pa-msg--user { margin-top: -4px; }
.pa-msg { max-width: 82%; padding: 8px 11px 6px; border-radius: 15px; font-size: .9rem; line-height: 1.45; word-wrap: break-word; }
.pa-msg__text { white-space: pre-wrap; word-wrap: break-word; }
.pa-msg__meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 2px; line-height: 1; }
.pa-msg__time { font-size: .62rem; color: var(--pa-muted); }
.pa-msg--user .pa-msg__time { color: #9a8a3a; }
.pa-ticks { display: inline-flex; align-items: center; width: 16px; height: 10px; color: #9aa0a8; }
.pa-ticks svg { width: 100%; height: 100%; }
.pa-ticks--read { color: #34b7f1; }
.pa-msg--bot { align-self: flex-start; background: var(--pa-bot); color: var(--pa-ink); border-bottom-left-radius: 5px; }
.pa-msg--user { align-self: flex-end; background: var(--pa-user); color: var(--pa-ink); border-bottom-right-radius: 5px; }
.pa-msg--err { align-self: flex-start; background: #fff5f5; color: #c0392b; border: 1px solid #f3c0c0; padding: 9px 13px; }
.pa-msg--sys { align-self: center; font-size: .72rem; color: var(--pa-muted); background: #eef0f3; padding: 4px 12px; border-radius: 999px; }

/* pre-chat (Centro de Atención) */
.pa-prechat { display: flex; flex-direction: column; gap: 14px; padding: 6px 2px; }
.pa-prechat__head { text-align: center; padding: 8px 4px 2px; }
.pa-prechat__title { font-size: 1.05rem; font-weight: 800; color: var(--pa-ink); }
.pa-prechat__sub { font-size: .85rem; color: var(--pa-muted); margin-top: 3px; }
.pa-prechat__status { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: .72rem; font-weight: 700; padding: 4px 11px; border-radius: 999px; }
.pa-prechat__status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.pa-prechat__status.is-on { background: #e9f9ef; color: #15803d; } .pa-prechat__status.is-on::before { background: #1faa5a; }
.pa-prechat__status.is-off { background: #fff4e0; color: #9a6b00; } .pa-prechat__status.is-off::before { background: #e0a000; }
.pa-prechat__opts { display: flex; flex-direction: column; gap: 9px; }
.pa-prechat__opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--pa-line); border-radius: 14px; padding: 13px 14px; font: inherit;
  transition: border-color .15s ease, transform .12s ease, box-shadow .2s ease;
}
.pa-prechat__opt:hover { border-color: #d8b400; transform: translateY(-1px); box-shadow: 0 6px 18px -8px rgba(16,18,28,.2); }
.pa-prechat__emoji { font-size: 1.25rem; flex-shrink: 0; }
.pa-prechat__label { flex: 1; font-size: .92rem; font-weight: 600; color: var(--pa-ink); }
.pa-prechat__arrow { color: var(--pa-muted); font-size: 1.2rem; }
.pa-prechat__note { font-size: .78rem; color: var(--pa-muted); text-align: center; background: #fafbfc; border: 1px solid var(--pa-line); border-radius: 10px; padding: 9px 12px; }

/* Centro de Atención (pantalla premium de entrada) */
.pa-centro { display: flex; flex-direction: column; gap: 14px; padding: 8px 2px 4px; }
.pa-centro__head { text-align: center; padding: 14px 6px 4px; }
.pa-centro__title { font-size: 1.12rem; font-weight: 800; color: var(--pa-ink); letter-spacing: -.01em; }
.pa-centro__sub { font-size: .86rem; color: var(--pa-muted); margin-top: 4px; }
.pa-centro__status { display: inline-flex; align-items: center; gap: 6px; margin-top: 11px; font-size: .73rem; font-weight: 700; padding: 5px 12px; border-radius: 999px; }
.pa-centro__status .pa-dot { width: 8px; height: 8px; border-radius: 50%; }
.pa-centro__status.is-on { background: #e9f9ef; color: #15803d; } .pa-centro__status.is-on .pa-dot { background: #1faa5a; box-shadow: 0 0 0 0 rgba(31,170,90,.5); animation: pa-pulse 2.4s ease-out infinite; }
.pa-centro__status.is-away { background: #fff4e0; color: #9a6b00; } .pa-centro__status.is-away .pa-dot { background: #e0a000; }
.pa-centro__status.is-off { background: #f1f2f4; color: #6b7280; } .pa-centro__status.is-off .pa-dot { background: #9aa0a8; }
.pa-centro__lead { font-size: .78rem; font-weight: 700; color: var(--pa-muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 2px; }
.pa-centro__opts { display: flex; flex-direction: column; gap: 9px; }
.pa-centro__opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--pa-line); border-radius: 14px; padding: 13px 14px; font: inherit;
  transition: border-color .15s ease, transform .12s ease, box-shadow .2s ease;
}
.pa-centro__opt:hover { border-color: #d8b400; transform: translateY(-1px); box-shadow: 0 6px 18px -8px rgba(16,18,28,.2); }
.pa-centro__opt:active { transform: scale(.99); }
.pa-centro__emoji { font-size: 1.3rem; flex-shrink: 0; }
.pa-centro__label { flex: 1; font-size: .92rem; font-weight: 600; color: var(--pa-ink); }
.pa-centro__arrow { color: var(--pa-muted); font-size: 1.25rem; }
.pa-centro__cta {
  margin-top: 2px; border: none; cursor: pointer; width: 100%;
  background: linear-gradient(135deg, #FFE24D, #FFD400); color: #1a1505;
  font-weight: 800; font-size: .95rem; border-radius: 14px; padding: 14px;
  box-shadow: 0 8px 22px -10px rgba(216,180,0,.7); transition: transform .12s ease, filter .15s ease;
}
.pa-centro__cta:hover { filter: brightness(.97); }
.pa-centro__cta:active { transform: scale(.98); }
.pa-centro__note { font-size: .78rem; color: var(--pa-muted); text-align: center; background: #fafbfc; border: 1px solid var(--pa-line); border-radius: 10px; padding: 9px 12px; }

/* Conexión realista (spinner + estados) */
.pa-connect { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 280px; padding: 20px; text-align: center; }
.pa-connect__spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #ececef; border-top-color: var(--pa-yellow); animation: pa-spin .8s linear infinite; }
@keyframes pa-spin { to { transform: rotate(360deg); } }
.pa-connect__msg { font-size: .92rem; font-weight: 700; color: var(--pa-ink); min-height: 1.2em; transition: opacity .2s ease; }
.pa-connect__sub { font-size: .8rem; color: var(--pa-muted); }

/* Reconexión (sesión vieja) */
.pa-reconnect { display: flex; flex-direction: column; gap: 11px; padding: 24px 8px; text-align: center; }
.pa-reconnect__title { font-size: 1.05rem; font-weight: 800; color: var(--pa-ink); }
.pa-reconnect__sub { font-size: .86rem; color: var(--pa-muted); line-height: 1.5; margin-bottom: 6px; }
.pa-reconnect__resume { border: none; cursor: pointer; background: var(--pa-yellow); color: #1a1505; font-weight: 800; font-size: .92rem; border-radius: 12px; padding: 12px; }
.pa-reconnect__new { border: 1px solid var(--pa-line); cursor: pointer; background: #fff; color: var(--pa-ink); font-weight: 700; font-size: .9rem; border-radius: 12px; padding: 11px; }
.pa-reconnect__new:hover { border-color: #d8b400; }

/* mini-form del pre-chat */
.pa-form { display: flex; flex-direction: column; gap: 11px; padding: 4px 2px; }
.pa-form__back { align-self: flex-start; background: none; border: none; color: var(--pa-muted); font: inherit; font-size: .82rem; cursor: pointer; padding: 2px 0; }
.pa-form__title { font-size: 1rem; font-weight: 800; color: var(--pa-ink); }
.pa-form__row { display: flex; flex-direction: column; gap: 4px; }
.pa-form__row span { font-size: .8rem; font-weight: 600; color: var(--pa-muted); }
.pa-form__input { border: 1px solid var(--pa-line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: .9rem; outline: none; }
.pa-form__input:focus { border-color: #d8b400; box-shadow: 0 0 0 3px rgba(255,212,0,.18); }
.pa-form__ta { resize: none; line-height: 1.4; font-family: inherit; }
.pa-form__row em { font-style: normal; color: #b0b5bd; font-weight: 500; }
.pa-form__err { font-size: .8rem; color: #c0392b; }
.pa-form__go { margin-top: 4px; border: none; cursor: pointer; background: var(--pa-yellow); color: #1a1505; font-weight: 800; font-size: .92rem; border-radius: 12px; padding: 12px; }

/* tarjeta de estado de pedido */
.pa-order { align-self: flex-start; width: 100%; max-width: 100%; background: #fff; border: 1px solid var(--pa-line); border-radius: 14px; padding: 12px 14px; box-shadow: 0 8px 22px -12px rgba(16,18,28,.22); display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.pa-order__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.pa-order__num { font-size: .82rem; font-weight: 800; color: var(--pa-ink); min-width: 0; overflow-wrap: anywhere; }
.pa-order__state { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: #9a6b00; background: #fff7e0; border: 1px solid #ffe49b; border-radius: 999px; padding: 3px 9px; white-space: nowrap; flex-shrink: 0; }
.pa-order__items { display: flex; flex-direction: column; gap: 4px; }
.pa-order__item { display: flex; justify-content: space-between; gap: 10px; font-size: .82rem; color: #374151; min-width: 0; }
.pa-order__item span:first-child { min-width: 0; overflow-wrap: anywhere; }
.pa-order__item span:last-child { white-space: nowrap; flex-shrink: 0; }
.pa-order__total { display: flex; justify-content: space-between; border-top: 1px solid var(--pa-line); padding-top: 7px; font-size: .85rem; }
.pa-order__total strong { color: var(--pa-ink); }
.pa-order__track { font-size: .8rem; color: #15803d; overflow-wrap: anywhere; word-break: break-word; }
.pa-order__link { font-size: .82rem; font-weight: 700; color: #1a73e8; text-decoration: none; overflow-wrap: anywhere; }

/* acciones comerciales */
.pa-actions { align-self: flex-start; max-width: 92%; display: flex; flex-direction: column; gap: 8px; }
.pa-prod { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--pa-line); border-radius: 13px; padding: 8px; }
.pa-prod__imgwrap { width: 50px; height: 50px; border-radius: 9px; overflow: hidden; background: #f3f4f6; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.pa-prod__imgwrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pa-prod__body { flex: 1; min-width: 0; }
.pa-prod__name { font-size: .82rem; font-weight: 600; color: var(--pa-ink); line-height: 1.25; }
.pa-prod__price { font-size: .82rem; font-weight: 800; color: var(--pa-ink); margin: 1px 0 5px; }
.pa-prod__btns { display: flex; gap: 6px; }
.pa-prod__add { border: none; cursor: pointer; background: var(--pa-yellow); color: #1a1505; font-weight: 800; font-size: .74rem; border-radius: 8px; padding: 6px 10px; }
.pa-prod__add:disabled { background: #d8f5e0; color: #15803d; cursor: default; }
.pa-prod__link { display: inline-flex; align-items: center; font-size: .74rem; font-weight: 700; color: #1a73e8; text-decoration: none; padding: 6px 8px; border: 1px solid var(--pa-line); border-radius: 8px; }
.pa-cta-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pa-cta-btn { display: inline-flex; align-items: center; justify-content: center; font-size: .82rem; font-weight: 700; text-decoration: none; border-radius: 999px; padding: 9px 16px; border: 1px solid var(--pa-line); color: var(--pa-ink); background: #fff; }
.pa-cta-btn--primary { background: var(--pa-yellow); border-color: var(--pa-yellow); color: #1a1505; font-weight: 800; }

/* typing */
.pa-typing { align-self: flex-start; background: var(--pa-bot); border-radius: 15px; border-bottom-left-radius: 5px; padding: 9px 13px; display: flex; align-items: center; gap: 8px; max-width: 88%; }
.pa-typing__label { font-size: .76rem; color: var(--pa-muted); }
.pa-typing__dots { display: inline-flex; gap: 4px; }
.pa-typing__dots span { width: 7px; height: 7px; border-radius: 50%; background: #b7bcc4; animation: pa-blink 1.2s infinite ease-in-out; }
.pa-typing__dots span:nth-child(2) { animation-delay: .2s; }
.pa-typing__dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pa-blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* input */
.pa-foot { border-top: 1px solid var(--pa-line); padding: 10px; background: #fff; }
.pa-inputrow { display: flex; align-items: flex-end; gap: 8px; }
.pa-input {
  flex: 1; resize: none; border: 1px solid var(--pa-line); border-radius: 12px;
  padding: 10px 12px; font: inherit; font-size: .9rem; line-height: 1.4; max-height: 96px;
  outline: none; background: #fff; color: var(--pa-ink);
}
.pa-input:focus { border-color: #d8b400; }
.pa-send {
  flex-shrink: 0; width: 42px; height: 42px; border: none; border-radius: 12px; cursor: pointer;
  background: var(--pa-yellow); color: #1a1505; display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease, filter .15s ease;
}
.pa-send:hover { filter: brightness(.96); }
.pa-send:active { transform: scale(.94); }
.pa-send:disabled { opacity: .5; cursor: not-allowed; }
.pa-send svg { width: 20px; height: 20px; }
.pa-foot__legal { display: flex; align-items: center; justify-content: center; gap: 5px; text-align: center; font-size: .66rem; color: var(--pa-muted); margin: 8px 0 1px; }
.pa-foot__legal strong { color: #5b6068; font-weight: 700; }
.pa-foot__lock { display: inline-flex; }
.pa-foot__lock svg { width: 11px; height: 11px; }

/* Mobile-first: la ventana ocupa toda la pantalla (sheet), pensada para uso con una mano */
@media (max-width: 560px) {
  .pa-window {
    position: fixed; inset: 0; right: 0; bottom: 0;
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
    border-radius: 0; border: none;
    animation: pa-sheet-in .28s cubic-bezier(.2,.9,.3,1);
  }
  @keyframes pa-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
  .pa-head { padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); }
  .pa-head__avatar { width: 40px; height: 40px; }
  .pa-body { padding: 14px 14px 16px; }
  .pa-msg { max-width: 86%; font-size: .94rem; }
  .pa-foot { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .pa-input { font-size: 16px; } /* evita zoom iOS */
  .pa-bubble { width: 58px; height: 58px; }
  .pa-root.pa-open .pa-bubble { display: none; } /* el sheet ya ocupa todo */
}
@media (prefers-reduced-motion: reduce) {
  .pa-window { animation: none; }
  .pa-typing__dots span, .pa-bubble::after, .pa-head__label::before, .pa-centro__status .pa-dot,
  .pa-bubble__dot, .pa-bubble__dot::after { animation: none; }
  .pa-bubble { transition: none; }
}
