/* FinanceGuide Chatbot — Chat Widget v1.5
   Self-contained. Zero external dependencies. */

/* ── Variables ───────────────────────────────────────────────────────────────── */
:root {
  --fgb-primary:       #1a6b3c;
  --fgb-primary-light: #2d9056;
  --fgb-primary-dark:  #0f4527;
  --fgb-bg:            #ffffff;
  --fgb-surface:       #f8faf9;
  --fgb-border:        #e4ede9;
  --fgb-text:          #1c2b22;
  --fgb-text-muted:    #6b7c73;
  --fgb-user-bg:       var(--fgb-primary);
  --fgb-user-text:     #ffffff;
  --fgb-bot-bg:        #f1f5f2;
  --fgb-shadow:        0 8px 40px rgba(26,107,60,0.18), 0 2px 8px rgba(0,0,0,0.08);
  --fgb-radius:        16px;
  --fgb-bubble-r:      12px;
  --fgb-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --fgb-z:             9999;
  --fgb-w:             370px;
  --fgb-h:             540px;
}

/* ── Root ────────────────────────────────────────────────────────────────────── */
#fgb-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--fgb-z);
  font-family: var(--fgb-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fgb-text);
  box-sizing: border-box;
}
#fgb-root *, #fgb-root *::before, #fgb-root *::after { box-sizing: border-box; }

/* ── Bubble button ───────────────────────────────────────────────────────────── */
#fgb-bubble {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--fgb-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(26,107,60,0.35), 0 2px 6px rgba(0,0,0,0.12);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, background .2s;
  outline: none;
}
#fgb-bubble:hover  { background: var(--fgb-primary-light); transform: scale(1.08); box-shadow: 0 6px 28px rgba(26,107,60,.45); }
#fgb-bubble:active { transform: scale(.96); }
#fgb-bubble svg    { width: 26px; height: 26px; }
#fgb-bubble::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--fgb-primary); opacity: 0;
  animation: fgb-pulse 2.5s ease-out infinite; pointer-events: none;
}
@keyframes fgb-pulse { 0% { opacity:.6; transform:scale(1); } 100% { opacity:0; transform:scale(1.5); } }

/* Badge */
#fgb-badge {
  position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px;
  border-radius: 9px; background: #e53e3e; color: white;
  font-size: 11px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; padding: 0 4px; border: 2px solid white;
  animation: fgb-badge-pop .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes fgb-badge-pop { from { transform:scale(0); } to { transform:scale(1); } }

/* Proactive tooltip */
.fgb-proactive-tip {
  position: absolute; bottom: 68px; right: 0; white-space: nowrap;
  background: #1c2b22; color: white; font-size: 12px; padding: 7px 12px;
  border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: fgb-fade-in .3s ease;
}
.fgb-proactive-tip::after {
  content: ''; position: absolute; bottom: -6px; right: 18px;
  border: 6px solid transparent; border-top-color: #1c2b22; border-bottom: 0;
}
@keyframes fgb-fade-in { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

/* ── Chat window ─────────────────────────────────────────────────────────────── */
#fgb-window {
  position: absolute; bottom: 70px; right: 0;
  width: var(--fgb-w); max-width: calc(100vw - 32px);
  height: var(--fgb-h); max-height: calc(100vh - 120px);
  background: var(--fgb-bg); border-radius: var(--fgb-radius);
  box-shadow: var(--fgb-shadow); display: flex; flex-direction: column;
  overflow: hidden; border: 1px solid var(--fgb-border);
  transform: scale(.85) translateY(20px); transform-origin: bottom right;
  opacity: 0; pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.4,.64,1), opacity .25s ease;
}
#fgb-window.fgb-window--open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

/* ── Header ──────────────────────────────────────────────────────────────────── */
#fgb-header {
  display: flex; align-items: center; gap: 6px; padding: 10px 10px;
  background: linear-gradient(135deg, var(--fgb-primary) 0%, var(--fgb-primary-light) 100%);
  flex-shrink: 0;
}
.fgb-header-avatar {
  width: 35px; height: 35px; border-radius: 50%;
  background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.fgb-header-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.fgb-header-title { font-weight: 700; font-size: 15px; color: white; letter-spacing: -.01em; }
.fgb-header-status { font-size: 11px; color: rgba(255,255,255,.8); display: flex; align-items: center; gap: 5px; }
.fgb-status-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #4ade80;
  animation: fgb-online 2s ease-in-out infinite;
}
@keyframes fgb-online { 0%,100% { opacity:1; } 50% { opacity:.5; } }
#fgb-minimize {
  background: rgba(255,255,255,.12); border: none; border-radius: 8px;
  width: 34px; height: 34px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
  color: white;          /* ensures currentColor on SVG strokes resolves correctly */
  padding: 0;            /* kill any browser-default button padding */
  line-height: 1;
}
#fgb-minimize svg { display: block; pointer-events: none; }
#fgb-minimize:hover { background: rgba(255,255,255,.28); }

/* ── Messages area ───────────────────────────────────────────────────────────── */
#fgb-messages {
  flex: 1; overflow-y: auto; padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth; background: var(--fgb-surface);
  -webkit-overflow-scrolling: touch;
}
#fgb-messages::-webkit-scrollbar { width: 4px; }
#fgb-messages::-webkit-scrollbar-thumb { background: #c8d8ce; border-radius: 2px; }

/* ── Message rows ────────────────────────────────────────────────────────────── */
.fgb-msg {
  display: flex; align-items: flex-end; gap: 8px; max-width: 100%;
  animation: fgb-msg-in .28s cubic-bezier(.22,1,.36,1);
}
@keyframes fgb-msg-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
.fgb-msg--user { justify-content: flex-end; }
.fgb-msg--bot  { justify-content: flex-start; }

.fgb-bot-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 1px 4px rgba(0,0,0,.1); margin-bottom: 2px;
}

.fgb-bubble {
  max-width: calc(100% - 40px); padding: 10px 14px;
  border-radius: var(--fgb-bubble-r); font-size: 13.5px; line-height: 1.55;
  word-wrap: break-word; overflow-wrap: break-word;
}
.fgb-bubble--user { background: var(--fgb-user-bg); color: white; border-bottom-right-radius: 4px; margin-left: auto; }
.fgb-bubble--bot  { background: var(--fgb-bot-bg); color: var(--fgb-text); border-bottom-left-radius: 4px; }

/* ── Answer block ────────────────────────────────────────────────────────────── */
.fgb-answer-block { display: flex; flex-direction: column; gap: 7px; }
.fgb-answer-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fgb-primary); font-weight: 600; }
.fgb-answer-text  { font-size: 13.5px; line-height: 1.65; color: var(--fgb-text); }

/* Rich text inside answers */
.fgb-num    { display: inline-block; font-weight: 700; color: var(--fgb-primary); margin-right: 2px; }
.fgb-bullet { color: var(--fgb-primary); margin-right: 4px; }

/* Clickable links inside bot messages */
.fgb-link,
.fgb-bubble--bot a {
  color: var(--fgb-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-all;
  font-weight: 500;
  transition: opacity 0.15s;
}
.fgb-link:hover,
.fgb-bubble--bot a:hover { opacity: 0.75; }

/* Fuzzy match label */
.fgb-fuzzy-label {
  font-size: 12px; color: var(--fgb-text-muted); margin-bottom: 6px;
  padding: 5px 8px; background: rgba(26,107,60,.06); border-radius: 6px;
  border-left: 2px solid var(--fgb-primary);
}

/* ── Fallback block ──────────────────────────────────────────────────────────── */
.fgb-fallback-block { display: flex; flex-direction: column; gap: 10px; }
.fgb-fallback-msg { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; color: var(--fgb-text-muted); }
.fgb-suggestions-label { font-size: 11.5px; font-weight: 700; color: var(--fgb-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.fgb-suggestions-list  { display: flex; flex-direction: column; gap: 6px; }

.fgb-suggestion-btn {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: white; border: 1.5px solid var(--fgb-border); border-radius: 10px;
  cursor: pointer; font-size: 12.5px; font-family: var(--fgb-font); color: var(--fgb-primary);
  text-align: left; line-height: 1.4; font-weight: 500;
  transition: background .15s, border-color .15s, transform .1s;
}
.fgb-suggestion-btn:hover  { background: #f0faf4; border-color: var(--fgb-primary-light); transform: translateX(2px); }
.fgb-suggestion-btn:active { transform: scale(.98); }
.fgb-suggestion-btn svg { flex-shrink: 0; opacity: .6; }

/* ── CTA ─────────────────────────────────────────────────────────────────────── */
.fgb-cta {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fgb-text-muted);
  padding: 8px 10px; background: rgba(26,107,60,.06); border-radius: 8px; border-left: 3px solid var(--fgb-primary);
}
.fgb-cta a { color: var(--fgb-primary); text-decoration: none; font-weight: 700; transition: color .15s; }
.fgb-cta a:hover { color: var(--fgb-primary-light); text-decoration: underline; }

/* ── Feedback buttons ────────────────────────────────────────────────────────── */
.fgb-feedback {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--fgb-border);
}
.fgb-fb-label  { font-size: 11.5px; color: var(--fgb-text-muted); }
.fgb-fb-btn {
  background: none; border: 1.5px solid var(--fgb-border); border-radius: 6px;
  padding: 3px 8px; cursor: pointer; font-size: 14px; transition: background .15s, border-color .15s, transform .1s;
}
.fgb-fb-btn:hover  { background: #f0faf4; border-color: var(--fgb-primary-light); transform: scale(1.1); }
.fgb-fb-btn:active { transform: scale(.95); }
.fgb-fb-thanks { font-size: 12px; font-weight: 600; }
.fgb-fb-up   { color: var(--fgb-primary); }
.fgb-fb-down { color: #e53e3e; }

/* ── Category grid (onboarding) ──────────────────────────────────────────────── */
.fgb-category-row { width: 100%; }
.fgb-category-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 4px 0;
}
.fgb-cat-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 10px 6px; background: white; border: 1.5px solid var(--fgb-border); border-radius: 10px;
  cursor: pointer; font-size: 12px; font-family: var(--fgb-font); color: var(--fgb-text); font-weight: 600;
  transition: background .15s, border-color .15s, transform .1s; text-align: center;
}
.fgb-cat-chip:hover  { background: #f0faf4; border-color: var(--fgb-primary); transform: translateY(-2px); }
.fgb-cat-chip:active { transform: scale(.97); }
.fgb-cat-chip span   { font-size: 11.5px; }

/* Category results heading */
.fgb-category-heading { font-size: 13px; font-weight: 700; color: var(--fgb-primary); margin-bottom: 10px; }
.fgb-category-results { display: flex; flex-direction: column; gap: 4px; }

/* ── Chips bar ───────────────────────────────────────────────────────────────── */
#fgb-chips-bar {
  display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto;
  background: var(--fgb-surface); border-top: 1px solid var(--fgb-border);
  flex-shrink: 0; scrollbar-width: none;
  animation: fgb-msg-in .2s ease;
}
#fgb-chips-bar::-webkit-scrollbar { display: none; }

.fgb-chip {
  flex-shrink: 0; padding: 6px 12px; background: white; border: 1.5px solid var(--fgb-border);
  border-radius: 20px; cursor: pointer; font-size: 12px; font-family: var(--fgb-font);
  color: var(--fgb-primary); white-space: nowrap; font-weight: 500;
  transition: background .15s, border-color .15s, transform .1s;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
.fgb-chip:hover  { background: #f0faf4; border-color: var(--fgb-primary-light); }
.fgb-chip:active { transform: scale(.97); }

/* ── Typing indicator ────────────────────────────────────────────────────────── */
.fgb-typing-bubble { display: flex; align-items: center; gap: 5px; padding: 12px 16px; }
.fgb-typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #aabfb3;
  animation: fgb-typing 1.2s ease-in-out infinite;
}
.fgb-typing-dot:nth-child(2) { animation-delay: .2s; }
.fgb-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes fgb-typing { 0%,80%,100% { transform:translateY(0);opacity:.4; } 40% { transform:translateY(-6px);opacity:1; } }

/* ── Input area ──────────────────────────────────────────────────────────────── */
#fgb-input-area {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px;
  background: var(--fgb-bg); border-top: 1px solid var(--fgb-border); flex-shrink: 0;
  margin-top: 10px;
  padding-top: 12px;
}
#fgb-input {
  flex: 1; padding: 11px 16px; background: var(--fgb-surface); border: 1.5px solid #6df7f1;
  border-radius: 22px; font-size: 14.5px; font-family: var(--fgb-font); color: var(--fgb-text);
  resize: none; outline: none; line-height: 1.55; min-height: 44px; max-height: 120px;
  transition: border-color .2s, box-shadow .2s;
}
#fgb-input:focus   { border-color: var(--fgb-primary); box-shadow: 0 0 0 3px rgba(26,107,60,.1); background: white; }
#fgb-input::placeholder { color: #9bb5a5; }

/* ── Voice input & voice output toggle buttons ──────────────────────────────── */
#fgb-voice-in,
#fgb-voice-out {
  flex-shrink: 0;
  width: 36px; height: 36px;
  padding: 0;                          /* remove all default button padding */
  border: 1.5px solid var(--fgb-border);
  border-radius: 50%;
  background: var(--fgb-surface);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  transition: background .15s, border-color .15s, transform .1s;
  color: var(--fgb-text);              /* override any theme colour */
}
#fgb-voice-in:hover,
#fgb-voice-out:hover  { background: #e8f5ee; border-color: var(--fgb-primary); }
#fgb-voice-in:active,
#fgb-voice-out:active { transform: scale(.93); }
#fgb-voice-in.fgb-recording {
  background: #fee2e2; border-color: #ef4444; animation: fgb-pulse-rec .8s ease-in-out infinite;
}
@keyframes fgb-pulse-rec { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); } 50% { box-shadow: 0 0 0 5px rgba(239,68,68,0); } }

/* ── Send button ─────────────────────────────────────────────────────────────── */
#fgb-send {
  flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 50%; background: var(--fgb-primary);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: white;                        /* ensures SVG fill="currentColor" is always white */
  padding: 0;
  transition: background .15s, transform .15s;
}
#fgb-send svg { display: block; pointer-events: none; }
#fgb-send:hover:not(:disabled)  { background: var(--fgb-primary-light); transform: scale(1.05); }
#fgb-send:disabled               { background: #c8d8ce; cursor: not-allowed; }
#fgb-send:active:not(:disabled)  { transform: scale(.95); }

/* ── Guided Flow options ─────────────────────────────────────────────────────── */
.fgb-flow-message {
  font-size: 13.5px; line-height: 1.55; color: var(--fgb-text);
  margin-bottom: 10px; font-weight: 500;
}
.fgb-flow-options {
  display: flex; flex-direction: column; gap: 7px;
  margin-top: 6px;
}
.fgb-flow-opt {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 10px 14px;
  background: white; border: 1.5px solid var(--fgb-border);
  border-radius: 10px; cursor: pointer;
  font-size: 13.5px; font-family: var(--fgb-font); color: var(--fgb-text);
  font-weight: 500; text-align: left; line-height: 1.4;
  transition: border-color .15s, background .15s, transform .1s, box-shadow .15s;
}
.fgb-flow-opt:hover  {
  border-color: var(--fgb-primary); background: #f0faf4;
  box-shadow: 0 2px 8px rgba(26,107,60,.12); transform: translateX(2px);
}
.fgb-flow-opt:active { transform: scale(.98); }
.fgb-flow-opt--selected {
  border-color: var(--fgb-primary); background: #e8f5ee;
  color: var(--fgb-primary); font-weight: 600;
}
.fgb-flow-opt:disabled { cursor: default; }
.fgb-flow-arrow { color: var(--fgb-primary); font-size: 16px; font-weight: 700; margin-left: 6px; }

/* ── Footer ──────────────────────────────────────────────────────────────────── */
#fgb-footer {
  text-align: center; font-size: 10.5px; color: #b0c4ba; padding: 5px;
  background: var(--fgb-bg); flex-shrink: 0; letter-spacing: .02em;
}

/* ── Related posts ───────────────────────────────────────────────────────────── */
.fgb-posts-block { display: flex; flex-direction: column; gap: 6px; width: 100%; }

/* Toggle button */
.fgb-posts-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  background: white;
  border: 1.5px solid var(--fgb-primary);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--fgb-font);
  color: var(--fgb-primary);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  align-self: flex-start;
}
.fgb-posts-toggle:hover  { background: #f0faf4; box-shadow: 0 2px 8px rgba(26,107,60,.15); }
.fgb-posts-toggle:active { transform: scale(0.97); }
.fgb-posts-toggle svg    { flex-shrink: 0; }
.fgb-posts-chevron       { transition: transform 0.2s ease; margin-left: 2px; }

/* Hidden / visible post list */
.fgb-posts-list { display: flex; flex-direction: column; gap: 6px; }
.fgb-posts-list--hidden { display: none; }

.fgb-post-card {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  background: white; border: 1.5px solid var(--fgb-border); border-radius: 10px;
  text-decoration: none !important; color: var(--fgb-text);
  transition: border-color .15s, box-shadow .15s, transform .1s; min-width: 0;
  animation: fgb-msg-in 0.2s ease;
}
.fgb-post-card:hover { border-color: var(--fgb-primary); box-shadow: 0 2px 10px rgba(26,107,60,.12); transform: translateY(-1px); }
.fgb-post-card:active { transform: scale(.99); }
.fgb-post-thumb { width: 44px; height: 44px; border-radius: 7px; object-fit: cover; flex-shrink: 0; }
.fgb-post-thumb--placeholder {
  width: 44px; height: 44px; border-radius: 7px; background: var(--fgb-surface);
  border: 1px solid var(--fgb-border); display: flex; align-items: center; justify-content: center;
  color: #c8d8ce; flex-shrink: 0;
}
.fgb-post-info    { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.fgb-post-title   { font-size: 12.5px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fgb-post-excerpt { font-size: 11.5px; color: var(--fgb-text-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.fgb-post-arrow   { color: var(--fgb-primary); flex-shrink: 0; opacity: .5; transition: opacity .15s, transform .15s; }
.fgb-post-card:hover .fgb-post-arrow { opacity: 1; transform: translateX(2px); }

/* ── Restored history label ──────────────────────────────────────────────────── */
.fgb-restored-label { display: block; font-size: 10px; color: #b0c4ba; margin-top: 4px; font-style: italic; }

/* ── Tablet ───────────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :root { --fgb-w: 340px; --fgb-h: 500px; }
  #fgb-root { bottom: 16px; right: 16px; }
  #fgb-window { right: 0; bottom: 68px; width: calc(100vw - 32px); max-width: 100%; }
}

/* ── Mobile full-screen ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #fgb-root { bottom: 0; right: 0; left: 0; }
  #fgb-bubble { position: fixed; bottom: 18px; right: 18px; width: 54px; height: 54px; }
  #fgb-window {
    position: fixed; bottom: 0; left: 0; right: 0; top: 0;
    width: 100%; max-width: 100%; height: 100%; max-height: 100%;
    border-radius: 0; transform-origin: bottom center;
    transform: translateY(100%);
    transition: transform .35s cubic-bezier(.22,1,.36,1), opacity .25s ease;
  }
  #fgb-window.fgb-window--open { transform: translateY(0); opacity: 1; }
  #fgb-header { padding: max(16px, env(safe-area-inset-top)) 16px 16px; }
  #fgb-input  { font-size: 16px; padding: 12px 16px; min-height: 48px; }
  #fgb-input-area { padding: 8px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #fgb-footer { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  #fgb-send        { width: 46px; height: 46px; }
  #fgb-voice-in,
  #fgb-voice-out   { width: 40px; height: 40px; font-size: 17px; }
  .fgb-bubble { font-size: 14px; padding: 11px 14px; }
  .fgb-suggestion-btn:hover { transform: none; }
  .fgb-category-grid { grid-template-columns: repeat(3,1fr); gap: 6px; }
  .fgb-cat-chip { padding: 9px 4px; font-size: 11px; }
}
@media (max-width: 360px) {
  #fgb-bubble { width: 50px; height: 50px; bottom: 14px; right: 14px; }
  .fgb-category-grid { grid-template-columns: repeat(2,1fr); }
}

/* ── Language toggle button ──────────────────────────────────────────────────── */
.fgb-lang-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  font-family: inherit;
  letter-spacing: 0.02em;
}
.fgb-lang-btn:hover  { background: rgba(255,255,255,0.25); }
.fgb-lang-btn:active { transform: scale(0.95); }

/* ── Exit Satisfaction Survey ────────────────────────────────────────────────── */
#fgb-survey {
  position: absolute;
  bottom: 70px;
  right: 0;
  z-index: calc(var(--fgb-z) + 1);
  width: 280px;
  animation: fgb-survey-in 0.3s cubic-bezier(0.34,1.4,0.64,1);
}

@keyframes fgb-survey-in {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.fgb-survey-card {
  background: white;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(26,107,60,0.18), 0 2px 8px rgba(0,0,0,0.1);
  padding: 18px 16px 16px;
  border: 1px solid var(--fgb-border);
  position: relative;
}

.fgb-survey-close {
  position: absolute;
  top: 10px; right: 10px;
  background: none; border: none;
  cursor: pointer; font-size: 14px;
  color: var(--fgb-text-muted);
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.fgb-survey-close:hover { background: var(--fgb-surface); }

.fgb-survey-q {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fgb-text);
  line-height: 1.4;
  margin-bottom: 14px;
  padding-right: 18px;
}

.fgb-survey-btns {
  display: flex;
  gap: 6px;
}

.fgb-survey-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  border: 1.5px solid var(--fgb-border);
  background: var(--fgb-surface);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  color: var(--fgb-text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: center;
}
.fgb-survey-btn:hover  { background: #f0faf4; border-color: var(--fgb-primary); }
.fgb-survey-btn:active { transform: scale(0.96); }
.fgb-survey-yes:hover  { border-color: #16a34a; color: #16a34a; }
.fgb-survey-no:hover   { border-color: #dc2626; color: #dc2626; }

.fgb-survey-thanks {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--fgb-primary);
  padding: 12px 0;
}

/* Mobile: survey full width */
@media (max-width: 480px) {
  #fgb-survey { width: calc(100vw - 32px); bottom: 80px; right: 16px; }
}

/* ── WhatsApp Escalation Card ────────────────────────────────────────────────── */
.fgb-wa-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1.5px solid #86efac;
  border-radius: 12px;
  animation: fgb-msg-in 0.3s ease;
}

.fgb-wa-card--no-link {
  background: var(--fgb-surface);
  border-color: var(--fgb-border);
}

.fgb-wa-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #25D366;
  box-shadow: 0 3px 12px rgba(37,211,102,0.35);
  flex-shrink: 0;
  align-self: flex-start;
}

.fgb-wa-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fgb-wa-heading {
  font-size: 13.5px;
  font-weight: 700;
  color: #14532d;
  line-height: 1.4;
}

.fgb-wa-subtext {
  font-size: 12.5px;
  color: #166534;
  line-height: 1.5;
  opacity: 0.85;
}

.fgb-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  background: #25D366;
  color: white !important;
  font-size: 13.5px;
  font-weight: 700;
  font-family: var(--fgb-font);
  text-decoration: none !important;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 14px rgba(37,211,102,0.4);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  letter-spacing: 0.01em;
}

.fgb-wa-btn:hover {
  background: #1db954;
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(37,211,102,0.5);
}

.fgb-wa-btn:active {
  transform: scale(0.97);
}

/* ── Mobile WhatsApp ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .fgb-wa-card  { padding: 12px; gap: 8px; }
  .fgb-wa-btn   { padding: 12px 14px; font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Contact Form — in-chatbot mini form
   ─────────────────────────────────────────────────────────────────────────── */

/* Header button to open the form */
.fgb-cf-header-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  padding: 4px 6px;
  cursor: pointer;
  margin-right: 2px;
  line-height: 1.4;
  white-space: nowrap;
  transition: background 0.15s;
  font-family: var(--fgb-font);
}
.fgb-cf-header-btn:hover { background: rgba(255,255,255,0.30); }

/* Card wrapper — sits inside a bot message bubble */
.fgb-cf-card {
  font-size: 12px;
  line-height: 1.5;
  padding: 0;
}

.fgb-cf-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--fgb-primary, #1a6b3c);
  margin-bottom: 3px;
}

.fgb-cf-desc {
  font-size: 11.5px;
  color: #666;
  margin: 0 0 10px;
  line-height: 1.4;
}

/* Fields wrapper */
.fgb-cf-fields {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}

.fgb-cf-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fgb-cf-label {
  font-size: 11px;
  font-weight: 600;
  color: #444;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.fgb-cf-req {
  color: #d0342c;
  font-size: 11px;
}

.fgb-cf-math-q {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--fgb-primary, #1a6b3c);
  background: rgba(26,107,60,0.08);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 2px;
}

/* Input / textarea */
.fgb-cf-input {
  font-size: 12px;
  font-family: var(--fgb-font);
  padding: 5px 8px;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  background: #fff;
  color: #222;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
}
.fgb-cf-input:focus {
  border-color: var(--fgb-primary, #1a6b3c);
  box-shadow: 0 0 0 2px rgba(26,107,60,0.12);
}

.fgb-cf-textarea {
  resize: vertical;
  min-height: 52px;
  line-height: 1.4;
}

/* Error message */
.fgb-cf-error {
  font-size: 11.5px;
  color: #c0392b;
  background: #fdecea;
  border: 1px solid #f5c6c3;
  border-radius: 5px;
  padding: 5px 8px;
  margin-bottom: 8px;
  line-height: 1.4;
}

/* Submit button */
.fgb-cf-submit {
  width: 100%;
  background: var(--fgb-primary, #1a6b3c);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--fgb-font);
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.15s, transform 0.1s;
}
.fgb-cf-submit:hover:not(:disabled)  { filter: brightness(1.08); }
.fgb-cf-submit:active:not(:disabled) { transform: scale(0.98); }
.fgb-cf-submit:disabled              { opacity: 0.6; cursor: not-allowed; }

/* Success state */
.fgb-cf-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 0 4px;
  text-align: center;
}
.fgb-cf-success-icon { font-size: 26px; }
.fgb-cf-success-msg  { font-size: 12.5px; color: #2d6a2d; font-weight: 600; line-height: 1.4; }

/* Mobile tweaks */
@media (max-width: 480px) {
  .fgb-cf-title        { font-size: 12.5px; }
  .fgb-cf-input        { font-size: 13px; padding: 6px 9px; }
  .fgb-cf-submit       { font-size: 13px; padding: 9px 14px; }
}
