/* ACQUY.NET Chatbot V1 — shared storefront assistant.
   Shipped tokens only: no new colour, token, framework or component vocabulary.
   Gold (#FFD000) is 2.42:1 on white and therefore never carries text here; it
   appears only as a hairline on navy. Gold-toned text would use --acquy-link. */

.cbot {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900; /* below the header; the legacy 2147483000 is rejected */
  font-family: var(--acquy-font-sans);
  font-size: var(--fs-base);
  color: var(--acquy-text);
  /* column-reverse keeps the launcher on the bottom edge and grows the panel
     upwards from it, so the launcher never rides up over the navigation. */
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 12px;
}

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

/* ---- 4.1 Launcher ------------------------------------------------------- */

.cbot__launcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 20px;
  border-radius: 24px;
  background: var(--acquy-black);
  color: var(--acquy-surface);
  border: 1px solid var(--acquy-gold-hairline);
  box-shadow: var(--acquy-shadow-2);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.cbot__launcher:hover { background: var(--acquy-black); }
.cbot__launcher:focus-visible { outline: none; box-shadow: var(--acquy-shadow-2), var(--acquy-focus-ring); }

.cbot__launcher-icon { width: 20px; height: 20px; }
.cbot__launcher-label { white-space: nowrap; }

/* Status dot: green when the agent resolves, grey when it does not. It is
   aria-hidden, and the label is identical either way. */
.cbot__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cbot__dot--on { background: var(--acquy-success); }
.cbot__dot--off { background: var(--acquy-border-strong); }

/* ---- 4.3 Panel --------------------------------------------------------- */

.cbot__panel {
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 120px);
  background: var(--acquy-surface);
  border: 1px solid var(--acquy-border);
  border-radius: var(--acquy-radius);
  box-shadow: var(--acquy-shadow-2);
  overflow: hidden;
}

.cbot__panel[hidden] { display: none; }

.cbot__head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  min-height: 64px;
  padding: 0 8px 0 16px;
  background: var(--acquy-black);
  border-bottom: 1px solid var(--acquy-yellow); /* gold hairline, on navy only */
  color: var(--acquy-surface);
}

.cbot__headtext { flex: 1; min-width: 0; }
.cbot__title { margin: 0; font-size: var(--fs-md); font-weight: 700; color: var(--acquy-surface); }
.cbot__subtitle { margin: 2px 0 0; font-size: var(--fs-xs); color: #DDE1E5; }

.cbot__close {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: var(--acquy-radius);
  color: var(--acquy-surface);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.cbot__close:hover { background: rgba(255, 255, 255, .12); }
.cbot__close:focus-visible { outline: 2px solid var(--acquy-surface); outline-offset: -2px; }

/* ---- Body and bubbles -------------------------------------------------- */

.cbot__body {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--acquy-surface);
}

.cbot__row { display: flex; }
.cbot__row--bot { justify-content: flex-start; }
.cbot__row--user { justify-content: flex-end; }

.cbot__bubble {
  margin: 0;
  max-width: 85%;
  padding: 10px 12px;
  border-radius: var(--acquy-radius);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cbot__bubble--bot { background: var(--acquy-bg); color: var(--acquy-ink); }
.cbot__bubble--user { background: var(--acquy-link); color: var(--acquy-surface); }
.cbot__bubble--bot a { color: var(--acquy-link-active); }

/* Quick prompts (C-2) reuse the shipped .chip style, first turn only. */
.cbot__prompts { display: flex; flex-wrap: wrap; gap: 8px; }
.cbot__prompts .chip { cursor: pointer; }

/* ---- Product card in the conversation (max 3) -------------------------- */

.cbot__cards { display: flex; flex-direction: column; gap: 8px; }

.cbot__card {
  display: flex;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--acquy-border);
  border-radius: var(--acquy-radius);
  background: var(--acquy-surface);
}

.cbot__card-art {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--acquy-radius);
  background: var(--acquy-soft-2);
  color: var(--acquy-black);
}

.cbot__card-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cbot__card-name { font-weight: 600; color: var(--acquy-ink); font-size: var(--fs-sm); }
.cbot__card-spec { font-size: var(--fs-xs); color: var(--acquy-muted); }
.cbot__card-price { font-weight: 700; color: var(--acquy-black); font-size: var(--fs-sm); }
.cbot__card-link { font-size: var(--fs-sm); color: var(--acquy-link-active); font-weight: 600; align-self: flex-start; }

/* ---- Clarify options (max 3) ------------------------------------------- */

.cbot__options { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* ---- C-10 typing indicator --------------------------------------------- */

.cbot__typing { display: inline-flex; align-items: center; gap: 6px; }
.cbot__typing-dots { display: inline-flex; gap: 3px; }
.cbot__typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--acquy-muted);
  animation: cbot-bounce 1.2s infinite ease-in-out;
}
.cbot__typing-dots i:nth-child(2) { animation-delay: .15s; }
.cbot__typing-dots i:nth-child(3) { animation-delay: .3s; }

@keyframes cbot-bounce {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Reduced motion shows a static "Đang nhập…" with no animated dots. */
@media (prefers-reduced-motion: reduce) {
  .cbot__typing-dots { display: none; }
  .cbot__typing-dots i { animation: none; }
}

/* ---- Escalation row (C-11), pinned above the footer -------------------- */

.cbot__escalate {
  flex: none;
  padding: 10px 16px;
  border-top: 1px solid var(--acquy-border);
  background: var(--acquy-bg);
}

.cbot__escalate[hidden] { display: none; }

/* ---- Footer ------------------------------------------------------------ */

.cbot__foot {
  flex: none;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--acquy-border);
  background: var(--acquy-surface);
}

.cbot__input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 96px;
  padding: 11px 12px;
  font: inherit;
  color: var(--acquy-text);
  background: var(--acquy-surface);
  border: 1px solid var(--acquy-border-strong);
  border-radius: var(--acquy-radius);
  resize: none;
}

.cbot__input:focus { outline: none; border-color: var(--acquy-link); box-shadow: var(--acquy-focus-ring); }
.cbot__input:disabled { background: var(--acquy-bg); color: var(--acquy-muted); cursor: not-allowed; }

.cbot__send { flex: none; min-height: 44px; }
.cbot__send:disabled { opacity: .5; cursor: not-allowed; }

/* ---- 4.6 Responsive ---------------------------------------------------- */

/* < 768px: icon-only circular launcher, panel becomes a bottom sheet. */
@media (max-width: 767px) {
  .cbot { right: 16px; bottom: 16px; }
  /* The cart and checkout keep a sticky action bar at the bottom: the launcher sits above it, never on the CTA. */
  body:has(.cartbar) .cbot { bottom: 88px; }

  .cbot__launcher {
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
  }

  .cbot__launcher-label { display: none; }

  /* The dot would crowd a 52px circle; availability is server-read either way. */
  .cbot__dot { display: none; }

  .cbot__launcher-icon { width: 24px; height: 24px; }

  .cbot__panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 85dvh;
    border-radius: var(--acquy-radius) var(--acquy-radius) 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }

  .cbot__foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }

  /* The bottom sheet leaves the flow, so the launcher would sit on top of it. */
  .cbot:has(.cbot__panel:not([hidden])) .cbot__launcher { display: none; }
}
