/* ============================================================
   FAQ Chatbot Widget — Global Sport Professionals design tokens
   Sits in the standard bottom-right corner; #back-to-top and
   .toast are stacked ABOVE it instead (see main.css) — matching
   the GTP site's layout rather than shifting sideways.
   ============================================================ */

/* ── Floating Action Button ── */
.chatbot-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-lime-shine);
  color: var(--black);
  cursor: pointer;
  box-shadow: var(--shadow-lg), var(--glow-lime);
  transition: transform 150ms cubic-bezier(0.4,0,0.2,1), box-shadow 150ms cubic-bezier(0.4,0,0.2,1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chatbot-fab:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-lg), 0 6px 28px rgba(163,230,53,0.4);
}
.chatbot-fab svg {
  width: 26px;
  height: 26px;
  transition: transform 150ms cubic-bezier(0.4,0,0.2,1), opacity 150ms cubic-bezier(0.4,0,0.2,1);
}
.chatbot-fab .chatbot-icon-close { position: absolute; opacity: 0; transform: rotate(-90deg) scale(0.6); }
.chatbot-fab.open .chatbot-icon-chat { opacity: 0; transform: rotate(90deg) scale(0.6); }
.chatbot-fab.open .chatbot-icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* Attention pulse — runs once on load */
.chatbot-fab:not(.open) { animation: chatbot-pulse 2s ease 1.5s 2; }
@keyframes chatbot-pulse {
  0%, 100% { box-shadow: var(--shadow-lg), 0 0 0 0 rgba(163,230,53,0.45); }
  50%      { box-shadow: var(--shadow-lg), 0 0 0 12px rgba(163,230,53,0); }
}

/* ── Chat Panel ── */
.chatbot-panel {
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  z-index: 9998;
  width: 440px;
  max-height: min(680px, calc(100vh - 8rem));
  border-radius: var(--radius-lg);
  background: rgba(0,0,0,0.97);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(163,230,53,0.1);
  border: 1px solid rgba(163,230,53,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
}
.chatbot-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ── */
.chatbot-header {
  background: var(--gradient-lime-shine);
  color: var(--black);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.chatbot-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chatbot-header-avatar svg { width: 20px; height: 20px; }
.chatbot-header-text { flex: 1; min-width: 0; }
.chatbot-header-title {
  font-family: var(--font-head);
  font-size: 0.9375rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
}
.chatbot-header-subtitle {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.75;
  line-height: 1.3;
}
.chatbot-header-close {
  background: none;
  border: none;
  color: var(--black);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  opacity: 0.7;
  transition: opacity 150ms cubic-bezier(0.4,0,0.2,1), background 150ms cubic-bezier(0.4,0,0.2,1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chatbot-header-close:hover { opacity: 1; background: rgba(0,0,0,0.1); }
.chatbot-header-close svg { width: 18px; height: 18px; }

/* ── Messages Area ── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}
.chatbot-messages::-webkit-scrollbar { width: 5px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: rgba(163,230,53,0.3); border-radius: 4px; }

/* ── Message Bubbles ── */
.chatbot-msg {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  animation: chatbot-msg-in 0.25s cubic-bezier(0.4,0,0.2,1);
}
@keyframes chatbot-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chatbot-msg-bot { align-self: flex-start; }
.chatbot-msg-user { align-self: flex-end; }

.chatbot-bubble {
  position: relative;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.6;
  word-break: break-word;
}
.chatbot-msg-bot .chatbot-bubble {
  background: rgba(13,79,20,0.2);
  color: var(--white);
  border: 1px solid rgba(163,230,53,0.15);
  border-bottom-left-radius: 0.25rem;
}

/* ── Assistant status dots ──
   Green: the live Groq assistant actually answered this message (escalated
   because the local FAQ matcher couldn't confidently answer it alone).
   Amber: escalation was attempted but hit the per-IP rate limit — the
   suggestions shown instead are the local matcher's best (weak) guesses.
   No dot at all: answered for free from the local FAQ match, or the
   assistant failed/was unreachable for a reason other than rate limiting. */
.chatbot-groq-dot,
.chatbot-rate-limit-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(13,79,20,0.9);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
}
.chatbot-groq-dot { background: #22c55e; }
.chatbot-rate-limit-dot { background: #f59e0b; }
.chatbot-msg-user .chatbot-bubble {
  background: var(--gradient-lime-shine);
  color: var(--black);
  border-bottom-right-radius: 0.25rem;
}

/* ── Markdown content inside bubbles ── */
.chatbot-bubble p { margin: 0 0 0.35rem; }
.chatbot-bubble p:last-child { margin-bottom: 0; }
.chatbot-bubble ul {
  margin: 0.25rem 0;
  padding-left: 1.15rem;
  list-style: disc;
}
.chatbot-bubble li { margin-bottom: 0.15rem; }
.chatbot-bubble li:last-child { margin-bottom: 0; }
.chatbot-bubble strong { font-weight: 600; }
.chatbot-bubble a {
  color: var(--lime);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
  transition: color 150ms cubic-bezier(0.4,0,0.2,1);
}
.chatbot-bubble a:hover {
  color: var(--lime-bright);
}
.chatbot-msg-user .chatbot-bubble a {
  color: var(--black);
  text-decoration-color: rgba(0,0,0,0.5);
}
.chatbot-msg-user .chatbot-bubble a:hover {
  text-decoration-color: var(--black);
}

/* ── Typing Indicator ── */
.chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 0.75rem 0.875rem;
  align-self: flex-start;
  background: rgba(13,79,20,0.2);
  border: 1px solid rgba(163,230,53,0.15);
  border-radius: var(--radius-sm);
  border-bottom-left-radius: 0.25rem;
}
.chatbot-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime-dim);
  animation: chatbot-bounce 1.2s ease-in-out infinite;
}
.chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatbot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ── Quick Suggestions ── */
.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.375rem;
}
.chatbot-suggestion {
  background: rgba(163,230,53,0.06);
  border: 1px solid rgba(163,230,53,0.2);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 150ms cubic-bezier(0.4,0,0.2,1), color 150ms cubic-bezier(0.4,0,0.2,1), border-color 150ms cubic-bezier(0.4,0,0.2,1);
  font-family: var(--font-body);
}
.chatbot-suggestion:hover {
  background: rgba(163,230,53,0.14);
  color: var(--lime);
  border-color: rgba(163,230,53,0.4);
}

/* ── Input Area ── */
.chatbot-input-area {
  padding: 0.75rem;
  border-top: 1px solid rgba(163,230,53,0.15);
  background: rgba(0,0,0,0.4);
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-shrink: 0;
}
.chatbot-input {
  flex: 1;
  border: 1px solid rgba(163,230,53,0.2);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.875rem;
  font-size: 0.875rem;
  font-family: var(--font-body);
  color: var(--white);
  background: rgba(255,255,255,0.03);
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 100px;
  line-height: 1.5;
  transition: border-color 150ms cubic-bezier(0.4,0,0.2,1), box-shadow 150ms cubic-bezier(0.4,0,0.2,1);
}
.chatbot-input::placeholder { color: var(--mid-grey); }
.chatbot-input:focus {
  border-color: rgba(163,230,53,0.5);
  box-shadow: 0 0 0 3px rgba(163,230,53,0.1);
}
.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gradient-lime-shine);
  color: var(--black);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter 150ms cubic-bezier(0.4,0,0.2,1), transform 150ms cubic-bezier(0.4,0,0.2,1);
}
.chatbot-send:hover { filter: brightness(1.1); }
.chatbot-send:active { transform: scale(0.94); }
.chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; }
.chatbot-send svg { width: 18px; height: 18px; }

/* ── Error State ── */
.chatbot-error {
  font-size: 0.8125rem;
  color: #ef4444;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  text-align: center;
  animation: chatbot-msg-in 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Powered-by footer ── */
.chatbot-powered {
  text-align: center;
  padding: 0.375rem;
  font-size: 0.625rem;
  color: var(--mid-grey);
  background: rgba(0,0,0,0.4);
  border-top: 1px solid rgba(163,230,53,0.08);
  flex-shrink: 0;
}

/* ── Mobile Responsive ── */
@media (max-width: 480px) {
  .chatbot-panel {
    width: calc(100vw - 1.5rem);
    right: 0.75rem;
    bottom: 5rem;
    max-height: calc(100vh - 6.5rem);
    border-radius: var(--radius-md);
  }
  .chatbot-fab {
    bottom: 1rem;
    right: 1rem;
    width: 50px;
    height: 50px;
  }
  .chatbot-fab svg { width: 22px; height: 22px; }
}
