/* =========================================================================
   chatbot.css, floating FAQ chatbot widget. Uses the site's own design
   tokens (--gold, --surface, --border, --text*) so it themes automatically
   with the dark/light toggle, no separate light-mode overrides needed.
   ========================================================================= */

.chatbot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: var(--font-body);
}

/* ── Floating toggle button ────────────────────────────────────────────── */
.chatbot-toggle {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1a1407;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease), visibility 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.chatbot-toggle:hover { transform: scale(1.08); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4); }
.chatbot-toggle:active { transform: scale(0.95); }
.chatbot-toggle .chatbot-icon-chat { width: 24px; height: 24px; }
.chatbot-toggle.is-open { transform: scale(0.5) translateY(20px); opacity: 0; pointer-events: none; visibility: hidden; }

/* ── Chat window ───────────────────────────────────────────────────────── */
@keyframes chatbot-pop-in {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes chatbot-pop-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(24px) scale(0.94); }
}

.chatbot-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  height: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  isolation: isolate;
}
.chatbot-window.open { opacity: 1; visibility: visible; pointer-events: auto; animation: chatbot-pop-in 0.35s var(--ease) both; }
.chatbot-window.closing { animation: chatbot-pop-out 0.25s ease forwards; }

/* ── Header (panels 1 & 2) ────────────────────────────────────────────── */
.chatbot-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chatbot-header-avatar {
  width: 34px; height: 34px; border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1a1407;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.chatbot-header-content { flex: 1; min-width: 0; }
.chatbot-title { font-size: 14px; font-weight: 600; margin: 0; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatbot-subtitle { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; display: flex; align-items: center; gap: 5px; }
.chatbot-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #2d8a4e; flex-shrink: 0; }

.chatbot-header-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.chatbot-header-btn {
  width: 30px; height: 30px; border: none; background: transparent; border-radius: var(--r-sm);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background 0.15s, color 0.15s;
}
.chatbot-header-btn svg { width: 16px; height: 16px; }
.chatbot-header-btn:hover { background: var(--card-2); color: var(--text-strong); }

/* ── Panels ────────────────────────────────────────────────────────────── */
.chatbot-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--surface); }
.chatbot-panel[hidden] { display: none; }

/* ── Welcome panel ─────────────────────────────────────────────────────── */
.chatbot-welcome-panel { animation: chatbot-pop-in 0.3s ease forwards; }

.chatbot-welcome-hero {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  padding: 28px 20px 24px;
  background: linear-gradient(160deg, var(--navy) 0%, var(--bg) 130%);
  border-bottom: 1px solid var(--gold-soft);
}
.chatbot-welcome-hero-orb { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.06); pointer-events: none; }
.chatbot-welcome-hero-orb--top { width: 180px; height: 180px; top: -60px; right: -50px; }
.chatbot-welcome-hero-orb--bottom { width: 120px; height: 120px; bottom: -40px; left: -30px; }

.chatbot-welcome-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; z-index: 2; }
.chatbot-welcome-action-btn {
  background: rgba(255, 255, 255, 0.12); border: none; border-radius: var(--r-sm);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: rgba(255, 255, 255, 0.85); transition: background 0.2s;
}
.chatbot-welcome-action-btn svg { width: 14px; height: 14px; }
.chatbot-welcome-action-btn:hover { background: rgba(255, 255, 255, 0.22); }

.chatbot-welcome-hero-icon {
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--gold-soft); border: 1.5px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px; position: relative; z-index: 1; color: var(--gold-bright);
}
.chatbot-welcome-hero-icon svg { width: 22px; height: 22px; }
.chatbot-welcome-greeting { font-size: 22px; font-weight: 600; color: #ffffff; margin: 0 0 6px; position: relative; z-index: 1; }
.chatbot-welcome-tagline { font-size: 13px; color: rgba(255, 255, 255, 0.72); margin: 0; line-height: 1.5; max-width: 240px; position: relative; z-index: 1; }

.chatbot-welcome-body { padding: 16px 16px 8px; flex: 1; overflow-y: auto; background: var(--surface); }

.chatbot-welcome-new-chat {
  width: 100%; background: var(--gold-soft); border: 1px solid rgba(195, 163, 104, 0.5);
  border-radius: var(--r-sm); padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  cursor: pointer; margin-bottom: 10px; text-align: left; transition: background 0.2s, border-color 0.2s;
}
.chatbot-welcome-new-chat:hover { background: var(--card-2); border-color: var(--border-strong); }
.chatbot-welcome-new-chat-icon {
  width: 36px; height: 36px; border-radius: 10px; background: var(--gold-soft); border: 1.5px solid var(--gold);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--gold-bright);
}
.chatbot-welcome-new-chat-icon svg { width: 16px; height: 16px; }
.chatbot-welcome-new-chat-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.chatbot-welcome-new-chat-text strong { font-size: 13px; font-weight: 600; color: var(--gold-bright); }
.chatbot-welcome-new-chat-text span { font-size: 11px; color: var(--text-muted); }
.chatbot-welcome-arrow { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

.chatbot-welcome-topics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chatbot-welcome-topic {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; cursor: pointer;
  text-align: left; transition: background 0.2s, border-color 0.2s;
}
.chatbot-welcome-topic:hover { background: var(--gold-soft); border-color: rgba(195, 163, 104, 0.5); }
.chatbot-welcome-topic svg { width: 16px; height: 16px; color: var(--gold); margin-bottom: 4px; }
.chatbot-welcome-topic strong { font-size: 11px; font-weight: 600; color: var(--text-strong); }
.chatbot-welcome-topic span { font-size: 10px; color: var(--text-muted); }

/* ── Contact capture panel ────────────────────────────────────────────── */
.chatbot-contact-intro { padding: 20px 18px 4px; }
.chatbot-contact-intro p { font-size: 13.5px; color: var(--text); margin: 0; line-height: 1.55; }

.chatbot-contact-form { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 14px; }
.chatbot-field { display: flex; flex-direction: column; gap: 5px; }
.chatbot-label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.02em; text-transform: uppercase; }
.chatbot-field-input {
  padding: 9px 12px; font-size: 14px; border: 1px solid var(--border); border-radius: var(--r-sm);
  outline: none; background: var(--card); color: var(--text-strong); width: 100%; box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chatbot-field-input::placeholder { color: var(--text-muted); }
.chatbot-field-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.chatbot-field-input.is-invalid { border-color: #c0392b; box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12); }
.chatbot-field-error { font-size: 12px; color: #e0685a; min-height: 16px; line-height: 1.4; }

.chatbot-contact-submit {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; color: #1a1407;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  border: none; border-radius: var(--r-sm); cursor: pointer; margin-top: 2px;
  transition: opacity 0.15s, transform 0.1s;
}
.chatbot-contact-submit svg { width: 16px; height: 16px; }
.chatbot-contact-submit:hover { opacity: 0.9; }
.chatbot-contact-submit:active { transform: scale(0.98); }
.chatbot-contact-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.chatbot-privacy-note { font-size: 11.5px; color: var(--text-muted); text-align: center; margin: 0; line-height: 1.5; }

/* ── Messages ──────────────────────────────────────────────────────────── */
.chatbot-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.chatbot-messages::-webkit-scrollbar { width: 6px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: var(--gold-soft); border-radius: 3px; }

@keyframes chatbot-message-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chatbot-message { display: flex; animation: chatbot-message-in 0.25s var(--ease); }
.chatbot-message.bot-message { justify-content: flex-start; }
.chatbot-message.user-message { justify-content: flex-end; }

.chatbot-message-content { max-width: 78%; padding: 11px 15px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; word-wrap: break-word; }
.bot-message .chatbot-message-content { background: var(--card-2); border: 1px solid var(--border); color: var(--text); }
.user-message .chatbot-message-content { background: var(--gold-soft); border: 1px solid rgba(195, 163, 104, 0.35); color: var(--gold-bright); }
.chatbot-message-content p { margin: 0; }

/* ── Suggestions ───────────────────────────────────────────────────────── */
.chatbot-suggestions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; animation: chatbot-message-in 0.3s var(--ease); }
.chatbot-suggestion-btn {
  padding: 10px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; text-align: left;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.chatbot-suggestion-btn:hover { background: var(--gold-soft); border-color: rgba(195, 163, 104, 0.5); color: var(--gold-bright); transform: translateX(3px); }

/* ── Typing indicator ──────────────────────────────────────────────────── */
.chatbot-typing { display: flex; gap: 4px; padding: 12px 16px; background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; width: fit-content; }
.chatbot-typing-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); animation: chatbot-typing 1.4s infinite; }
.chatbot-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatbot-typing {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-6px); }
}

/* ── Input ─────────────────────────────────────────────────────────────── */
.chatbot-input-container { padding: 14px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chatbot-input-form { display: flex; gap: 8px; align-items: center; }
.chatbot-input {
  flex: 1; background: var(--card); border: 1px solid var(--border); color: var(--text-strong);
  padding: 10px 14px; border-radius: var(--r-sm); font-size: 14px; font-family: inherit; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chatbot-input::placeholder { color: var(--text-muted); }
.chatbot-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }

.chatbot-send-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold)); color: #1a1407;
  border: none; border-radius: var(--r-sm); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
}
.chatbot-send-btn svg { width: 17px; height: 17px; }
.chatbot-send-btn:hover { transform: scale(1.06); opacity: 0.92; }
.chatbot-send-btn:active { transform: scale(0.95); }

/* ── Footer attribution ────────────────────────────────────────────────── */
.chatbot-footer { display: flex; align-items: center; justify-content: center; padding: 8px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chatbot-footer-link { font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--gold); text-decoration: none; transition: color 0.2s; }
.chatbot-footer-link:hover, .chatbot-footer-link:focus-visible { color: var(--gold-bright); text-decoration: underline; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .chatbot-widget { bottom: 16px; right: 16px; }
  .chatbot-window { width: calc(100vw - 32px); height: min(560px, 78vh); bottom: 72px; right: 0; left: 0; margin: 0 auto; }
  .chatbot-toggle { width: 50px; height: 50px; }
}
