/*
 * FoxChat customer widget (widget.js), served to the three shops. Shared by every
 * site, so everything is scoped to #bt-ai-support and resets the form controls the
 * themes style globally. --bt-ai-accent comes from the theme (bt_ai_support_look)
 * or Settings > AI support.
 */
#bt-ai-support {
  --bt-ai-accent: #1659ac;
  --bt-ai-accent-dark: color-mix(in srgb, var(--bt-ai-accent) 78%, #000);
  --bt-ai-accent-tint: color-mix(in srgb, var(--bt-ai-accent) 8%, #fff);
  --bt-ai-bg: #ffffff;
  --bt-ai-ink: #1b1f2a;
  --bt-ai-muted: #6b7280;
  --bt-ai-line: #e6e8ec;
  --bt-ai-bot: #f1f3f6;
  --bt-ai-spring: cubic-bezier(.2, 1.15, .35, 1);
  --bt-ai-ease: cubic-bezier(.25, .8, .3, 1);
  --bt-ai-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 12px 32px -8px rgba(15, 23, 42, .22);
  /* The themes' own faces (body text Barlow, UI Oxanium; set per element, not on
     <body>, so "inherit" would fall back to the browser's serif). */
  --bt-ai-font: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --bt-ai-font-ui: 'Oxanium', var(--bt-ai-font);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  font-family: var(--bt-ai-font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bt-ai-ink);
  text-align: left;
  letter-spacing: normal;
  text-transform: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  pointer-events: none;
}
#bt-ai-support > * { pointer-events: auto; }
#bt-ai-support[hidden],
#bt-ai-support [hidden] { display: none !important; }
#bt-ai-support *,
#bt-ai-support *::before,
#bt-ai-support *::after { box-sizing: border-box; }

/* Boost pages under 1296px have a fixed price bar along the bottom. */
@media (max-width: 1296px) {
  #bt-ai-support.bt-ai-lift { bottom: 96px; }
}

#bt-ai-support button,
#bt-ai-support input,
#bt-ai-support textarea {
  font: inherit;
  color: inherit;
  margin: 0;
  letter-spacing: normal;
  text-transform: none;
  box-shadow: none;
  min-height: 0;
  width: auto;
}
#bt-ai-support button { cursor: pointer; background: none; border: 0; padding: 0; line-height: 1; }
#bt-ai-support button:disabled { cursor: default; }
#bt-ai-support button:focus-visible,
#bt-ai-support a:focus-visible,
#bt-ai-support textarea:focus-visible { outline: 2px solid var(--bt-ai-accent); outline-offset: 2px; }

/* ------------------------------------------------------------ launcher */

#bt-ai-support .bt-ai-launcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bt-ai-accent);
  background-image: linear-gradient(160deg, color-mix(in srgb, var(--bt-ai-accent) 88%, #fff), var(--bt-ai-accent-dark));
  color: #fff;
  box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--bt-ai-accent) 70%, #000), 0 2px 6px rgba(0, 0, 0, .16);
  transition: transform .25s var(--bt-ai-spring), box-shadow .2s ease;
  animation: bt-ai-launch .5s var(--bt-ai-spring) both;
}
#bt-ai-support .bt-ai-launcher:hover { transform: scale(1.07); }
#bt-ai-support .bt-ai-launcher:active { transform: scale(.94); }
.bt-ai-launcher-icon {
  position: absolute;
  display: flex;
  transition: transform .3s var(--bt-ai-spring), opacity .18s ease;
}
.bt-ai-icon-down { opacity: 0; transform: rotate(-90deg) scale(.6); }
.bt-ai-open .bt-ai-icon-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.bt-ai-open .bt-ai-icon-down { opacity: 1; transform: none; }
.bt-ai-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 11px;
  background: #e5484d;
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 21px;
  text-align: center;
  box-shadow: 0 0 0 2.5px #fff;
}
.bt-ai-badge.bt-ai-bump { animation: bt-ai-bump .45s var(--bt-ai-spring); }

/* --------------------------------------------------------------- popup */

.bt-ai-pop {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: min(340px, calc(100vw - 40px));
  margin-right: 2px;
}
#bt-ai-support.bt-ai-open .bt-ai-pop { display: none; }
.bt-ai-pop-wrap { position: relative; width: 100%; animation: bt-ai-pop-in .45s var(--bt-ai-spring) both; transform-origin: bottom right; }
.bt-ai-pop-out .bt-ai-pop-wrap,
.bt-ai-pop-out .bt-ai-pop-chip { animation: bt-ai-pop-leave .2s ease forwards; }
#bt-ai-support .bt-ai-pop-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 16px 18px 14px 16px;
  background: var(--bt-ai-bg);
  border-radius: 18px;
  box-shadow: var(--bt-ai-shadow);
  text-align: left;
  color: var(--bt-ai-ink);
  line-height: 1.45;
  transition: transform .2s var(--bt-ai-ease), box-shadow .2s ease;
}
#bt-ai-support .bt-ai-pop-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(15, 23, 42, .06), 0 18px 40px -10px rgba(15, 23, 42, .28); }
.bt-ai-pop-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bt-ai-pop-title { font-size: 15px; font-weight: 600; color: var(--bt-ai-ink); }
.bt-ai-pop-text { font-size: 15px; color: #2b3240; }
.bt-ai-pop-meta { margin-top: 4px; font-size: 12.5px; color: var(--bt-ai-muted); }
#bt-ai-support .bt-ai-pop-close {
  position: absolute;
  top: -10px;
  right: -8px;
  z-index: 1;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  color: var(--bt-ai-muted);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .18);
  opacity: 0;
  transform: scale(.8);
  transition: opacity .15s ease, transform .2s var(--bt-ai-spring), color .15s ease;
}
.bt-ai-pop-wrap:hover .bt-ai-pop-close,
#bt-ai-support .bt-ai-pop-close:focus-visible { opacity: 1; transform: none; }
#bt-ai-support .bt-ai-pop-close:hover { color: var(--bt-ai-ink); }
.bt-ai-pop-chips { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#bt-ai-support .bt-ai-pop-chip {
  padding: 10px 18px;
  border: 1.5px solid var(--bt-ai-accent);
  border-radius: 12px;
  background: var(--bt-ai-bg);
  color: var(--bt-ai-accent);
  font-size: 15px;
  line-height: 1.25;
  box-shadow: 0 4px 14px -6px rgba(15, 23, 42, .25);
  animation: bt-ai-pop-in .45s var(--bt-ai-spring) both;
  animation-delay: calc(.12s + var(--i, 0) * .07s);
  transition: background .15s ease, color .15s ease, transform .2s var(--bt-ai-spring);
}
#bt-ai-support .bt-ai-pop-chip:hover { background: var(--bt-ai-accent); color: #fff; transform: translateY(-1px); }

/* --------------------------------------------------------------- panel */

.bt-ai-panel {
  display: flex;
  flex-direction: column;
  width: 384px;
  height: min(640px, calc(100vh - 110px));
  background: var(--bt-ai-bg);
  border-radius: 20px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .06), 0 24px 60px -14px rgba(15, 23, 42, .38);
  overflow: hidden;
  transform-origin: bottom right;
  animation: bt-ai-panel-in .34s var(--bt-ai-spring) both;
}
.bt-ai-closing .bt-ai-panel { animation: bt-ai-panel-out .19s ease forwards; }
.bt-ai-lift .bt-ai-panel { height: min(640px, calc(100vh - 190px)); }

.bt-ai-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 14px 14px;
  background: var(--bt-ai-accent);
  background-image: linear-gradient(135deg, color-mix(in srgb, var(--bt-ai-accent) 90%, #fff), var(--bt-ai-accent-dark));
  color: #fff;
}
.bt-ai-avatar {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  overflow: hidden;
}
.bt-ai-avatar-img { background: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .55); }
.bt-ai-avatar-img img { width: 100%; height: 100%; object-fit: contain; padding: 3px; display: block; }
#bt-ai-support .bt-ai-pop-logo { flex-basis: 40px; width: 40px; height: 40px; background: #fff; box-shadow: none; }
.bt-ai-pop-logo img { padding: 0; }
.bt-ai-names { flex: 1; min-width: 0; margin-left: 2px; }
.bt-ai-title,
#bt-ai-support .bt-ai-chip { font-family: var(--bt-ai-font-ui); }
.bt-ai-title {
  font-weight: 700;
  font-size: 15.5px;
  line-height: 1.25;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bt-ai-sub { display: flex; align-items: center; gap: 6px; font-size: 12.5px; opacity: .92; line-height: 1.3; }
.bt-ai-sub::before { content: ""; flex: 0 0 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); animation: bt-ai-live 2.4s ease-in-out infinite; }
#bt-ai-support .bt-ai-icon-btn {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border-radius: 50%;
  transition: background .15s ease;
}
#bt-ai-support .bt-ai-icon-btn:hover { background: rgba(255, 255, 255, .22); }

.bt-ai-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(var(--bt-ai-accent-tint), var(--bt-ai-bg) 140px);
}
.bt-ai-msg {
  max-width: 84%;
  padding: 9px 14px;
  border-radius: 18px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.bt-ai-msg.bt-ai-enter { animation: bt-ai-msg-in .32s var(--bt-ai-spring) both; }
.bt-ai-user.bt-ai-enter { animation-name: bt-ai-msg-in-right; }
.bt-ai-msg p { margin: 0 0 .5em; }
.bt-ai-msg p:last-child { margin-bottom: 0; }
.bt-ai-msg a { color: inherit; text-decoration: underline; }
.bt-ai-bot { align-self: flex-start; background: var(--bt-ai-bot); border-bottom-left-radius: 6px; }
.bt-ai-bot + .bt-ai-bot { margin-top: -2px; }
.bt-ai-bot a { color: var(--bt-ai-accent-dark); font-weight: 600; }
.bt-ai-user { align-self: flex-end; background: var(--bt-ai-accent); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.bt-ai-user + .bt-ai-user { margin-top: -2px; }
.bt-ai-bot + .bt-ai-user,
.bt-ai-user + .bt-ai-bot { margin-top: 6px; }

.bt-ai-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin: 8px 0 4px; }
#bt-ai-support .bt-ai-chip {
  padding: 8px 13px;
  border: 1.5px solid color-mix(in srgb, var(--bt-ai-accent) 55%, #fff);
  border-radius: 12px;
  background: #fff;
  color: var(--bt-ai-accent-dark);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  animation: bt-ai-msg-in .35s var(--bt-ai-spring) both;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .2s var(--bt-ai-spring);
}
#bt-ai-support .bt-ai-chip:hover { background: var(--bt-ai-accent); border-color: var(--bt-ai-accent); color: #fff; transform: translateY(-1px); }

.bt-ai-rate { display: flex; align-items: center; gap: 4px; margin: 2px 0 0 4px; font-size: 12px; color: var(--bt-ai-muted); animation: bt-ai-fade .3s ease both; }
#bt-ai-support .bt-ai-rate button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--bt-ai-muted);
  transition: background .15s ease, color .15s ease;
}
#bt-ai-support .bt-ai-rate button:hover { background: var(--bt-ai-bot); color: var(--bt-ai-ink); }
#bt-ai-support .bt-ai-rate-down svg { transform: rotate(180deg); }

.bt-ai-typing { display: flex; align-items: center; gap: 4px; padding: 13px 15px; }
.bt-ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa1ad;
  animation: bt-ai-dot 1.25s infinite ease-in-out;
}
.bt-ai-typing span:nth-child(2) { animation-delay: .16s; }
.bt-ai-typing span:nth-child(3) { animation-delay: .32s; }

.bt-ai-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px 12px;
  border-top: 1px solid var(--bt-ai-line);
  background: var(--bt-ai-bg);
}
#bt-ai-support .bt-ai-input {
  flex: 1;
  resize: none;
  max-height: 120px;
  overflow-y: hidden;
  padding: 10px 14px;
  border: 1.5px solid var(--bt-ai-line);
  border-radius: 22px;
  background: #f8f9fb;
  color: var(--bt-ai-ink);
  line-height: 1.4;
  outline: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
#bt-ai-support .bt-ai-input:focus { border-color: var(--bt-ai-accent); background: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--bt-ai-accent) 15%, transparent); }
#bt-ai-support .bt-ai-send {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bt-ai-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s var(--bt-ai-spring), background .15s ease, opacity .15s ease;
}
#bt-ai-support .bt-ai-send:hover:not(:disabled) { background: var(--bt-ai-accent-dark); transform: scale(1.06); }
#bt-ai-support .bt-ai-send:active:not(:disabled) { transform: scale(.92); }
#bt-ai-support .bt-ai-send:disabled { opacity: .45; }

/* -------------------------------------------------------------- phones */

@media (max-width: 600px) {
  #bt-ai-support { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); gap: 12px; }
  #bt-ai-support.bt-ai-lift:not(.bt-ai-open):not(.bt-ai-closing) { bottom: calc(86px + env(safe-area-inset-bottom)); }
  #bt-ai-support .bt-ai-launcher { width: 56px; height: 56px; }
  .bt-ai-pop { max-width: calc(100vw - 32px); }
  #bt-ai-support .bt-ai-pop-card { padding: 14px 16px 12px 14px; }
  .bt-ai-pop-title, .bt-ai-pop-text { font-size: 14.5px; }
  #bt-ai-support .bt-ai-pop-close { opacity: 1; transform: none; }
  #bt-ai-support .bt-ai-pop-chip { padding: 9px 15px; font-size: 14.5px; }

  /* Open: the chat is the whole visible screen (above the keyboard too). */
  #bt-ai-support.bt-ai-open,
  #bt-ai-support.bt-ai-closing {
    inset: auto 0 auto 0;
    top: var(--bt-ai-vt, 0);
    right: 0;
    bottom: auto;
    height: var(--bt-ai-vh, 100dvh);
  }
  #bt-ai-support.bt-ai-open .bt-ai-launcher,
  #bt-ai-support.bt-ai-closing .bt-ai-launcher { display: none; }
  .bt-ai-open .bt-ai-panel,
  .bt-ai-closing .bt-ai-panel,
  .bt-ai-lift.bt-ai-open .bt-ai-panel {
    width: 100vw;
    height: 100%;
    border-radius: 0;
    transform-origin: bottom center;
    animation-name: bt-ai-sheet-in;
  }
  .bt-ai-closing .bt-ai-panel { animation: bt-ai-sheet-out .19s ease forwards; }
  .bt-ai-head { padding: calc(10px + env(safe-area-inset-top)) 8px 10px 12px; }
  .bt-ai-form { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  /* 16px stops iOS zooming into the field. */
  #bt-ai-support .bt-ai-input { font-size: 16px; }
  .bt-ai-msg { max-width: 88%; }
}
html.bt-ai-locked,
html.bt-ai-locked body { overflow: hidden !important; overscroll-behavior: none; }

/* ----------------------------------------------------------- keyframes */

@keyframes bt-ai-launch { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }
@keyframes bt-ai-bump { 0% { transform: scale(.3); } 60% { transform: scale(1.18); } 100% { transform: none; } }
@keyframes bt-ai-pop-in { from { opacity: 0; transform: translateY(14px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes bt-ai-pop-leave { to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes bt-ai-panel-in { from { opacity: 0; transform: translateY(18px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes bt-ai-panel-out { to { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes bt-ai-sheet-in { from { opacity: .4; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes bt-ai-sheet-out { to { opacity: 0; transform: translateY(40px); } }
@keyframes bt-ai-msg-in { from { opacity: 0; transform: translate(-6px, 8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes bt-ai-msg-in-right { from { opacity: 0; transform: translate(6px, 8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes bt-ai-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bt-ai-dot { 0%, 70%, 100% { transform: translateY(0); opacity: .45; } 35% { transform: translateY(-4px); opacity: 1; } }
@keyframes bt-ai-live { 0%, 100% { box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); } 50% { box-shadow: 0 0 0 4px rgba(74, 222, 128, .25); } }

@media (prefers-reduced-motion: reduce) {
  #bt-ai-support *,
  #bt-ai-support *::before { animation: none !important; transition: none !important; }
}
