/* ── Belibitools Chatbot Widget ──────────────────────────────────────────────── */

/* Toggle button */
#bt-chat-toggle {
  position: fixed;
  bottom: 92px;
  right: 32px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--blue-gradient);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(26,79,255,0.45), 0 1px 0 rgba(255,255,255,0.1) inset;
  z-index: 9990;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#bt-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 30px rgba(26,79,255,0.6);
}
#bt-chat-toggle svg {
  width: 22px;
  height: 22px;
  stroke: #fff;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#bt-chat-toggle.bt-chat-toggle--open svg {
  transform: rotate(15deg) scale(0.9);
}

/* Notification badge */
#bt-chat-toggle[data-badge]::after {
  content: '';
  position: absolute;
  top: 7px;
  right: 7px;
  width: 10px;
  height: 10px;
  background: #ff4757;
  border-radius: 50%;
  border: 2px solid var(--bg);
  animation: bt-ping 1.5s ease-in-out infinite;
}
@keyframes bt-ping {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.2); opacity: 0.8; }
}

/* Chat panel */
#bt-chat-panel {
  position: fixed;
  bottom: 162px;
  right: 32px;
  width: 360px;
  max-height: min(520px, calc(100vh - 200px));
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow:
    0 24px 64px rgba(0,0,0,0.7),
    0 0 0 1px rgba(26,79,255,0.12),
    inset 0 1px 0 rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9989;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
#bt-chat-panel.bt-chat-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.bt-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--blue-gradient);
  flex-shrink: 0;
}
.bt-chat-header__info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bt-chat-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bt-chat-header__avatar svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
}
.bt-chat-header__name {
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: var(--fw-semi);
  color: #fff;
  line-height: 1.2;
}
.bt-chat-header__status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font);
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  margin-top: 2px;
}
.bt-chat-header__dot {
  width: 7px;
  height: 7px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--cyan-glow);
  flex-shrink: 0;
}
.bt-chat-close {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.bt-chat-close:hover { background: rgba(255,255,255,0.26); }
.bt-chat-close svg { width: 13px; height: 13px; stroke: #fff; }

/* Messages area */
.bt-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.bt-chat-messages::-webkit-scrollbar { width: 4px; }
.bt-chat-messages::-webkit-scrollbar-track { background: transparent; }
.bt-chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Message rows */
.bt-chat-msg {
  display: flex;
  max-width: 85%;
  animation: bt-msg-in 0.2s ease;
}
@keyframes bt-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bt-chat-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.bt-chat-msg--bot  { align-self: flex-start; }

/* Bubbles */
.bt-chat-bubble {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.57;
  padding: 10px 13px;
  border-radius: 16px;
  word-break: break-word;
}
.bt-chat-msg--user .bt-chat-bubble {
  background: var(--blue-gradient);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(26,79,255,0.3);
}
.bt-chat-msg--bot .bt-chat-bubble {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.bt-chat-typing .bt-chat-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 13px 16px;
}
.bt-chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--blue);
  border-radius: 50%;
  animation: bt-bounce 1.2s ease-in-out infinite;
}
.bt-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.bt-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bt-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.bt-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-overlay);
  flex-shrink: 0;
}
.bt-chat-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 9px 14px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
.bt-chat-input::placeholder { color: var(--text-muted); }
.bt-chat-input:focus { border-color: var(--blue-border); }
.bt-chat-send {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--blue-gradient);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(26,79,255,0.3);
  transition: opacity 0.15s, transform 0.15s;
}
.bt-chat-send:hover { opacity: 0.85; transform: scale(1.06); }
.bt-chat-send:disabled { opacity: 0.45; cursor: default; transform: none; }
.bt-chat-send svg { width: 14px; height: 14px; stroke: #fff; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #bt-chat-toggle {
    bottom: 88px;
    right: 20px;
  }
  #bt-chat-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 156px;
    max-height: min(500px, calc(100dvh - 180px));
  }
}
