/* ============================================================
   e-Qapla — Chat widget (setter consultivo, v1 estatico)
   Cerebro North Star client-side. Reusa los tokens de
   design-system/colors_and_type.css (cargado en cada pagina).
   Prefijo: eqbot-
   ============================================================ */

.eqbot,
.eqbot * { box-sizing: border-box; }

.eqbot {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147482000;
  font-family: var(--font-sans, system-ui, sans-serif);
}

/* ---------- Lanzador ---------- */
.eqbot__launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 0 22px 0 18px;
  border: 0;
  border-radius: var(--radius-pill, 100px);
  background: var(--color-primary, #1E50FA);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 14px 30px -10px rgba(30, 80, 250, 0.55), 0 2px 8px rgba(10, 11, 13, 0.18);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.eqbot__launcher:hover {
  transform: translateY(-2px);
  background: var(--color-primary-active, #1740C8);
  box-shadow: 0 20px 40px -12px rgba(30, 80, 250, 0.65), 0 2px 8px rgba(10, 11, 13, 0.2);
}
.eqbot__launcher:focus-visible { outline: 2px solid var(--color-primary, #1E50FA); outline-offset: 3px; }
.eqbot__launcher svg { width: 22px; height: 22px; flex: none; }
.eqbot__launcher-dot {
  position: absolute;
  top: -3px; right: -3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--color-semantic-up, #05b169);
  border: 2px solid #fff;
}
.eqbot__launcher-wrap { position: relative; display: inline-flex; }
@media (max-width: 480px) {
  .eqbot__launcher span { display: none; }
  .eqbot__launcher { padding: 0; width: 58px; justify-content: center; }
}
.eqbot.is-open .eqbot__launcher-wrap { display: none; }
/* En paginas con el WhatsApp flotante (.srv-wa), sube el lanzador para apilarlos */
.eqbot--stacked .eqbot__launcher-wrap { margin-bottom: 58px; }

/* ---------- Panel ---------- */
.eqbot__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100dvh - 40px);
  display: none;
  flex-direction: column;
  background: var(--color-canvas, #fff);
  border: 1px solid var(--color-hairline, #dee1e6);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 30px 70px -24px rgba(10, 11, 13, 0.4), 0 6px 18px rgba(10, 11, 13, 0.12);
}
.eqbot.is-open .eqbot__panel { display: flex; }
@media (prefers-reduced-motion: no-preference) {
  .eqbot.is-open .eqbot__panel { animation: eqbotIn .28s cubic-bezier(.22,1,.36,1) both; }
  @keyframes eqbotIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
}
@media (max-width: 480px) {
  .eqbot { right: 12px; bottom: 12px; left: 12px; }
  .eqbot__panel { width: 100%; height: calc(100dvh - 24px); }
}

/* ---------- Header ---------- */
.eqbot__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 18px;
  background: var(--color-surface-dark, #0a0b0d);
  color: #fff;
  flex: none;
}
.eqbot__avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  background: var(--color-primary, #1E50FA);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono, monospace);
  font-weight: 500; font-size: 15px; color: #fff;
}
.eqbot__head-main { min-width: 0; flex: 1; }
.eqbot__head-name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.eqbot__head-status {
  font-size: 12px; color: var(--color-on-dark-soft, #a8acb3);
  display: flex; align-items: center; gap: 6px; margin-top: 2px;
}
.eqbot__head-status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-semantic-up, #05b169);
}
.eqbot__head-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--color-on-dark-soft, #a8acb3);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.eqbot__head-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.eqbot__head-btn svg { width: 18px; height: 18px; }

/* ---------- Mensajes ---------- */
.eqbot__log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--color-surface-soft, #f7f7f7);
  scroll-behavior: smooth;
}
.eqbot__row { display: flex; }
.eqbot__row--bot { justify-content: flex-start; }
.eqbot__row--user { justify-content: flex-end; }
.eqbot__bubble {
  max-width: 84%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.eqbot__row--bot .eqbot__bubble {
  background: var(--color-canvas, #fff);
  color: var(--color-ink, #0a0b0d);
  border: 1px solid var(--color-hairline, #dee1e6);
  border-bottom-left-radius: 5px;
}
.eqbot__row--user .eqbot__bubble {
  background: var(--color-primary, #1E50FA);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.eqbot__bubble a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.eqbot__row--bot .eqbot__bubble a { color: var(--color-primary, #1E50FA); }

/* Typing */
.eqbot__typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.eqbot__typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-muted-soft, #a8acb3);
  animation: eqbotBlink 1.2s infinite ease-in-out both;
}
.eqbot__typing span:nth-child(2) { animation-delay: .18s; }
.eqbot__typing span:nth-child(3) { animation-delay: .36s; }
@keyframes eqbotBlink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .eqbot__typing span { animation: none; } }

/* ---------- Quick replies ---------- */
.eqbot__replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 16px 12px;
  background: var(--color-surface-soft, #f7f7f7);
}
.eqbot__reply {
  appearance: none;
  border: 1px solid rgba(30, 80, 250, 0.35);
  background: var(--color-canvas, #fff);
  color: var(--color-primary, #1E50FA);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-pill, 100px);
  cursor: pointer;
  transition: background .14s ease, transform .14s ease, border-color .14s ease;
}
.eqbot__reply:hover { background: rgba(30, 80, 250, 0.07); transform: translateY(-1px); }
.eqbot__reply:focus-visible { outline: 2px solid var(--color-primary, #1E50FA); outline-offset: 2px; }
.eqbot__reply--cta {
  background: var(--color-primary, #1E50FA);
  color: #fff;
  border-color: transparent;
}
.eqbot__reply--cta:hover { background: var(--color-primary-active, #1740C8); }
.eqbot__reply--wa {
  border-color: #25d366;
  color: #0f8a47;
}
.eqbot__reply--wa:hover { background: rgba(37, 211, 102, 0.1); }
.eqbot__reply--ghost {
  border-color: var(--color-hairline, #dee1e6);
  color: var(--color-body, #5b616e);
}
.eqbot__reply--ghost:hover { background: var(--color-surface-strong, #eef0f3); }

/* ---------- Input ---------- */
.eqbot__input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--color-hairline, #dee1e6);
  background: var(--color-canvas, #fff);
  flex: none;
}
.eqbot__input input {
  flex: 1;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--color-hairline, #dee1e6);
  border-radius: var(--radius-pill, 100px);
  font-family: inherit;
  font-size: 14.5px;
  color: var(--color-ink, #0a0b0d);
  background: var(--color-surface-soft, #f7f7f7);
}
.eqbot__input input:focus { outline: none; border-color: var(--color-primary, #1E50FA); background: #fff; }
.eqbot__send {
  width: 42px; height: 42px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--color-primary, #1E50FA);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.eqbot__send:hover { background: var(--color-primary-active, #1740C8); }
.eqbot__send:disabled { background: var(--color-primary-disabled, #A8B5E6); cursor: default; }
.eqbot__send svg { width: 18px; height: 18px; }

.eqbot__foot {
  text-align: center;
  font-size: 11px;
  color: var(--color-muted, #7c828a);
  padding: 0 12px 8px;
  background: var(--color-canvas, #fff);
  flex: none;
}
.eqbot__foot button {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--color-muted, #7c828a); font-family: inherit; font-size: 11px;
  text-decoration: underline; padding: 0;
}
.eqbot__foot button:hover { color: var(--color-ink, #0a0b0d); }

/* ---------- Vista de reserva (calendario GHL embebido) ---------- */
.eqbot__booking {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  background: var(--color-canvas, #fff);
}
.eqbot.is-booking .eqbot__log,
.eqbot.is-booking .eqbot__replies,
.eqbot.is-booking .eqbot__input,
.eqbot.is-booking .eqbot__foot { display: none; }
.eqbot.is-booking .eqbot__booking { display: flex; }
.eqbot__booking-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-hairline, #dee1e6);
  flex: none;
  font-size: 13.5px; font-weight: 600; color: var(--color-ink, #0a0b0d);
}
.eqbot__booking-back {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--color-hairline, #dee1e6);
  background: var(--color-canvas, #fff);
  color: var(--color-body, #5b616e);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 12px 6px 10px;
  border-radius: var(--radius-pill, 100px);
  transition: border-color .15s ease, color .15s ease;
}
.eqbot__booking-back:hover { border-color: var(--color-ink, #0a0b0d); color: var(--color-ink, #0a0b0d); }
.eqbot__booking-back svg { width: 15px; height: 15px; }
.eqbot__booking-mount {
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--color-surface-soft, #f7f7f7);
}
.eqbot__booking-skel {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px;
  font-size: 14px; color: var(--color-muted, #7c828a);
}
.eqbot__booking-skel::before {
  content: ""; width: 18px; height: 18px; flex: none;
  border-radius: 50%;
  border: 2.5px solid rgba(30, 80, 250, 0.2);
  border-top-color: var(--color-primary, #1E50FA);
  animation: eqbotSpin .8s linear infinite;
}
@keyframes eqbotSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .eqbot__booking-skel::before { animation: none; } }

@media print { .eqbot { display: none !important; } }
