/* WABABA landing assistant — light, glassy, matches the app theme (green primary) */

.wb-chatbot-widget {
  --wbc-primary: var(--primary, #128a46);
  --wbc-accent: #25d366;
  --wbc-ink: var(--foreground, #0f2a1c);
  --wbc-muted: var(--muted-foreground, #5b6b62);
  --wbc-line: rgba(18, 138, 70, 0.14);
  --wbc-glass: rgba(255, 255, 255, 0.78);
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  font-family: var(--font-sans, "Manrope", system-ui, sans-serif);
  color: var(--wbc-ink);
  /* Pops in shortly after the logo intro finishes (see html.intro-playing below). */
  transition: opacity 0.45s ease 0.5s, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s, visibility 0s linear 0.5s;
}

/* Hidden while the landing logo intro plays — it shares the intro's z-index and used to sit on top of it. */
html.intro-playing .wb-chatbot-widget {
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(0.85);
  pointer-events: none;
}

.wb-chatbot-widget svg { display: block; }

/* ── Launcher (round logo) ── */
.wb-chatbot-toggle {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 0 2px #fff, 0 10px 30px -8px rgba(18, 138, 70, 0.45), 0 2px 6px rgba(15, 42, 28, 0.08);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease;
}
.wb-chatbot-toggle:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 0 0 2px #fff, 0 16px 36px -10px rgba(18, 138, 70, 0.55); }
.wb-chatbot-toggle:focus-visible { outline: 3px solid rgba(37, 211, 102, 0.45); outline-offset: 3px; }
.wb-chatbot-toggle-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.wb-chatbot-widget.open .wb-chatbot-toggle { display: none; }

/* green gradient ring, slowly rotating */
.wb-chatbot-toggle::after {
  content: "";
  position: absolute;
  inset: -5px;
  padding: 3px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #25d366, #128a46, #7ee2a8, #25d366);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: wbcSpin 4s linear infinite;
  pointer-events: none;
}
@keyframes wbcSpin { to { transform: rotate(360deg); } }

/* soft attention pulse while closed */
.wb-chatbot-toggle::before {
  content: "";
  position: absolute;
  inset: -11px;
  border-radius: 50%;
  border: 2px solid rgba(37, 211, 102, 0.45);
  animation: wbcPulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes wbcPulse {
  0% { transform: scale(0.92); opacity: 0.9; }
  70% { transform: scale(1.18); opacity: 0; }
  100% { opacity: 0; }
}
.wb-chatbot-toggle-dot {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--wbc-accent);
  border: 2.5px solid #fff;
}

/* ── Window ── */
.wb-chatbot-window {
  display: none;
  flex-direction: column;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: min(820px, calc(100vh - 48px));
  height: min(820px, calc(100dvh - 48px));
  background: var(--wbc-glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  box-shadow: 0 0 0 1px var(--wbc-line), 0 30px 70px -24px rgba(15, 42, 28, 0.35), 0 8px 24px -12px rgba(18, 138, 70, 0.25);
  overflow: hidden;
  transform-origin: bottom right;
}
.wb-chatbot-widget.open .wb-chatbot-window { display: flex; animation: wbcOpen 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes wbcOpen {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* Header */
.wb-chatbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.16), rgba(255, 255, 255, 0.35) 60%);
  border-bottom: 1px solid var(--wbc-line);
}
.wb-chatbot-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px var(--wbc-line), 0 4px 12px -4px rgba(18, 138, 70, 0.35);
}
.wb-chatbot-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.wb-chatbot-avatar::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--wbc-accent);
  border: 2px solid #fff;
}
.wb-chatbot-header-info { flex: 1; min-width: 0; }
.wb-chatbot-header-info h3 {
  margin: 0;
  font-family: var(--font-display, "Sora", sans-serif);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--wbc-ink);
}
.wb-chatbot-header-info p {
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--wbc-muted);
}
.wb-chatbot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--wbc-accent); box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2); }
.wb-chatbot-icon-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--wbc-muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.wb-chatbot-icon-btn:hover { background: rgba(18, 138, 70, 0.1); color: var(--wbc-primary); }
.wb-chatbot-icon-btn svg { width: 18px; height: 18px; }

/* Messages */
.wb-chatbot-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-image: radial-gradient(rgba(18, 138, 70, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(18, 138, 70, 0.25) transparent;
}
.wb-chatbot-message { display: flex; align-items: flex-end; gap: 8px; max-width: 88%; animation: wbcMsg 0.25s ease-out; }
@keyframes wbcMsg { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.wb-chatbot-message.bot { align-self: flex-start; }
.wb-chatbot-message.user { align-self: flex-end; flex-direction: row-reverse; }
.wb-chatbot-msg-avatar {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px var(--wbc-line);
  object-fit: cover;
}
.wb-chatbot-bubble {
  padding: 10px 13px 6px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.wb-chatbot-message.bot .wb-chatbot-bubble {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--wbc-line);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 2px 8px -4px rgba(15, 42, 28, 0.12);
  color: var(--wbc-ink);
}
.wb-chatbot-message.user .wb-chatbot-bubble {
  background: linear-gradient(135deg, var(--wbc-primary), #18a957);
  border-radius: 16px 16px 4px 16px;
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(18, 138, 70, 0.6);
}
.wb-chatbot-bubble strong { font-weight: 800; }
.wb-chatbot-bubble a { color: var(--wbc-primary); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.wb-chatbot-message.user .wb-chatbot-bubble a { color: #fff; }
.wb-chatbot-bubble ul { margin: 4px 0; padding-left: 18px; }
.wb-chatbot-bubble li { margin: 2px 0; }
.wb-chatbot-time {
  margin-top: 3px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: #94a3a0;
}
.wb-chatbot-message.user .wb-chatbot-time { color: rgba(255, 255, 255, 0.82); }
.wb-chatbot-time svg { width: 13px; height: 13px; }
.wb-chatbot-message.error .wb-chatbot-bubble { border-color: rgba(220, 38, 38, 0.25); background: rgba(254, 242, 242, 0.95); }

/* Typing indicator */
.wb-chatbot-typing {
  display: none;
  align-self: flex-start;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px 16px 16px 4px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--wbc-line);
}
.wb-chatbot-typing.active { display: flex; }
.wb-chatbot-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--wbc-accent); animation: wbcTyping 1.3s infinite ease-in-out both; }
.wb-chatbot-dot:nth-child(1) { animation-delay: -0.32s; }
.wb-chatbot-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes wbcTyping { 0%, 80%, 100% { transform: scale(0.5); opacity: 0.45; } 40% { transform: scale(1); opacity: 1; } }

/* Quick questions */
.wb-chatbot-chips-area {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 8px;
  border-top: 1px solid var(--wbc-line);
  background: rgba(255, 255, 255, 0.55);
}
.wb-chatbot-chips-primary,
.wb-chatbot-chips-secondary {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
  mask-image: linear-gradient(90deg, #000 88%, transparent);
  padding-right: 18px;
}
.wb-chatbot-chips-primary::-webkit-scrollbar,
.wb-chatbot-chips-secondary::-webkit-scrollbar { display: none; }
.wb-chatbot-chip-primary {
  flex-shrink: 0;
  padding: 6px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(18, 138, 70, 0.07);
  color: var(--wbc-muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.wb-chatbot-chip-primary:hover { color: var(--wbc-primary); border-color: rgba(18, 138, 70, 0.25); }
.wb-chatbot-chip-primary.active { background: var(--wbc-primary); color: #fff; }
.wb-chatbot-chip-primary.link { background: rgba(37, 211, 102, 0.14); color: var(--wbc-primary); }
.wb-chatbot-chip-secondary {
  flex-shrink: 0;
  padding: 7px 12px;
  border: 1px solid rgba(18, 138, 70, 0.22);
  border-radius: 999px;
  background: #fff;
  color: var(--wbc-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.wb-chatbot-chip-secondary:hover { border-color: var(--wbc-primary); color: var(--wbc-primary); transform: translateY(-1px); }
.wb-chatbot-chip-secondary:disabled { opacity: 0.5; cursor: default; transform: none; }

/* Input */
.wb-chatbot-input-area {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 6px;
  background: rgba(255, 255, 255, 0.7);
}
.wb-chatbot-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(18, 138, 70, 0.2);
  border-radius: 999px;
  background: #fff;
  color: var(--wbc-ink);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.wb-chatbot-input::placeholder { color: #9aa8a1; }
.wb-chatbot-input:focus { border-color: var(--wbc-primary); box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.15); }
.wb-chatbot-send {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wbc-primary), #18a957);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 18px -8px rgba(18, 138, 70, 0.7);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.wb-chatbot-send svg { width: 18px; height: 18px; margin-left: -2px; }
.wb-chatbot-send:not(:disabled):hover { transform: scale(1.06); }
.wb-chatbot-send:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.wb-chatbot-footer {
  flex-shrink: 0;
  padding: 2px 0 9px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: #9aa8a1;
  background: rgba(255, 255, 255, 0.7);
}
.wb-chatbot-footer b { color: var(--wbc-primary); }

/* Fallback for browsers without backdrop-filter */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .wb-chatbot-window { background: rgba(255, 255, 255, 0.97); }
}

/* Mobile: near full-screen sheet */
@media (max-width: 520px) {
  .wb-chatbot-widget { right: 12px; bottom: 12px; gap: 10px; }
  .wb-chatbot-window {
    width: calc(100vw - 24px);
    max-width: none;
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
    border-radius: 20px;
  }
  .wb-chatbot-toggle { width: 58px; height: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  .wb-chatbot-toggle::before, .wb-chatbot-toggle::after { animation: none; }
  .wb-chatbot-widget.open .wb-chatbot-window, .wb-chatbot-message { animation: none; }
}
