/* BugBot chat widget */
:root {
  --bb-accent: #0d83fd;
  --bb-accent-2: #7a23bf;
  --bb-bg: #ffffff;
  --bb-fg: #1f2330;
  --bb-muted: #6b7280;
  --bb-bubble-user: linear-gradient(135deg, var(--bb-accent), var(--bb-accent-2));
  --bb-bubble-bot: #f1f3f7;
  --bb-border: #e5e7eb;
  --bb-shadow: 0 12px 32px rgba(0,0,0,0.18);
}
.dark-theme {
  --bb-bg: #1c1f2a;
  --bb-fg: #f3f4f6;
  --bb-muted: #9ca3af;
  --bb-bubble-bot: #2a2e3c;
  --bb-border: #2f3344;
  --bb-shadow: 0 12px 32px rgba(0,0,0,0.55);
}

/* Lift the existing site scroll-top button so it sits above the chat bubble. */
.scroll-top.active {
  right: 28px !important;
  bottom: 92px !important;
}
/* Hide the scroll-top while the chat panel is open so it doesn't overlap the send button. */
body.bb-open .scroll-top {
  display: none !important;
}

#bb-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bb-bubble-user);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  box-shadow: var(--bb-shadow);
  z-index: 9998;
  border: none;
  transition: transform .2s ease;
}
#bb-launcher:hover { transform: scale(1.06); }
#bb-launcher .bb-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 10px; height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--bb-bg);
}

#bb-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--bb-bg);
  color: var(--bb-fg);
  border: 1px solid var(--bb-border);
  border-radius: 16px;
  box-shadow: var(--bb-shadow);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: "Inter", "Roboto", system-ui, -apple-system, sans-serif;
}
#bb-panel.open { display: flex; }

#bb-header {
  background: var(--bb-bubble-user);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#bb-header .bb-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
#bb-header h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.1;
}
#bb-header small {
  display: block;
  font-size: 11px;
  opacity: 0.85;
}
#bb-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

#bb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bb-bg);
}
.bb-msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.bb-msg.bot {
  background: var(--bb-bubble-bot);
  color: var(--bb-fg);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.bb-msg.user {
  background: var(--bb-bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.bb-msg.error {
  background: #fee2e2;
  color: #991b1b;
  align-self: flex-start;
  font-size: 13px;
}
.bb-typing {
  display: inline-flex;
  gap: 4px;
}
.bb-typing span {
  width: 6px; height: 6px;
  background: var(--bb-muted);
  border-radius: 50%;
  animation: bb-blink 1.2s infinite;
}
.bb-typing span:nth-child(2) { animation-delay: .2s; }
.bb-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bb-blink {
  0%, 80%, 100% { opacity: .25; }
  40% { opacity: 1; }
}

#bb-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 8px;
}
#bb-suggestions button {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--bb-border);
  background: transparent;
  color: var(--bb-fg);
  cursor: pointer;
}
#bb-suggestions button:hover { background: var(--bb-bubble-bot); }

#bb-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--bb-border);
  background: var(--bb-bg);
}
#bb-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--bb-border);
  background: var(--bb-bg);
  color: var(--bb-fg);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  max-height: 120px;
  min-height: 40px;
  outline: none;
}
#bb-input:focus { border-color: var(--bb-accent); }
#bb-send {
  background: var(--bb-bubble-user);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 18px;
  cursor: pointer;
}
#bb-send:disabled { opacity: 0.5; cursor: not-allowed; }

#bb-footer-note {
  text-align: center;
  font-size: 10px;
  color: var(--bb-muted);
  padding: 0 0 8px;
}
