/*
 * Search bar, dimming layer and answer panel.
 * .sa-frame: demo page (stage = the box around the site iframe, dock below it).
 * .sa-page:  real store page (everything fixed to the viewport, inside a Shadow DOM).
 *
 * --sa-width is the width of the site's content column (measured by assistant.js), so the search bar
 * and the answer panel line up with the page content instead of spanning the whole window.
 */
.sa-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ dim layer */
.sa-scrim { position: absolute; inset: 0; z-index: 5; background: rgba(17, 30, 34, 0.42); opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease; -webkit-backdrop-filter: blur(1.5px); backdrop-filter: blur(1.5px); }
.is-typing .sa-scrim { opacity: 0.55; pointer-events: auto; }
.is-open .sa-scrim { opacity: 1; pointer-events: auto; }

/* ------------------------------------------------------------------ answer panel */
.sa-panel {
  position: absolute; z-index: 6; left: 50%; top: 20px; bottom: 12px;
  width: var(--sa-width, min(1160px, calc(100% - 32px)));
  transform: translateX(-50%);
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; color: var(--text); font-family: var(--font-body);
  border-radius: 16px;
  box-shadow: 0 0 0 1px rgba(17, 30, 34, 0.06), 0 2px 6px rgba(17, 30, 34, 0.06), 0 28px 64px -16px rgba(17, 30, 34, 0.38);
  animation: sa-rise 0.2s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes sa-rise { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.sa-panel-head { flex: none; display: flex; align-items: center; gap: 6px; padding: 12px 14px 12px 20px;
  border-bottom: 1px solid #edf1f0; }
.sa-spacer { flex: 1; }
.sa-back, .sa-new { border: 0; background: transparent; color: var(--muted); font: 600 13.5px/1 var(--font-heading);
  padding: 9px 12px; border-radius: 8px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.sa-back:hover, .sa-new:hover { background: var(--primary-soft); color: var(--primary); }
.sa-close { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent;
  color: var(--muted); border-radius: 50%; cursor: pointer; transition: background 0.15s, color 0.15s; }
.sa-close:hover { background: #eef2f1; color: var(--text); }

.sa-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth;
  padding: 8px 32px 24px; }
/* Readable line length inside a wide panel */
.sa-scroll > .thread { max-width: 820px; margin: 0 auto; }
.sa-scroll .sa-turn { padding: 26px 0 28px; }
.sa-scroll .sa-turn:first-child { padding-top: 20px; }
.sa-scroll .msg-user { font-size: 21px; letter-spacing: -0.01em; margin-bottom: 6px; }
.sa-scroll .trace { margin-bottom: 2px; }

/* ------------------------------------------------------------------ search bar */
.sa-dock { padding: 14px 16px max(16px, env(safe-area-inset-bottom)); background: transparent; }
.sa-form {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  width: var(--sa-width, min(1160px, calc(100% - 32px))); max-width: 100%; margin: 0 auto;
  background: #fff; border: 1px solid #d8e2e0; border-radius: 16px; padding: 7px 7px 7px 52px;
  box-shadow: 0 1px 2px rgba(17, 30, 34, 0.05), 0 10px 30px -12px rgba(17, 30, 34, 0.28);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sa-form:focus-within { border-color: #9bb4b0;
  box-shadow: 0 0 0 4px rgba(57, 91, 100, 0.12), 0 10px 30px -12px rgba(17, 30, 34, 0.28); }
/* "Powered by Saariv": one quiet line under the bar, never competing with it */
.sa-powered { display: block; width: fit-content; margin: 7px auto 0; padding: 2px 6px; border-radius: 6px;
  font: 500 11px/1.3 var(--font-body, system-ui, -apple-system, "Segoe UI", sans-serif); letter-spacing: 0.01em;
  color: #9ca3af; text-decoration: none; -webkit-tap-highlight-color: transparent; transition: color 0.15s ease; }
.sa-powered-name { font-weight: 700; color: #6b7280; transition: color 0.15s ease; }
.sa-powered:hover, .sa-powered:hover .sa-powered-name { color: var(--primary, #18181b); }
.sa-powered:focus-visible { outline: 2px solid var(--primary, #18181b); outline-offset: 2px; }
.sa-icon { position: absolute; left: 19px; top: 50%; transform: translateY(-50%); color: var(--primary); display: flex; opacity: 0.8; }
.sa-input { flex: 1 1 0; min-width: 0; resize: none; border: 0; outline: 0; background: transparent; color: var(--text);
  font: 400 16.5px/1.45 var(--font-body); padding: 11px 0; min-height: 24px; max-height: 140px; }
.sa-input::placeholder { color: #8b979f; }
.sa-send, .sa-stop { flex: none; align-self: stretch; min-height: 44px; border: 0; border-radius: 11px; padding: 0 22px;
  cursor: pointer; font: 600 15px/1 var(--font-heading); background: var(--primary); color: #f3faf8;
  transition: background 0.15s, opacity 0.15s; }
.sa-send:hover:not(:disabled) { background: var(--primary-hover); }
.sa-send:disabled { opacity: 0.35; cursor: default; }
.sa-stop { background: var(--text); color: #fff; }
.sa-form > [hidden] { display: none !important; }

/* ------------------------------------------------------------------ voice: the mic, listening, the words arriving */
/* the mic and + are plain icons inside the bar (like ChatGPT), not boxes of their own */
.sa-mic, .sa-attach { position: relative; flex: none; align-self: center; width: 40px; height: 40px; min-height: 0;
  padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--muted, #6b7280);
  transition: background 0.15s, color 0.15s, opacity 0.15s; -webkit-tap-highlight-color: transparent; }
.sa-mic:hover, .sa-attach:hover { background: rgba(15, 23, 42, 0.06); color: var(--text, #111); }
.sa-mic .sa-mic-i, .sa-mic .sa-mic-stop { display: grid; place-items: center; }
.sa-mic .sa-mic-stop { display: none; }
.sa-form.is-listening .sa-mic { background: #dc2626; color: #fff; }
.sa-form.is-listening .sa-mic .sa-mic-i { display: none; }
.sa-form.is-listening .sa-mic .sa-mic-stop { display: grid; }
/* a ring that grows with the voice */
.sa-form.is-listening .sa-mic::after { content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid #dc2626; opacity: 0.5; pointer-events: none;
  transform: scale(calc(1 + var(--sa-level, 0) * 0.22)); transition: transform 0.1s linear; }
.sa-form.is-transcribing .sa-mic { opacity: 0.55; pointer-events: none; }
.sa-form.is-transcribing .sa-input { color: var(--muted); }
/* a transcript is in the bar: send is what to tap next (nothing goes out until it is tapped) */
.sa-form.is-voice-ready .sa-send:not(:disabled) { animation: sa-ready 1.4s ease-out 2;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); }
@keyframes sa-ready { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); }
  100% { box-shadow: 0 0 0 9px transparent; } }
.sa-voice-note { width: var(--sa-width, min(1160px, calc(100% - 32px))); max-width: 100%; margin: 7px auto 0;
  text-align: center; font: 500 13px/1.35 var(--font-body); color: var(--muted); }
.sa-voice-note[hidden] { display: none; }
.sa-note-btn { display: inline-block; margin: 6px 4px 0; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--primary); background: #fff; color: var(--primary); font: 600 13px/1.2 var(--font-body);
  text-decoration: none; cursor: pointer; }
.sa-note-btn:first-of-type { margin-left: 8px; }
.sa-note-btn:hover { background: var(--primary); color: var(--on-primary, #fff); }
/* the keyboard's own mic is doing the listening: the bar says so */
.sa-form.is-dictating { border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }

/* ------------------------------------------------------------------ photos and files in the bar */
.sa-form.has-attach { padding-left: 7px; }
.sa-form.has-attach .sa-icon { display: none; }
.sa-form.has-attach .sa-input { padding-left: 2px; }
.sa-files { order: -1; flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 2px 0; }
.sa-form > .sa-files[hidden] { display: none !important; }
.sa-file { display: inline-flex; align-items: center; gap: 6px; max-width: min(260px, 100%); padding: 6px 6px 6px 9px;
  border: 1px solid rgba(15, 23, 42, 0.12); border-radius: 10px; background: #f6f7f8; color: var(--text, #111);
  font: 500 13px/1.2 var(--font-body); }
.sa-file-i { display: grid; flex: none; color: var(--muted, #6b7280); }
.sa-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-file.is-reading .sa-file-name::after { content: " \00b7 reading\2026"; color: var(--muted, #6b7280); }
.sa-file.is-reading { opacity: 0.75; }
.sa-file-x { flex: none; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0;
  border-radius: 50%; background: transparent; color: var(--muted, #6b7280); cursor: pointer; }
.sa-file-x svg { width: 14px; height: 14px; }
.sa-file-x:hover { background: rgba(15, 23, 42, 0.08); color: var(--text, #111); }
.sa-turn-files { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 12px; }
.sa-turn-files .sa-file { padding-right: 10px; }
.sa-form.is-drop { border-style: dashed; border-color: var(--primary); }

/* ------------------------------------------------------------------ welcome: before the first question */
/* a row of things to try just above the bar: no card, no big mic (the mic is in the bar) */
.sa-welcome { position: absolute; z-index: 6; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: min(720px, calc(100% - 24px)); box-sizing: border-box; padding: 0; background: transparent;
  color: var(--text); text-align: center; font-family: var(--font-body);
  animation: sa-rise 0.22s cubic-bezier(0.2, 0.7, 0.2, 1); }
.sa-welcome[hidden] { display: none; }
.sa-welcome-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.sa-welcome-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid rgba(15, 23, 42, 0.14); background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06); color: var(--text); border-radius: 999px;
  padding: 9px 15px; font: 500 14px/1.2 var(--font-body); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.sa-welcome-chip:hover { border-color: var(--primary); background: #fff; }
.sa-mic:focus-visible, .sa-attach:focus-visible, .sa-welcome-chip:focus-visible, .sa-file-x:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; }
.sa-back:focus-visible, .sa-new:focus-visible, .sa-close:focus-visible, .sa-send:focus-visible, .sa-stop:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; }

/* ------------------------------------------------------------------ page mode (store) */
.sa-page { position: fixed; inset: 0; z-index: 2147483000; pointer-events: none; }
.sa-page .sa-stage { position: absolute; left: 0; right: 0; top: 0; bottom: calc(var(--sa-dock-h, 84px) + var(--sa-kb, 0px)); }
.sa-page .sa-scrim { position: fixed; inset: 0; pointer-events: none; }
.sa-page.is-typing .sa-scrim, .sa-page.is-open .sa-scrim { pointer-events: auto; }
.sa-page .sa-panel, .sa-page .sa-form, .sa-page .sa-welcome, .sa-page .sa-voice-note { pointer-events: auto; }
.sa-page .sa-dock { position: absolute; z-index: 10; left: 0; right: 0; bottom: var(--sa-kb, 0px); }
/* soft fade so page content behind the floating bar doesn't clash with it */
.sa-page .sa-dock::before { content: ""; position: absolute; inset: -24px 0 0; z-index: -1; pointer-events: none;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.92) 40%, rgba(255, 255, 255, 0)); }
.sa-page.is-typing .sa-dock::before, .sa-page.is-open .sa-dock::before { opacity: 0; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 640px) {
  .sa-panel { top: 8px; bottom: 8px; border-radius: 14px; }
  .sa-panel-head { padding: 8px 8px 8px 12px; }
  .sa-scroll { padding: 4px 18px 16px; }
  .sa-scroll .msg-user { font-size: 18px; }
  .sa-dock { padding: 10px 10px max(10px, env(safe-area-inset-bottom)); }
  .sa-form { padding-left: 42px; border-radius: 14px; }
  .sa-icon { left: 14px; }
  .sa-send { padding: 0 16px; }
  .sa-input { font-size: 16px; } /* 16px keeps iOS from zooming in on focus */
}
@media (max-width: 640px) {
  .sa-mic, .sa-attach { width: 42px; height: 42px; }
  .sa-form { gap: 4px; }
  .sa-form.has-attach { padding-left: 4px; }
  .sa-welcome { bottom: 10px; }
  .sa-welcome-chips { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none;
    padding: 2px 2px 4px; }
  .sa-welcome-chips .sa-welcome-chip { flex: none; max-width: none; }
  .sa-welcome-chip { font-size: 15px; padding: 10px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .sa-scrim { transition: none; }
  .sa-panel, .sa-welcome { animation: none; }
  .sa-form.is-voice-ready .sa-send { animation: none; }
}

/* a long pasted message: its first lines, then all of it on Show all */
.sa-scroll .msg-user.is-long { font-size: 15px; font-weight: 500; line-height: 1.5; white-space: pre-wrap;
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.sa-scroll .msg-user.is-long.is-open { display: block; -webkit-line-clamp: unset; }
.sa-more { border: 0; background: none; padding: 2px 0; margin: -2px 0 8px; color: var(--primary, #4f46e5);
  font: 500 13.5px/1.4 var(--font-body, inherit); cursor: pointer; }
