/* Shared design tokens and primitives for the three support surfaces.
 *
 * The widget, the console and the help centre are three different runtimes —
 * one is injected into the product page, the others are pages of their own —
 * so they cannot share a component library. They can share this: the same
 * palette, the same spacing scale, the same radii, the same focus ring, the
 * same idea of what a "wait" colour means. When the violet moves, it moves in
 * one file.
 *
 * ---------------------------------------------------------------------------
 * Direction: "éditorial clair".
 *
 * Near-white ground, graphite text, one violet accent, and a lavender light
 * that never extends past the top of a home screen. Three rules do most of the
 * work, and breaking any of them is what made the old version read like an
 * admin form:
 *
 *   1. Border, fill, radius and shadow each say "separate object". Spend them
 *      by role. A one-pixel rule between two rows is enough; a card around
 *      every row means no row matters more than another.
 *   2. Two surfaces, not five: white, and a grey pulled slightly toward the
 *      violet (#f7f7fb, never #f5f5f5). A third surface has to earn its place.
 *   3. One shadow in the whole interface — the floating panel. Everything else
 *      is separated by alignment and space.
 *
 * Everything is prefixed `sa-` and the primitives are opt-in classes, so
 * dropping this into the product page restyles nothing that is not ours.
 *
 * Contrast: the text tokens are checked against the surfaces they are used on.
 * --sa-ink-2 on --sa-surface is 6.9:1 and --sa-ink-3 is 4.6:1, both above the
 * WCAG 2.2 AA floor of 4.5:1 for body text. --sa-ink-3 is therefore usable for
 * real secondary text, not only for decoration. Visual lightness is never
 * bought with contrast.
 */

:root,
#sa-root {
  /* -- surfaces ---------------------------------------------------------- */
  --sa-canvas: #f4f4f8;          /* page ground: neutral pulled toward violet */
  --sa-surface: #ffffff;
  --sa-surface-2: #fbfbfd;
  --sa-surface-sunken: #f7f7fb;  /* the only secondary surface */
  --sa-tint: #f4f1ff;            /* what the customer said, in the thread */

  /* -- ink --------------------------------------------------------------- */
  --sa-ink: #17181f;             /* graphite, not black */
  --sa-ink-2: #565b6b;
  --sa-ink-3: #868ba0;

  /* -- rules: thin, and rarer than before -------------------------------- */
  --sa-line: #ebebf3;
  --sa-line-strong: #dcdce8;

  /* -- accent: the product's violet, unchanged --------------------------- */
  --sa-accent: #7c3aed;
  --sa-accent-hover: #6423d8;
  --sa-accent-active: #54169f;
  --sa-accent-soft: #f3efff;
  --sa-accent-line: #e2d8fd;
  --sa-on-accent: #ffffff;

  /* -- the lavender light ------------------------------------------------
     Used once per surface, at the top of a home screen, and it stops before
     the first line of content. A wash behind running text is a wash that
     makes running text harder to read. */
  --sa-lav-1: #e9e0ff;
  --sa-lav-2: #f2ecff;
  --sa-lav-3: #faf8ff;

  /* -- semantic: colour plus a word, never colour alone ------------------ */
  --sa-wait: #9a4b06;
  --sa-wait-soft: #fff7ed;
  --sa-wait-line: #fdd9a8;
  --sa-ok: #14712f;
  --sa-ok-soft: #f0fdf4;
  --sa-ok-line: #b6f0c6;
  --sa-bad: #b3261e;
  --sa-bad-soft: #fef3f2;
  --sa-bad-line: #fbcfcb;
  --sa-info: #1c4ed8;
  --sa-info-soft: #eff5ff;
  --sa-info-line: #c3d7fe;

  /* -- radii ------------------------------------------------------------- */
  --sa-r-sm: 8px;
  --sa-r: 11px;
  --sa-r-lg: 16px;
  --sa-r-xl: 22px;
  --sa-r-full: 999px;

  /* -- spacing: one scale, used everywhere ------------------------------- */
  --sa-1: 4px;
  --sa-2: 8px;
  --sa-3: 12px;
  --sa-4: 16px;
  --sa-5: 20px;
  /* How far the launcher sits off the bottom of the window. One value, so
     the panel's height and anything stacked above it stay in step. */
  --sa-launcher-bottom: 88px;
  --sa-6: 24px;
  --sa-8: 32px;
  --sa-10: 40px;

  /* -- elevation --------------------------------------------------------- */
  --sa-shadow-1: 0 1px 2px rgba(21, 22, 28, 0.05);
  --sa-shadow-2: 0 1px 2px rgba(21, 22, 28, 0.05), 0 8px 24px -12px rgba(60, 40, 130, 0.24);
  --sa-shadow-3: 0 1px 2px rgba(23, 24, 31, 0.06), 0 18px 48px -16px rgba(23, 24, 31, 0.22),
    0 40px 90px -40px rgba(60, 40, 130, 0.28);

  /* -- type -------------------------------------------------------------- */
  /* Inter is already loaded by the product page. Manrope is the one face this
     feature adds, and it appears in exactly two places: the wordmark and the
     headlines. A display face used three times is a design; used everywhere it
     is a font choice. */
  --sa-display: Manrope, Inter, "Open Sans", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sa-font: Inter, "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --sa-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sa-fs-xs: 11.5px;
  --sa-fs-sm: 12.5px;
  --sa-fs: 14px;
  --sa-fs-md: 14.5px;
  --sa-fs-lg: 17px;
  --sa-fs-xl: 21px;
  --sa-fs-2xl: 27px;
  --sa-fs-3xl: 33px;
  --sa-lh: 1.6;
  --sa-tracking-tight: -0.02em;
  --sa-tracking-display: -0.038em;

  /* -- motion: short, and honest about being optional -------------------- */
  --sa-fast: 110ms;
  --sa-normal: 190ms;
  --sa-ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  :root,
  #sa-root {
    --sa-fast: 0ms;
    --sa-normal: 0ms;
  }
}

/* -- headings: the display face, used with restraint --------------------- */
.sa-display {
  font-family: var(--sa-display);
  font-weight: 800;
  letter-spacing: var(--sa-tracking-display);
  line-height: 1.06;
  text-wrap: balance;
}

/* -- eyebrow: the one place uppercase is allowed ------------------------- */
.sa-eyebrow {
  font-size: var(--sa-fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sa-ink-3);
}

/* -- section heading inside a panel: a word, not a banner ---------------- */
.sa-sec-h {
  font-size: var(--sa-fs-sm);
  font-weight: 600;
  color: var(--sa-ink);
  letter-spacing: 0.005em;
  margin: 0;
}

/* -- focus: one ring, everywhere, and never removed ---------------------- */
.sa-focusable:focus-visible,
.sa-btn:focus-visible,
.sa-field:focus-visible,
.sa-chip:focus-visible,
.sa-tab:focus-visible,
.sa-row:focus-visible {
  outline: 2px solid var(--sa-accent);
  outline-offset: 2px;
  border-radius: var(--sa-r-sm);
}

/* -- buttons -------------------------------------------------------------
   The default button carries no border. A border on every control is what
   turned this interface into a form; the ones that keep it are the ones whose
   edge means something — a destructive action, a control on a coloured
   ground. */
.sa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sa-2);
  min-height: 36px;
  padding: 0 var(--sa-3);
  border: 1px solid transparent;
  border-radius: var(--sa-r-sm);
  background: var(--sa-surface-sunken);
  color: var(--sa-ink);
  font: inherit;
  font-size: var(--sa-fs-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--sa-fast) var(--sa-ease),
    border-color var(--sa-fast) var(--sa-ease), color var(--sa-fast) var(--sa-ease);
}

.sa-btn:hover:not(:disabled) {
  background: #eeeef6;
}

.sa-btn:active:not(:disabled) {
  background: #e6e6f0;
}

.sa-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sa-btn--primary {
  background: var(--sa-accent);
  border-color: var(--sa-accent);
  color: var(--sa-on-accent);
}

.sa-btn--primary:hover:not(:disabled) {
  background: var(--sa-accent-hover);
  border-color: var(--sa-accent-hover);
}

.sa-btn--primary:active:not(:disabled) {
  background: var(--sa-accent-active);
}

.sa-btn--quiet {
  background: transparent;
  color: var(--sa-ink-2);
  font-weight: 500;
}

.sa-btn--quiet:hover:not(:disabled) {
  background: var(--sa-surface-sunken);
  color: var(--sa-ink);
}

/* The only text button that is violet at rest: reaching a person. It is the
   one action the customer must never have to hunt for. */
.sa-btn--human {
  background: transparent;
  color: var(--sa-accent);
  font-weight: 600;
}

.sa-btn--human:hover:not(:disabled) {
  background: var(--sa-accent-soft);
  color: var(--sa-accent-hover);
}

.sa-btn--outline {
  background: var(--sa-surface);
  border-color: var(--sa-line-strong);
}

.sa-btn--outline:hover:not(:disabled) {
  background: var(--sa-surface-sunken);
  border-color: var(--sa-ink-3);
}

.sa-btn--danger {
  background: transparent;
  color: var(--sa-bad);
  border-color: var(--sa-bad-line);
}

.sa-btn--danger:hover:not(:disabled) {
  background: var(--sa-bad-soft);
  border-color: var(--sa-bad);
}

/* Touch targets: 36px is fine with a mouse, not with a thumb. */
@media (pointer: coarse) {
  .sa-btn {
    min-height: 44px;
    padding: 0 var(--sa-4);
  }
}

/* -- icon button --------------------------------------------------------- */
.sa-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 0;
  border-radius: var(--sa-r-sm);
  background: transparent;
  color: var(--sa-ink-2);
  cursor: pointer;
  transition: background var(--sa-fast) var(--sa-ease), color var(--sa-fast) var(--sa-ease);
}

.sa-icon-btn:hover:not(:disabled) {
  background: rgba(23, 24, 31, 0.05);
  color: var(--sa-ink);
}

.sa-icon-btn:focus-visible {
  outline: 2px solid var(--sa-accent);
  outline-offset: 2px;
}

.sa-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (pointer: coarse) {
  .sa-icon-btn {
    width: 44px;
    height: 44px;
  }
}

/* -- rows: what replaced most of the cards -------------------------------
   A list of things to choose from is a list, separated by rules. On hover the
   row shifts 8px and takes a ground — motion and surface instead of a border. */
.sa-row {
  display: flex;
  align-items: center;
  gap: var(--sa-3);
  width: 100%;
  min-height: 46px;
  padding: var(--sa-3) var(--sa-2) var(--sa-3) 0;
  border: 0;
  border-radius: var(--sa-r);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--sa-fast) var(--sa-ease),
    padding-left var(--sa-fast) var(--sa-ease);
}

.sa-row:hover {
  background: var(--sa-surface-sunken);
  padding-left: var(--sa-2);
}

.sa-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sa-rows > li + li {
  border-top: 1px solid var(--sa-line);
}

.sa-row-ico {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: var(--sa-r-sm);
  background: var(--sa-accent-soft);
  color: var(--sa-accent);
}

.sa-row-txt {
  flex: 1;
  min-width: 0;
  font-size: var(--sa-fs-md);
  font-weight: 500;
  letter-spacing: -0.005em;
}

.sa-row-chev {
  display: grid;
  place-items: center;
  flex: none;
  color: var(--sa-ink-3);
}

@media (pointer: coarse) {
  .sa-row {
    min-height: 44px;
  }
}

/* -- fields -------------------------------------------------------------- */
.sa-field {
  width: 100%;
  min-height: 36px;
  padding: var(--sa-2) var(--sa-3);
  border: 1px solid var(--sa-line-strong);
  border-radius: var(--sa-r-sm);
  background: var(--sa-surface);
  color: var(--sa-ink);
  font: inherit;
  font-size: var(--sa-fs-sm);
}

.sa-field::placeholder {
  color: var(--sa-ink-3);
}

.sa-field:hover {
  border-color: var(--sa-ink-3);
}

.sa-field:focus {
  border-color: var(--sa-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--sa-accent-soft);
}

/* -- badges: colour plus a word, never colour alone ---------------------- */
.sa-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sa-1);
  padding: 2px var(--sa-2);
  border: 1px solid transparent;
  border-radius: var(--sa-r-full);
  font-size: var(--sa-fs-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.sa-badge--wait {
  background: var(--sa-wait-soft);
  border-color: var(--sa-wait-line);
  color: var(--sa-wait);
}

.sa-badge--ok {
  background: var(--sa-ok-soft);
  border-color: var(--sa-ok-line);
  color: var(--sa-ok);
}

.sa-badge--bad {
  background: var(--sa-bad-soft);
  border-color: var(--sa-bad-line);
  color: var(--sa-bad);
}

.sa-badge--bot {
  background: var(--sa-accent-soft);
  border-color: var(--sa-accent-line);
  color: var(--sa-accent-hover);
}

.sa-badge--muted {
  background: var(--sa-surface-sunken);
  border-color: transparent;
  color: var(--sa-ink-2);
}

/* -- chips: quiet, grey at rest, violet when chosen ---------------------- */
.sa-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sa-2);
  min-height: 32px;
  padding: var(--sa-1) var(--sa-3);
  border: 1px solid transparent;
  border-radius: var(--sa-r-sm);
  background: var(--sa-surface-sunken);
  color: var(--sa-ink-2);
  font: inherit;
  font-size: var(--sa-fs-sm);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--sa-fast) var(--sa-ease), color var(--sa-fast) var(--sa-ease);
}

.sa-chip:hover {
  background: var(--sa-accent-soft);
  color: var(--sa-accent-hover);
}

.sa-chip[aria-pressed="true"],
.sa-chip--on {
  background: var(--sa-accent-soft);
  border-color: var(--sa-accent-line);
  color: var(--sa-accent-active);
  font-weight: 600;
}

@media (pointer: coarse) {
  .sa-chip {
    min-height: 44px;
  }
}

/* -- scrollbars: present, but not shouting ------------------------------- */
.sa-scroll {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--sa-line-strong) transparent;
}

.sa-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.sa-scroll::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: var(--sa-r-full);
  background-clip: content-box;
  background-color: var(--sa-line-strong);
}

.sa-scroll::-webkit-scrollbar-thumb:hover {
  background-color: var(--sa-ink-3);
}

/* -- for screen readers only --------------------------------------------- */
.sa-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -- icons: one family, stroked, never carrying meaning alone ------------
   1.7px strokes with round joins — the geometry the product's lucide set
   uses, inlined because this file cannot load a JS icon library. */
.sa-i {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.sa-i--lg {
  width: 19px;
  height: 19px;
}
