/*
 * Syntrize website chatbot (assets/js/chatbot.js).
 * Uses the site's theme variables from styles.css, so it follows the dark and light themes.
 */
.sb {
  --sb-shadow: 0 30px 70px -24px rgba(0, 0, 0, .55), 0 0 0 1px var(--border-strong);
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  /* --sb-lift: height of the language-suggestion toast while it is showing (set by chatbot.js). */
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + var(--sb-lift, 0px));
  z-index: 48;
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  transition: bottom .3s var(--ease);
}
.sb.sb-is-open { z-index: 76; }
.sb *, .sb *::before, .sb *::after { box-sizing: border-box; }
.sb [hidden] { display: none !important; }
.sb button { font: inherit; color: inherit; cursor: pointer; }
.sb svg { width: 20px; height: 20px; display: block; }
.sb :focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* The chat button sits in the bottom-right corner; back-to-top moves up above it. */
body.has-chatbot .to-top { right: 25px; bottom: 92px; }
body.has-chatbot.has-cookie .to-top { bottom: 150px; }
/* The chat steps aside while the cookie banner or the mobile menu is open. */
body.has-cookie .sb, body.nav-open .sb { display: none; }

/* ------------------------------------------------------------- Launcher */
.sb-launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-left: auto;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: linear-gradient(var(--surface-solid), var(--surface-solid)) padding-box, var(--grad) border-box;
  box-shadow: 0 14px 34px -10px rgba(43, 212, 240, .55), 0 2px 8px rgba(0, 0, 0, .25);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.sb-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 18px 40px -10px rgba(43, 212, 240, .75), 0 2px 8px rgba(0, 0, 0, .25); }
.sb-launcher > span { grid-area: 1 / 1; display: grid; place-items: center; transition: transform .3s var(--ease), opacity .2s; }
.sb-launcher-logo { width: 42px; height: 42px; object-fit: contain; }
span.sb-launcher-logo svg { width: 26px; height: 26px; }
.sb-launcher .sb-ic-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.sb-launcher .sb-ic-close svg { width: 24px; height: 24px; }
.sb-is-open .sb-launcher .sb-ic-open { opacity: 0; transform: rotate(90deg) scale(.6); }
.sb-is-open .sb-launcher .sb-ic-close { opacity: 1; transform: none; }
/* "Online" dot */
.sb-launcher::before {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #2ee6a8;
  border: 2.5px solid var(--surface-solid);
  transition: opacity .2s;
}
.sb-is-open .sb-launcher::before { opacity: 0; }
.sb-launcher::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(43, 212, 240, .45);
  animation: sb-pulse 2.6s var(--ease) 1.5s 3;
  pointer-events: none;
}
.sb-is-open .sb-launcher::after { animation: none; }
@keyframes sb-pulse { 0% { box-shadow: 0 0 0 0 rgba(43, 212, 240, .45); } 70%, 100% { box-shadow: 0 0 0 16px rgba(43, 212, 240, 0); } }

/* --------------------------------------------------------------- Teaser */
.sb-teaser {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  width: max-content;
  max-width: min(300px, calc(100vw - 36px));
  padding: 12px 8px 12px 12px;
  border-radius: 18px 18px 6px 18px;
  background: var(--surface-solid);
  box-shadow: var(--sb-shadow);
  animation: sb-rise .45s var(--ease) both;
}
.sb-teaser-text { flex: 1; display: flex; align-items: flex-start; gap: 10px; padding: 0; border: 0; background: none; text-align: left; font-size: 14px; line-height: 1.45; color: var(--text); }
.sb-teaser-logo { flex: none; width: 30px; height: 30px; object-fit: contain; }
.sb-teaser-close { flex: none; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted) !important; }
.sb-teaser-close:hover { background: var(--surface-2); color: var(--text) !important; }
.sb-teaser-close svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- Panel */
.sb-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: flex;
  flex-direction: column;
  width: 390px;
  /* Leaves room for the site header above the panel. */
  height: min(640px, calc(100vh - 190px - var(--sb-lift, 0px)));
  height: min(640px, calc(100dvh - 190px - var(--sb-lift, 0px)));
  min-height: 360px;
  overflow: hidden;
  border-radius: 24px;
  background: var(--surface-solid);
  box-shadow: var(--sb-shadow);
  transform-origin: bottom right;
  animation: sb-open .32s var(--ease) both;
}
@keyframes sb-open { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes sb-rise { from { opacity: 0; transform: translateY(8px); } }

.sb-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  background: var(--grad-soft);
  border-bottom: 1px solid var(--border);
}
.sb-avatar {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface-solid);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.sb-avatar-logo { width: 34px; height: 34px; object-fit: contain; }
span.sb-avatar-logo svg { width: 22px; height: 22px; }
.sb-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sb-title { font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.sb-subtitle { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-subtitle::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: #2ee6a8; box-shadow: 0 0 0 3px rgba(46, 230, 168, .18); }
.sb-icon-btn { flex: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--muted) !important; transition: background .2s, color .2s; }
.sb-icon-btn:hover { background: var(--surface-2); color: var(--text) !important; }
.sb-icon-btn svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------- Conversation */
.sb-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 16px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sb-log:focus { outline: none; }
.sb-msg { display: flex; animation: sb-rise .3s var(--ease) both; }
.sb-user { justify-content: flex-end; }
.sb-bubble { max-width: 86%; padding: 10px 14px; border-radius: 18px; overflow-wrap: anywhere; }
.sb-bot .sb-bubble { border-bottom-left-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.sb-user .sb-bubble { border-bottom-right-radius: 6px; background: var(--grad); color: var(--on-grad); font-weight: 500; white-space: pre-wrap; }
.sb-bubble p { margin: 0; }
.sb-bubble p + p, .sb-bubble p + ul, .sb-bubble ul + p, .sb-bubble ul + ul { margin-top: 8px; }
.sb-bubble ul { margin: 0; padding-left: 18px; list-style: disc; }
.sb-bubble li + li { margin-top: 3px; }
.sb-bubble li::marker { color: var(--accent); }
.sb-bubble strong { font-weight: 600; }
.sb-bubble a { color: var(--accent); font-weight: 500; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.sb-bubble a:hover { text-decoration-thickness: 2px; }

.sb-bubble:has(.sb-rows) { width: 100%; max-width: 100%; }
.sb-rows { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0 2px; padding: 12px 14px; border-radius: 12px; background: var(--input-bg); border: 1px solid var(--border); font-size: 13.5px; }
.sb-rows dt { color: var(--muted); }
.sb-rows dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.sb-typing .sb-bubble { display: flex; gap: 5px; padding: 14px 16px; }
.sb-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: sb-dot 1.1s infinite ease-in-out; }
.sb-typing i:nth-child(2) { animation-delay: .15s; }
.sb-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes sb-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.sb-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 4px; animation: sb-rise .3s var(--ease) both; }
.sb-chip {
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text) !important;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  transition: background .2s, border-color .2s, transform .2s var(--ease);
}
.sb-chip:hover { background: var(--surface-hover); border-color: var(--accent); transform: translateY(-1px); }
.sb-chip-primary { border-color: transparent; background: var(--grad); color: var(--on-grad) !important; }
.sb-chip-primary:hover { background: var(--grad); border-color: transparent; filter: brightness(1.08); }

/* ---------------------------------------------------------------- Input */
.sb-form { display: flex; gap: 8px; padding: 12px 14px 8px; border-top: 1px solid var(--border); }
.sb-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 16px; /* 16px stops iOS from zooming in on focus */
  transition: border-color .2s, box-shadow .2s;
}
.sb-input::placeholder { color: var(--muted); }
.sb-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(106, 160, 255, .2); }
.sb-send { flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 14px; background: var(--grad); color: var(--on-grad) !important; transition: filter .2s, transform .2s var(--ease); }
.sb-send:hover { filter: brightness(1.08); transform: translateY(-1px); }
.sb-foot { padding: 0 14px 10px; font-size: 11.5px; text-align: center; color: var(--muted); }
.sb-foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* --------------------------------------------------------------- Phones */
@media (max-width: 760px) {
  .sb { right: max(14px, env(safe-area-inset-right)); bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--sb-lift, 0px)); }
  .sb-launcher { width: 56px; height: 56px; }
  .sb-launcher-logo { width: 38px; height: 38px; }
  .sb-teaser, .sb-panel { bottom: 70px; }
  body.has-chatbot .to-top { right: 19px; bottom: 82px; }
}
@media (max-width: 480px) {
  .sb-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sb-is-open .sb-launcher, .sb-is-open .sb-teaser { display: none; }
  .sb-bubble { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .sb *, .sb *::before, .sb *::after { animation: none !important; transition: none !important; }
}

@media print { .sb { display: none !important; } }
