/**
 * Ask Influ — the help bubble.
 *
 * Tokens come from the theme when the theme is there (var(--mint) and friends) and fall
 * back to the brand's own values when it is not, so the bubble looks right on a staging
 * copy with no theme as well as on influ.com.lk. --isc is the accent the admin screen sets.
 */

#influ-support {
  --isc: #3EB489;
  --isc-deep: #1F7A5C;
  --isc-tint: #E8F5EF;
  --is-ink: var(--charcoal, #1A1A1A);
  --is-soft: var(--ink-soft, #647069);
  --is-line: var(--line, #DCEAE3);
  --is-paper: var(--paper, #F7FAF9);
  --is-white: #FFFFFF;
  --is-coral: var(--coral, #E8785A);
  --is-display: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
  --is-body: var(--font-body, 'Inter', system-ui, sans-serif);
  --is-mono: var(--font-mono, 'IBM Plex Mono', ui-monospace, monospace);
  --is-shadow: 0 24px 60px -18px rgba(26, 26, 26, .35), 0 2px 10px rgba(26, 26, 26, .06);

  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 99998;
  font-family: var(--is-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--is-ink);
}
#influ-support.is-right { right: 20px; }
#influ-support.is-left  { left: 20px; }
#influ-support *, #influ-support *::before, #influ-support *::after { box-sizing: border-box; }
#influ-support button { font: inherit; cursor: pointer; }
#influ-support :focus-visible { outline: 2px solid var(--isc-deep); outline-offset: 2px; border-radius: 8px; }

/* ---------------------------------------------------------------- launcher */

.ias-launcher {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 20px 0 14px;
  border: 0; border-radius: 999px;
  background: var(--is-ink); color: var(--is-white);
  font-family: var(--is-display); font-weight: 600; font-size: .95rem; letter-spacing: -.01em;
  box-shadow: 0 14px 30px -10px rgba(26, 26, 26, .5);
  transition: transform .22s cubic-bezier(.34, 1.56, .64, 1), box-shadow .22s;
}
.ias-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 36px -10px rgba(26, 26, 26, .55); }
.ias-launcher:active { transform: translateY(0) scale(.98); }
.ias-launcher-label { white-space: nowrap; }

/* The swarm: three dots that drift, the same idea as booking several creators at once. */
.ias-swarm { position: relative; width: 26px; height: 26px; flex: none; }
.ias-swarm i {
  position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--isc);
  animation: ias-drift 3.6s ease-in-out infinite;
}
.ias-swarm i:nth-child(1) { top: 2px;  left: 9px;  }
.ias-swarm i:nth-child(2) { top: 13px; left: 1px;  background: var(--mint-bright, #4FE3AE); animation-delay: -1.2s; }
.ias-swarm i:nth-child(3) { top: 13px; left: 16px; background: var(--isc-deep); animation-delay: -2.4s; }
@keyframes ias-drift {
  0%, 100% { transform: translate(0, 0); }
  33%      { transform: translate(3px, -3px); }
  66%      { transform: translate(-3px, 2px); }
}
#influ-support.is-open .ias-launcher { transform: scale(.92); opacity: 0; pointer-events: none; }

/* The nudge, once per visit. */
.ias-teaser {
  position: absolute; bottom: 64px; width: 268px; padding: 14px 34px 14px 16px;
  background: var(--is-white); border: 1px solid var(--is-line); border-radius: 16px 16px 16px 4px;
  box-shadow: var(--is-shadow); font-size: .88rem; color: var(--is-ink);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .3s, transform .3s;
}
#influ-support.is-right .ias-teaser { right: 0; border-radius: 16px 16px 4px 16px; }
#influ-support.is-left  .ias-teaser { left: 0; }
#influ-support.has-teaser .ias-teaser { opacity: 1; transform: none; pointer-events: auto; }
.ias-teaser-close {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--is-soft); line-height: 1;
}
.ias-teaser-close:hover { background: var(--is-paper); color: var(--is-ink); }

/* ------------------------------------------------------------------- panel */

.ias-panel {
  position: absolute; bottom: 68px; width: 400px; max-width: calc(100vw - 32px);
  height: min(640px, calc(100vh - 140px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--is-white); border: 1px solid var(--is-line); border-radius: 22px;
  box-shadow: var(--is-shadow);
  opacity: 0; transform: translateY(14px) scale(.97); pointer-events: none;
  transition: opacity .24s ease, transform .24s cubic-bezier(.34, 1.3, .64, 1);
}
#influ-support.is-right .ias-panel { right: 0; transform-origin: bottom right; }
#influ-support.is-left  .ias-panel { left: 0;  transform-origin: bottom left; }
#influ-support.is-open .ias-panel { opacity: 1; transform: none; pointer-events: auto; }

.ias-head {
  position: relative; overflow: hidden; flex: none;
  padding: 18px 16px; display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--isc-deep), var(--isc));
  color: var(--is-white);
}
/* A blob behind the header, the same shape language as the site's hero. */
.ias-head::after {
  content: ""; position: absolute; width: 220px; height: 220px; right: -70px; top: -120px;
  background: radial-gradient(circle, var(--mint-bright, #4FE3AE), transparent 70%);
  opacity: .5; pointer-events: none;
}
.ias-head > * { position: relative; z-index: 1; }
.ias-mark {
  width: 40px; height: 40px; flex: none; border-radius: 13px;
  background: rgba(255, 255, 255, .18); display: flex; align-items: center; justify-content: center;
}
.ias-mark .ias-swarm i { background: #fff; }
.ias-mark .ias-swarm i:nth-child(2) { background: var(--mint-bright, #4FE3AE); }
.ias-mark .ias-swarm i:nth-child(3) { background: rgba(255, 255, 255, .7); }
.ias-title { flex: 1; min-width: 0; }
.ias-title strong { display: block; font-family: var(--is-display); font-size: 1.02rem; font-weight: 600; }
.ias-title span { display: flex; align-items: center; gap: 6px; font-size: .76rem; opacity: .9; }
.ias-title span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mint-bright, #4FE3AE); }
.ias-hbtn {
  width: 34px; height: 34px; flex: none; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .16); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: background .18s;
}
.ias-hbtn:hover { background: rgba(255, 255, 255, .3); }
.ias-hbtn svg { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- messages */

.ias-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 8px; background: var(--is-paper); }
.ias-scroll::-webkit-scrollbar { width: 8px; }
.ias-scroll::-webkit-scrollbar-thumb { background: var(--is-line); border-radius: 8px; }
.ias-thread { display: flex; flex-direction: column; gap: 14px; }

.ias-msg { max-width: 92%; animation: ias-rise .26s ease both; }
@keyframes ias-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ias-msg.is-user { align-self: flex-end; }
.ias-msg.is-user .ias-bubble {
  background: var(--is-ink); color: var(--is-white);
  border-radius: 16px 16px 4px 16px; padding: 10px 14px;
}
.ias-msg.is-bot .ias-bubble {
  background: var(--is-white); border: 1px solid var(--is-line);
  border-radius: 16px 16px 16px 4px; padding: 12px 15px;
}
.ias-msg.is-error .ias-bubble { border-color: var(--is-coral); background: #FDF0EC; color: #A2432B; }
.ias-eyebrow {
  display: block; margin: 0 0 6px 2px;
  font-family: var(--is-mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--is-soft);
}
.ias-bubble > *:first-child { margin-top: 0; }
.ias-bubble > *:last-child { margin-bottom: 0; }
.ias-bubble p { margin: 0 0 8px; }
.ias-bubble ul, .ias-bubble ol { margin: 6px 0 10px; padding-left: 20px; }
.ias-bubble li { margin: 3px 0; }
.ias-bubble a { color: var(--isc-deep); text-decoration: underline; text-underline-offset: 2px; }
.ias-msg.is-user a { color: #fff; }
.ias-bubble code {
  font-family: var(--is-mono); font-size: .85em; background: var(--isc-tint);
  color: var(--isc-deep); padding: 1px 5px; border-radius: 6px;
}
.ias-bubble strong { font-weight: 600; }
/* The cursor that follows a streaming answer. */
.ias-bubble.is-streaming > *:last-child::after {
  content: ""; display: inline-block; width: 2px; height: 1em; margin-left: 2px;
  background: var(--isc-deep); vertical-align: -2px; animation: ias-blink 1s steps(2) infinite;
}
@keyframes ias-blink { 50% { opacity: 0; } }

/* Thinking: the swarm gathering. */
.ias-thinking { display: inline-flex; align-items: center; gap: 5px; padding: 2px 0; }
.ias-thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--isc); animation: ias-bounce 1.1s infinite; }
.ias-thinking i:nth-child(2) { animation-delay: .14s; background: var(--isc-deep); }
.ias-thinking i:nth-child(3) { animation-delay: .28s; background: var(--mint-bright, #4FE3AE); }
@keyframes ias-bounce { 0%, 65%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Sources: where the answer came from. */
.ias-sources { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--is-line); }
.ias-sources-label {
  font-family: var(--is-mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--is-soft); display: block; margin-bottom: 6px;
}
.ias-source {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  margin: 0 6px 6px 0; padding: 5px 11px;
  border: 1px solid var(--is-line); border-radius: 999px; background: var(--is-paper);
  font-size: .8rem; color: var(--is-ink); text-decoration: none;
}
.ias-source:hover { border-color: var(--isc); background: var(--isc-tint); color: var(--isc-deep); }
.ias-source span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ias-source svg { width: 12px; height: 12px; flex: none; opacity: .6; }

/* What a person can do with an answer. */
.ias-tools { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.ias-tool {
  border: 0; background: transparent; color: var(--is-soft); padding: 4px 7px; border-radius: 8px;
  font-size: .74rem; display: inline-flex; align-items: center; gap: 5px; transition: background .15s, color .15s;
}
.ias-tool:hover { background: var(--isc-tint); color: var(--isc-deep); }
.ias-tool.is-on { color: var(--isc-deep); background: var(--isc-tint); }
.ias-tool svg { width: 13px; height: 13px; }
.ias-thanks { font-size: .74rem; color: var(--is-soft); margin-left: 4px; }

/* -------------------------------------------------------- the opening screen */

.ias-who { display: flex; flex-direction: column; gap: 10px; }
.ias-who-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 14px; border: 1px solid var(--is-line); border-radius: 16px; background: var(--is-white);
  transition: border-color .16s, transform .16s, box-shadow .16s;
}
.ias-who-btn:hover { border-color: var(--isc); transform: translateY(-1px); box-shadow: 0 10px 20px -14px rgba(26, 26, 26, .6); }
.ias-who-btn b { display: block; font-family: var(--is-display); font-size: .95rem; }
.ias-who-btn small { color: var(--is-soft); font-size: .78rem; }
.ias-who-ic {
  width: 36px; height: 36px; flex: none; border-radius: 11px; background: var(--isc-tint); color: var(--isc-deep);
  display: flex; align-items: center; justify-content: center;
}
.ias-who-ic svg { width: 18px; height: 18px; }

.ias-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ias-chip {
  padding: 8px 13px; border: 1px solid var(--is-line); border-radius: 999px;
  background: var(--is-white); color: var(--is-ink); font-size: .84rem; text-align: left;
  transition: border-color .16s, background .16s, color .16s;
}
.ias-chip:hover { border-color: var(--isc); background: var(--isc-tint); color: var(--isc-deep); }

/* ------------------------------------------------------------------- footer */

.ias-foot { flex: none; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--is-line); background: var(--is-white); }
.ias-actions { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.ias-act {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px;
  border: 1px solid var(--is-line); border-radius: 999px; background: var(--is-white);
  color: var(--is-soft); font-size: .78rem; text-decoration: none; transition: .15s;
}
.ias-act:hover { border-color: var(--isc); color: var(--isc-deep); background: var(--isc-tint); }
.ias-act svg { width: 13px; height: 13px; }
.ias-act.is-human { margin-left: auto; color: var(--isc-deep); border-color: var(--isc); }

.ias-form {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--is-paper); border: 1px solid var(--is-line); border-radius: 18px; padding: 6px 6px 6px 14px;
  transition: border-color .16s, background .16s;
}
.ias-form:focus-within { border-color: var(--isc); background: var(--is-white); }
.ias-input {
  flex: 1; border: 0; outline: 0; background: transparent; resize: none;
  font: inherit; font-size: 15px; color: var(--is-ink); line-height: 1.45; padding: 8px 0; max-height: 120px;
}
.ias-input::placeholder { color: var(--is-soft); }
.ias-send {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: 13px;
  background: var(--is-ink); color: var(--is-white); display: flex; align-items: center; justify-content: center;
  transition: background .16s, transform .16s;
}
.ias-send:hover:not(:disabled) { background: var(--isc-deep); transform: translateY(-1px); }
.ias-send:disabled { opacity: .35; cursor: not-allowed; }
.ias-send svg { width: 17px; height: 17px; }
.ias-send.is-stop { background: var(--is-coral); }
.ias-note { margin: 8px 2px 0; font-size: .7rem; line-height: 1.45; color: var(--is-soft); }

/* The sheet's backdrop, phones only: tap anywhere outside to put it away. */
.ias-scrim {
  position: fixed; inset: 0; background: rgba(26, 26, 26, .38);
  opacity: 0; pointer-events: none; transition: opacity .24s; z-index: -1;
}

/* ------------------------------------------------------- phones: a sheet */

@media (max-width: 560px) {
  #influ-support.is-open .ias-scrim { opacity: 1; pointer-events: auto; }
  .ias-actions { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ias-actions::-webkit-scrollbar { display: none; }
  .ias-act { flex: none; }
  .ias-act.is-human { margin-left: 0; }
  #influ-support { bottom: max(14px, env(safe-area-inset-bottom)); }
  #influ-support.is-right { right: 14px; }
  #influ-support.is-left { left: 14px; }
  .ias-launcher { min-height: 56px; width: 56px; padding: 0; justify-content: center; }
  .ias-launcher-label { display: none; }
  .ias-teaser { width: min(268px, calc(100vw - 40px)); }

  .ias-panel {
    position: fixed; inset: auto 0 0 0; width: 100%; max-width: none;
    height: 88dvh; border-radius: 24px 24px 0 0; border-left: 0; border-right: 0; border-bottom: 0;
    transform: translateY(100%); transition: transform .28s cubic-bezier(.32, .72, 0, 1), opacity .2s;
  }
  #influ-support.is-open .ias-panel { transform: none; }
  /* Something to grab, and a hint that it can be pushed away. */
  .ias-head::before {
    content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .4);
  }
  .ias-head { padding-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  #influ-support *, #influ-support *::before, #influ-support *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important;
  }
}

/* Somebody printing a page does not want a chat bubble on it. */
@media print { #influ-support { display: none !important; } }
