/*
 * Answer styles shared by the demo page, the embeddable assistant (inside a Shadow DOM) and the
 * admin replay. Plain store look: white surfaces, thin borders, the store's teal-grey buttons.
 */
:root, :host {
  --text: #1e293b;
  --muted: #5f6b7a;
  --primary: #395b64;
  --primary-hover: #2f4b53;
  --primary-soft: #e7f6f2;
  --accent: #395b64;
  --gradient: #395b64; /* kept for older rules: a solid colour, no gradient */
  --border: #dbe3e2;
  --surface: #f6f9f8;
  --subtle: #f2f5f7;
  --highlight: #ffcd57;
  --danger: #9f1239;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  --font-heading: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bodoni Moda", Georgia, serif;
}

/* ------------------------------------------------------------------ turns */
.thread { display: flex; flex-direction: column; gap: 0; }
.thread:empty::before { content: "Ask a new question below."; color: var(--muted); font-size: 14px; padding: 8px 0; }
.sa-turn { padding: 18px 0 22px; border-top: 1px solid var(--border); }
.sa-turn:first-child { border-top: 0; padding-top: 4px; }
.msg-user {
  margin: 0 0 10px; font-family: var(--font-heading); font-weight: 700; font-size: 17px; line-height: 1.35;
  color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-ai { display: block; }
.msg-avatar { display: none; }
.msg-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; min-height: 22px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); opacity: 0.7; }
.status-text { color: var(--muted); }
.trace { font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------------ markdown */
.md { font-family: var(--font-body); font-size: 15.5px; line-height: 1.65; color: var(--text); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 0.7em; }
.md ul, .md ol { margin: 0 0 0.7em; padding-left: 1.3em; }
.md li { margin: 0.2em 0; }
.md strong { font-weight: 700; color: var(--text); }
.md a { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.md h1, .md h2, .md h3 { font-family: var(--font-heading); font-weight: 700; color: var(--text); line-height: 1.25; margin: 0.9em 0 0.4em; }
.md h1 { font-size: 20px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; }
.md code { background: var(--subtle); border-radius: 4px; padding: 1px 5px; font-size: 0.9em; }
.md pre { background: var(--subtle); padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
.md pre code { background: transparent; padding: 0; }
.md blockquote { margin: 0 0 0.7em; padding: 4px 14px; border-left: 3px solid var(--border); color: var(--muted); }
.md table { border-collapse: collapse; margin: 0 0 0.8em; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--surface); font-weight: 600; }
.md hr { border: 0; height: 1px; background: var(--border); }

/* ------------------------------------------------------------------ widget blocks */
.blk { border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; }
.blk-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--border); }
.blk-title { flex: 1; min-width: 0; font-family: var(--font-heading); font-weight: 600; font-size: 13.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk-state { font-size: 12px; color: var(--muted); }
.blk-toggle { border: 1px solid var(--border); background: #fff; color: var(--muted); border-radius: 6px;
  font: inherit; font-size: 12px; padding: 3px 9px; cursor: pointer; }
.blk-toggle:hover { color: var(--text); }
.blk-frame { display: block; width: 100%; height: 120px; border: 0; background: #fff; }
.blk-code { margin: 0; max-height: 200px; overflow: auto; padding: 10px 14px; background: var(--subtle); color: var(--muted);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }
.blk-skeleton { height: 96px; margin: 12px; border-radius: 8px; background: var(--subtle); }
.blk-error { padding: 9px 14px; font-size: 13px; color: #7a4b00; background: #fff8e6; border-top: 1px solid #f3e2b8; }

/* ------------------------------------------------------------------ media */
.media { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.media-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.media--single .media-grid { grid-template-columns: minmax(0, 520px); }
.media--carousel .media-grid { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
.media--carousel .media-item { flex: 0 0 min(78%, 340px); scroll-snap-align: start; }
.media-item { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--subtle);
  padding: 0; cursor: zoom-in; aspect-ratio: 1 / 1; }
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item--video { aspect-ratio: 16 / 9; cursor: pointer; }
.media-item--video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.media-item .play { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 23, 42, 0.28); }
.media-item .play span { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--text); }
.media-item .media-label { position: absolute; left: 10px; right: 10px; bottom: 8px; color: #fff; font: 600 12.5px/1.3 var(--font-body);
  text-align: left; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.media-caption { font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------------ CTAs */
.ctas { display: flex; flex-wrap: wrap; gap: 8px; }
.cta { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--primary); background: var(--cta-bg, #fff); color: var(--primary);
  border-radius: 6px; padding: 9px 16px; font: 600 14px/1.2 var(--font-heading); cursor: pointer; transition: background 0.15s; }
.cta:hover { background: var(--primary-soft); }
/* the label colour a page sets for its primary colour (Saariv's dark theme), else the page's soft tint */
.cta--primary { background: var(--primary); color: var(--on-primary, var(--primary-soft)); }
.cta--primary:hover { background: var(--primary-hover); }
.cta:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.msg-error { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; background: #fff1f2;
  color: var(--danger); font-size: 14px; border: 1px solid #fecdd3; }
.msg-error button { margin-left: auto; border: 1px solid #fecdd3; background: #fff; color: var(--danger); border-radius: 6px;
  padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.msg-stopped { font-size: 12.5px; color: var(--muted); }
.sa-cart-note { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--primary-soft); color: var(--text); font-size: 14px; }
.sa-cart-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.sa-cart-note a { color: var(--primary); font-weight: 600; }

/* ------------------------------------------------------------------ toast + lightbox */
.toast { position: fixed; left: 50%; bottom: 112px; transform: translateX(-50%); z-index: 2147483600;
  background: var(--text); color: #fff; padding: 9px 16px; border-radius: 6px; font: 500 14px/1.3 var(--font-body); box-shadow: var(--shadow); }
.lightbox { position: fixed; inset: 0; z-index: 2147483600; background: rgba(15, 23, 42, 0.86); display: grid; place-items: center;
  padding: 40px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
[hidden] { display: none !important; }

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

/* A site page shown inside an answer */
.page-frame { margin: 14px 0; border: 1px solid #e3e8ea; border-radius: 12px; overflow: hidden; background: #fff; }
.page-frame-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #edf1f0;
  font: 600 13.5px/1.3 var(--font-heading); }
.page-frame--card .page-frame-bar { border-bottom: 0; }
.page-frame-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.page-frame-open { flex: none; color: var(--primary); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.page-frame-open:hover { background: var(--primary-soft); }
.page-frame iframe { display: block; width: 100%; height: min(560px, 62vh); border: 0; background: #fff; }
.page-frame-note { margin: 0; padding: 0 12px 12px; color: var(--muted); font-size: 14px; }
