/* Asistente de Zonda Bytes. Usa las variables de styles.css. */
.zbchat { position: fixed; right: 1.25rem; bottom: 5.75rem; z-index: 70; font-family: var(--font-sans); }

.zbchat__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.zbchat__toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-width: 3.25rem; height: 3.25rem; padding: 0 0.9rem; margin-left: auto;
  border-radius: var(--radius-pill); border: 1px solid var(--accent-border);
  background: var(--bg-elevated); color: var(--accent-bright);
  font: 600 0.9rem/1 var(--font-sans); cursor: pointer;
  box-shadow: var(--shadow-card), var(--accent-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.zbchat__toggle:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.zbchat__toggle-label { display: none; }
.zbchat[data-open="true"] .zbchat__toggle { display: none; }

.zbchat__panel {
  position: fixed; right: 1.25rem; bottom: 1.25rem;
  display: flex; flex-direction: column;
  width: min(23rem, calc(100vw - 2.5rem)); height: min(35rem, calc(100dvh - 2.5rem));
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), var(--accent-glow); overflow: hidden;
}
.zbchat__panel[hidden] { display: none; }

.zbchat__head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.85rem 1rem; background: var(--accent-gradient); color: var(--text-on-accent);
}
.zbchat__title { margin: 0; font: 700 1rem/1.25 var(--font-sans); }
.zbchat__sub { margin: 0.15rem 0 0; font-size: 0.78rem; opacity: 0.92; }
.zbchat__close {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: none;
  border: 0; border-radius: var(--radius-pill); background: rgba(255, 255, 255, 0.16);
  color: inherit; cursor: pointer;
}
.zbchat__close:hover { background: rgba(255, 255, 255, 0.28); }

.zbchat__log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem;
}
.zbchat__msg {
  max-width: 88%; padding: 0.6rem 0.8rem; border-radius: var(--radius-md);
  font-size: 0.95rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere;
}
.zbchat__msg--bot { align-self: flex-start; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--border-faint); border-bottom-left-radius: 0.25rem; }
.zbchat__msg--user { align-self: flex-end; background: var(--accent-deep); color: var(--text-on-accent); border-bottom-right-radius: 0.25rem; }
.zbchat__msg--error { border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }
.zbchat__link { color: var(--accent-bright); text-decoration: underline; text-underline-offset: 2px; }
.zbchat__msg--user .zbchat__link { color: #fff; }

.zbchat__typing { display: flex; gap: 0.3rem; padding: 0.8rem 0.9rem; }
.zbchat__dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--text-secondary); animation: zbchat-bounce 1.2s infinite ease-in-out; }
.zbchat__dot:nth-child(2) { animation-delay: 0.15s; }
.zbchat__dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes zbchat-bounce { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.zbchat__chips { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 1rem 0.75rem; }
.zbchat__chips[hidden] { display: none; }
.zbchat__chip {
  min-height: 2.75rem; padding: 0.4rem 0.85rem; border-radius: var(--radius-pill);
  border: 1px solid var(--accent-border); background: var(--accent-soft); color: var(--accent-bright);
  font: 500 0.88rem/1.2 var(--font-sans); cursor: pointer;
}
.zbchat__chip:hover { background: rgba(14, 165, 233, 0.22); }

.zbchat__status { margin: 0; padding: 0 1rem; min-height: 0; font-size: 0.8rem; color: #fca5a5; }
.zbchat__status:empty { display: none; }

.zbchat__form { display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.6rem 0.75rem; border-top: 1px solid var(--border-faint); }
.zbchat__input {
  flex: 1; min-width: 0; resize: none; max-height: 7.5rem; min-height: 2.75rem;
  padding: 0.65rem 0.8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle); background: var(--bg-input); color: var(--text-primary);
  font: 400 16px/1.35 var(--font-sans); /* 16px evita el zoom automático en el celu */
}
.zbchat__input::placeholder { color: var(--text-muted); }
.zbchat__send {
  display: grid; place-items: center; flex: none; width: 2.75rem; height: 2.75rem;
  border: 0; border-radius: var(--radius-sm); background: var(--accent-gradient); color: var(--text-on-accent); cursor: pointer;
}
.zbchat__send:disabled { opacity: 0.5; cursor: progress; }

.zbchat__foot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.25rem 0.75rem;
  padding: 0.5rem 0.9rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-faint); font-size: 0.82rem;
}
.zbchat__wa, .zbchat__mail { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--accent-bright); text-underline-offset: 2px; }
.zbchat__wa { font-weight: 600; }
.zbchat__mail { color: var(--text-secondary); }

.zbchat button:focus-visible, .zbchat a:focus-visible, .zbchat textarea:focus-visible, .zbchat__log:focus-visible {
  outline: 2px solid var(--accent-bright); outline-offset: 2px;
}

@media (min-width: 640px) {
  .zbchat__toggle-label { display: inline; }
}

/* Celular: la ventana ocupa toda la pantalla */
@media (max-width: 519px) {
  .zbchat { right: 1rem; bottom: 5.5rem; }
  .zbchat__panel { inset: 0; width: 100%; height: 100dvh; border-radius: 0; border: 0; }
}
html.zbchat-lock { overflow: hidden; }
@media (max-width: 519px) { html.zbchat-lock body { overflow: hidden; } }

@media (prefers-reduced-motion: reduce) {
  .zbchat__toggle, .zbchat__dot { transition: none; animation: none; }
}
