/* ============================================================
   Figment Assistant — floating help widget
   Namespaced .fga-* to avoid collisions with app styles.
   ============================================================ */
.fga-root {
  --fga-bg: linear-gradient(160deg, #1e1e2e 0%, #2d2d44 100%);
  --fga-accent: #7c5cff;
  --fga-accent-2: #22d3ee;
  --fga-ink: #f4f4fb;
  --fga-muted: rgba(244,244,251,.55);
  --fga-line: rgba(255,255,255,.10);
  --fga-user: linear-gradient(135deg, #7c5cff 0%, #9d7bff 100%);
  --fga-bot: rgba(255,255,255,.06);
  position: fixed; z-index: 2147483000;
  right: 22px; bottom: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Launcher ---------- */
.fga-launcher {
  position: relative; display: flex; align-items: center; gap: 10px;
  border: none; cursor: pointer; padding: 8px 16px 8px 8px;
  border-radius: 999px; background: var(--fga-bg);
  box-shadow: 0 10px 30px rgba(17,12,46,.45), 0 0 0 1px var(--fga-line) inset;
  color: var(--fga-ink); transition: transform .18s ease, box-shadow .18s ease;
}
.fga-launcher:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(17,12,46,.55), 0 0 0 1px rgba(124,92,255,.5) inset; }
.fga-launcher:active { transform: translateY(0); }
.fga-launcher-avatar {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
  background: #0e0e18; box-shadow: 0 0 0 2px rgba(124,92,255,.6);
}
.fga-launcher-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.fga-launcher-text b { font-size: .86rem; font-weight: 700; }
.fga-launcher-text span { font-size: .68rem; color: var(--fga-muted); }
/* pulsing ring to draw the eye (tech-forward) */
.fga-launcher::before {
  content: ""; position: absolute; left: 8px; top: 8px; width: 42px; height: 42px;
  border-radius: 50%; box-shadow: 0 0 0 0 rgba(124,92,255,.55);
  animation: fga-pulse 2.6s infinite; pointer-events: none;
}
@keyframes fga-pulse { 0%{box-shadow:0 0 0 0 rgba(124,92,255,.5)} 70%{box-shadow:0 0 0 14px rgba(124,92,255,0)} 100%{box-shadow:0 0 0 0 rgba(124,92,255,0)} }
.fga-root.fga-open .fga-launcher { display: none; }

/* ---------- Panel ---------- */
.fga-panel {
  position: absolute; right: 0; bottom: 0;
  width: min(384px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 40px));
  display: none; flex-direction: column; overflow: hidden;
  border-radius: 20px; background: rgba(20,20,32,.86);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 24px 70px rgba(8,6,25,.6), 0 0 0 1px var(--fga-line);
  color: var(--fga-ink);
  transform: translateY(14px) scale(.98); opacity: 0;
  transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .22s ease;
}
.fga-root.fga-open .fga-panel { display: flex; transform: translateY(0) scale(1); opacity: 1; }

/* Header with animated aurora */
.fga-head { position: relative; padding: 15px 14px; overflow: hidden; background: var(--fga-bg); border-bottom: 1px solid var(--fga-line); }
.fga-head::after {
  content: ""; position: absolute; inset: -40% -10% auto -10%; height: 160%;
  background: radial-gradient(60% 60% at 20% 20%, rgba(124,92,255,.55), transparent 60%),
              radial-gradient(50% 50% at 85% 30%, rgba(34,211,238,.35), transparent 60%);
  filter: blur(6px); animation: fga-drift 9s ease-in-out infinite alternate; pointer-events: none;
}
@keyframes fga-drift { from{transform:translate3d(-6%,-4%,0)} to{transform:translate3d(6%,4%,0)} }
.fga-head-row { position: relative; display: flex; align-items: center; gap: 11px; }
.fga-head-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background:#0e0e18; box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.fga-head-id { flex: 1; min-width: 0; }
.fga-head-id b { display:block; font-size: .98rem; font-weight: 700; }
.fga-head-id .fga-status { display:flex; align-items:center; gap:6px; font-size:.72rem; color: rgba(255,255,255,.75); }
.fga-dot { width:7px; height:7px; border-radius:50%; background:#34d399; box-shadow:0 0 8px #34d399; }
.fga-icon-btn { background: rgba(255,255,255,.10); border: none; color: var(--fga-ink); width: 30px; height: 30px; border-radius: 9px; cursor: pointer; font-size: 15px; line-height: 1; transition: background .15s; }
.fga-icon-btn:hover { background: rgba(255,255,255,.22); }

/* Always-visible human handoff strip */
.fga-human-bar { position: relative; display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding: 8px 12px; background: rgba(124,92,255,.12); border-bottom: 1px solid var(--fga-line); font-size: .76rem; color: rgba(255,255,255,.8); }
.fga-human-btn { border:1px solid rgba(124,92,255,.55); background: rgba(124,92,255,.2); color:#fff; padding:5px 11px; border-radius:999px; font-size:.75rem; font-weight:600; cursor:pointer; white-space:nowrap; transition: background .15s, transform .15s; }
.fga-human-btn:hover { background: rgba(124,92,255,.38); transform: translateY(-1px); }

/* Messages */
.fga-body { flex: 1; overflow-y: auto; padding: 16px 14px 6px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.fga-body::-webkit-scrollbar { width: 8px; } .fga-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }
.fga-msg { display: flex; gap: 9px; max-width: 100%; animation: fga-rise .25s ease both; }
@keyframes fga-rise { from{opacity:0; transform: translateY(8px)} to{opacity:1; transform:none} }
.fga-msg-av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: 0 0 26px; margin-top: 2px; background:#0e0e18; }
.fga-bubble { padding: 10px 13px; border-radius: 14px; font-size: .86rem; line-height: 1.5; min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.fga-bubble a { overflow-wrap: anywhere; word-break: break-all; }
.fga-bubble code { overflow-wrap: anywhere; word-break: break-all; }
.fga-msg.bot .fga-bubble { background: var(--fga-bot); border: 1px solid var(--fga-line); border-top-left-radius: 5px; color: var(--fga-ink); }
.fga-msg.user { flex-direction: row-reverse; }
.fga-msg.user .fga-bubble { background: var(--fga-user); color: #fff; border-top-right-radius: 5px; }
.fga-bubble p { margin: 0 0 .5em; } .fga-bubble p:last-child { margin-bottom: 0; }
.fga-bubble ol, .fga-bubble ul { margin: .3em 0 .3em; padding-left: 1.25em; } .fga-bubble li { margin: .18em 0; }
.fga-bubble code { background: rgba(255,255,255,.12); padding: 1px 5px; border-radius: 5px; font-size: .82em; }
.fga-bubble a { color: var(--fga-accent-2); }
.fga-bubble strong { color: #fff; }

/* Quick replies */
.fga-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 2px 2px 8px; }
.fga-chip { background: rgba(255,255,255,.06); border: 1px solid var(--fga-line); color: var(--fga-ink); font-size: .77rem; padding: 7px 11px; border-radius: 999px; cursor: pointer; transition: background .15s, border-color .15s; text-align: left; }
.fga-chip:hover { background: rgba(124,92,255,.22); border-color: rgba(124,92,255,.5); }

/* Typing indicator */
.fga-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.fga-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--fga-muted); animation: fga-bounce 1.2s infinite; }
.fga-typing i:nth-child(2){ animation-delay:.15s } .fga-typing i:nth-child(3){ animation-delay:.3s }
@keyframes fga-bounce { 0%,60%,100%{transform:translateY(0);opacity:.5} 30%{transform:translateY(-4px);opacity:1} }

/* Footer input */
.fga-foot { padding: 10px 12px 12px; border-top: 1px solid var(--fga-line); background: rgba(255,255,255,.02); }
.fga-input-row { display: flex; align-items: flex-end; gap: 8px; background: rgba(255,255,255,.06); border: 1px solid var(--fga-line); border-radius: 14px; padding: 6px 6px 6px 12px; transition: border-color .15s; }
.fga-input-row:focus-within { border-color: rgba(124,92,255,.6); }
.fga-input { flex: 1; background: transparent; border: none; outline: none; color: var(--fga-ink); font-size: .86rem; resize: none; max-height: 120px; line-height: 1.4; font-family: inherit; padding: 4px 0; }
.fga-input::placeholder { color: var(--fga-muted); }
.fga-send { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; border: none; cursor: pointer; background: var(--fga-user); color: #fff; font-size: 16px; display: grid; place-items: center; transition: transform .15s, opacity .15s; }
.fga-send:hover { transform: translateY(-1px); } .fga-send:disabled { opacity: .4; cursor: default; transform: none; }
.fga-legal { text-align: center; font-size: .64rem; color: var(--fga-muted); margin: 7px 2px 0; }

/* Human-handoff form */
.fga-form { display: flex; flex-direction: column; gap: 9px; }
.fga-form label { font-size: .76rem; font-weight: 600; color: rgba(244,244,251,.82); margin-bottom: -4px; }
.fga-field { background: rgba(255,255,255,.06); border: 1px solid var(--fga-line); border-radius: 11px; padding: 9px 11px; color: var(--fga-ink); font-size: .84rem; outline: none; font-family: inherit; }
.fga-field:focus { border-color: rgba(124,92,255,.6); }
textarea.fga-field { resize: vertical; min-height: 84px; }
.fga-form-actions { display: flex; gap: 8px; }
.fga-btn { flex: 1; border: none; border-radius: 11px; padding: 10px; font-size: .84rem; font-weight: 600; cursor: pointer; transition: transform .15s, opacity .15s; }
.fga-btn-primary { background: var(--fga-user); color: #fff; } .fga-btn-primary:hover { transform: translateY(-1px); }
.fga-btn-ghost { background: rgba(255,255,255,.08); color: var(--fga-ink); }
.fga-note { font-size: .8rem; color: var(--fga-muted); line-height: 1.5; }
.fga-ok { background: rgba(52,211,153,.14); border: 1px solid rgba(52,211,153,.4); color: #d1fae5; padding: 12px; border-radius: 12px; font-size: .84rem; line-height: 1.5; }

@media (max-width: 480px) {
  .fga-root { right: 12px; bottom: 12px; }
  .fga-launcher-text { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fga-launcher::before, .fga-head::after, .fga-typing i, .fga-msg { animation: none !important; }
}
