/* Pembantu AI Smart Bazar — bubble terapung pada halaman utama.
   Warna mengikut penjenamaan dalam smartbazar-landing.css. */

.sb-chat {
  --sb-chat-navy: #2B3A8F;
  --sb-chat-navy-dark: #22307A;
  --sb-chat-gold: #E9A400;
  --sb-chat-ink: #141C4B;
  --sb-chat-muted: #6B7280;
  --sb-chat-line: #E3E7F2;
  font-family: "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ── Butang bubble ─────────────────────────────────────────────────────── */
/* bottom 68px supaya tidak bertindih dengan butang #scroll-top template. */
.sb-chat__launcher {
  position: fixed;
  right: 15px;
  bottom: 68px;
  z-index: 99998;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--sb-chat-navy);
  color: #fff;
  font-size: 24px;
  line-height: 0;
  box-shadow: 0 8px 24px rgba(10, 16, 45, .32);
  transition: transform .2s ease, background-color .2s ease;
}

.sb-chat__launcher:hover { background: var(--sb-chat-navy-dark); transform: translateY(-2px); }
.sb-chat__launcher:focus-visible { outline: 3px solid var(--sb-chat-gold); outline-offset: 2px; }
.sb-chat__launcher i { pointer-events: none; }

/* Launcher bergambar (Smart Bazar): potret dalam bulatan + lencana chat kecil
   supaya pengguna tahu ia butang perbualan, bukan sekadar gambar profil. */
.sb-chat__launcher:has(.sb-chat__launcher-img) {
  width: 64px;
  height: 64px;
  padding: 0;
  border: 3px solid #fff;
}

.sb-chat__launcher-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  pointer-events: none;
}

.sb-chat__launcher-dot {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--sb-chat-gold);
  border: 2px solid #fff;
  color: var(--sb-chat-ink);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  pointer-events: none;
}

.sb-chat--open .sb-chat__launcher { transform: scale(.85); opacity: .9; }

/* ── Panel perbualan ───────────────────────────────────────────────────── */
.sb-chat__panel {
  position: fixed;
  right: 15px;
  bottom: 134px;
  z-index: 99998;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 30px));
  max-height: min(560px, calc(100vh - 160px));
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(10, 16, 45, .28);
  overflow: hidden;
}

.sb-chat__panel[hidden] { display: none; }

.sb-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--sb-chat-navy);
  color: #fff;
}

.sb-chat__title { margin: 0; font-size: 15px; font-weight: 700; }
.sb-chat__subtitle { margin: 2px 0 0; font-size: 12px; opacity: .78; }

.sb-chat__actions { display: flex; gap: 2px; flex-shrink: 0; }

.sb-chat__icon-btn {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 15px;
  line-height: 0;
  padding: 8px;
  border-radius: 6px;
}
.sb-chat__icon-btn:hover { background: rgba(255, 255, 255, .16); }
.sb-chat__icon-btn:disabled { opacity: .5; cursor: default; }

/* ── Log mesej ─────────────────────────────────────────────────────────── */
.sb-chat__log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #F7F8FC;
}

.sb-chat__msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
}

.sb-chat__msg p { margin: 0 0 8px; }
.sb-chat__msg p:last-child { margin-bottom: 0; }

.sb-chat__msg--bot {
  align-self: flex-start;
  background: #fff;
  color: #2A2F45;
  border: 1px solid var(--sb-chat-line);
  border-bottom-left-radius: 4px;
}

.sb-chat__msg--user {
  align-self: flex-end;
  background: var(--sb-chat-navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.sb-chat__msg--error {
  align-self: flex-start;
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
  border-bottom-left-radius: 4px;
}

/* Penunjuk "sedang menaip" */
.sb-chat__typing { display: inline-flex; gap: 4px; align-items: center; }
.sb-chat__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sb-chat-muted);
  animation: sb-chat-bounce 1.2s infinite ease-in-out;
}
.sb-chat__typing span:nth-child(2) { animation-delay: .18s; }
.sb-chat__typing span:nth-child(3) { animation-delay: .36s; }

@keyframes sb-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sb-chat__typing span { animation: none; }
  .sb-chat__launcher { transition: none; }
}

/* ── Maklum balas 👍/👎 ─────────────────────────────────────────────────── */
.sb-chat__feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--sb-chat-line);
  font-size: 12px;
  color: var(--sb-chat-muted);
}

.sb-chat__feedback-btn {
  border: 1px solid var(--sb-chat-line);
  background: #fff;
  color: var(--sb-chat-muted);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.4;
}
.sb-chat__feedback-btn:hover { border-color: var(--sb-chat-navy); color: var(--sb-chat-navy); }
.sb-chat__feedback-btn[disabled] { opacity: .55; }
.sb-chat__feedback-done { font-style: italic; }

/* ── Soalan cadangan ───────────────────────────────────────────────────── */
.sb-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px 0;
  background: #fff;
}

.sb-chat__suggestions[hidden] { display: none; }

.sb-chat__chip {
  border: 1px solid var(--sb-chat-line);
  background: #fff;
  color: var(--sb-chat-navy);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}
.sb-chat__chip:hover { background: #EEF1FA; border-color: var(--sb-chat-navy); }

/* ── Borang input ──────────────────────────────────────────────────────── */
.sb-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px 8px;
  background: #fff;
}

.sb-chat__input {
  flex: 1 1 auto;
  resize: none;
  max-height: 110px;
  border: 1px solid #D9DEEC;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  color: #2A2F45;
}
.sb-chat__input:focus {
  outline: none;
  border-color: var(--sb-chat-navy);
  box-shadow: 0 0 0 3px rgba(43, 58, 143, .12);
}

.sb-chat__send {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: var(--sb-chat-navy);
  color: #fff;
  font-size: 15px;
  line-height: 0;
}
.sb-chat__send:hover { background: var(--sb-chat-navy-dark); }
.sb-chat__send[disabled] { opacity: .5; }

.sb-chat__note {
  margin: 0;
  padding: 0 16px 12px;
  background: #fff;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--sb-chat-muted);
}

/* ── Telefon: panel penuh skrin ────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .sb-chat__panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 88vh;
    height: 88vh;
    border-radius: 14px 14px 0 0;
  }

  .sb-chat--open .sb-chat__launcher { display: none; }
}
