/* Slimstock Support Assistant — Chainlit brand overlay
 * Target: docs/"Slimstock Support assistant.html" interactive mockup.
 * Palette lives in public/theme.json; this file applies the parts theme.json
 * can't express: the Inter/Fraunces type, navy user bubbles, bubble-free
 * assistant messages, the bright-blue circular send button and the warm
 * pill composer.
 */

:root {
  --ss-navy: #002e47;
  --ss-blue: #00a1e4;          /* --primary in the mockup (accents, links, focus) */
  --ss-blue-strong: #00558f;
  --ss-orange: #f5821e;        /* call to action / chosen state; never body text */
  --ss-send: #38bdf8;          /* lighter sky blue for the send button (light mode) */
  --ss-send-hover: #0ea5e9;
  --ss-paper: #f4f1ea;
  --ss-surface: #ffffff;
  --ss-line: #e7eaef;
  --ss-ink: #0f1b2b;
  --ss-shadow: 0 1px 2px rgba(0, 46, 71, 0.05), 0 14px 34px -16px rgba(0, 46, 71, 0.16);
  --ss-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ss-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --ss-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---- Typography: Inter for UI, Fraunces for editorial headings ---- */
html,
body,
button,
input,
textarea,
select,
[class*="cl-"] {
  font-family: var(--ss-sans);
}

/* Assistant markdown headings get the Fraunces serif accent from the mockup */
.ai-message h1,
.ai-message h2,
.ai-message h3 {
  font-family: var(--ss-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* ---- Clean top bar that follows the theme background (light or dark) ---- */
#header {
  background: hsl(var(--background) / 0.82);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid hsl(var(--border));
}

#header img[alt*="logo" i],
.cl-logo img {
  max-height: 24px;
  width: auto;
}

/* ---- User message: solid navy bubble, white text, right aligned ----
 * This Chainlit build wraps the user text in a `bg-accent rounded-3xl max-w-[70%]`
 * div inside the user step; bg-muted covers older builds. */
.step[data-step-type="user_message"] [class*="bg-accent"],
.step[data-step-type="user_message"] [class*="bg-muted"] {
  background: var(--ss-navy) !important;
  border-radius: 18px 18px 6px 18px !important;
  box-shadow: var(--ss-shadow);
}

.step[data-step-type="user_message"] [class*="bg-accent"] *,
.step[data-step-type="user_message"] [class*="bg-muted"] * {
  color: #ffffff !important;
}

/* ---- Assistant message: no bubble, plain text on the paper background ---- */
.ai-message {
  background: transparent !important;
}

.ai-message .message-content {
  font-size: 1rem;
  line-height: 1.6;
}

/* ---- Composer: warm white pill with a soft shadow and brand focus ---- */
#message-composer {
  background: var(--ss-surface) !important;
  border: 1px solid hsl(var(--border));
  border-radius: 28px !important;
  box-shadow: var(--ss-shadow);
  transition: border-color 180ms var(--ss-ease), box-shadow 180ms var(--ss-ease);
}

.dark #message-composer {
  background: hsl(var(--card)) !important;
}

#message-composer:focus-within {
  border-color: var(--ss-blue);
  box-shadow: 0 0 0 3px rgba(0, 161, 228, 0.18), var(--ss-shadow);
}

/* ---- Send button: light sky-blue circle with a white arrow ---- */
#chat-submit {
  background-color: var(--ss-send) !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 50% !important;
  width: 38px !important;
  height: 38px !important;
  transition: background-color 180ms var(--ss-ease), transform 180ms var(--ss-ease);
}

#chat-submit:hover:not(:disabled) {
  background-color: var(--ss-send-hover) !important;
  transform: translateY(-1px);
}

#chat-submit:disabled {
  background-color: hsl(var(--muted)) !important;
  color: hsl(var(--muted-foreground)) !important;
}

#chat-submit svg {
  color: #ffffff !important;
}

/* ---- Attach control: soft circular button (mockup's "+") ---- */
#message-composer label[for="upload-button-input"],
#message-composer button:has(svg.lucide-paperclip) {
  border-radius: 50% !important;
  width: 36px;
  height: 36px;
  border: 1px solid hsl(var(--border));
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---- Feedback thumbs: the chosen thumb is an orange outline ----
 * !important is needed: the ghost button's hover colour would otherwise win. */
button.positive-feedback-on,
button.negative-feedback-on {
  color: var(--ss-orange) !important;
}

/* ---- Scroll to bottom arrow: the full width container ignores the pointer (issue #1401) ----
 * Chainlit 2.12.0 draws the arrow in a container that spans the whole width of the message list and
 * lies over its bottom while the page is scrolled up. It swallowed the clicks meant for the buttons
 * and tick boxes of a card under it. The container lets the pointer through; the arrow button keeps it. */
div.relative.flex.flex-col.flex-grow.overflow-y-auto > div.absolute.bottom-4.left-0.right-0.flex.justify-center {
  pointer-events: none;
}

div.relative.flex.flex-col.flex-grow.overflow-y-auto > div.absolute.bottom-4.left-0.right-0.flex.justify-center > button {
  pointer-events: auto;
}

/* ---- Links: brand blue (orange is not used in this mockup) ---- */
a:not([class*="button" i]) {
  color: var(--ss-blue-strong);
  text-decoration-color: rgba(0, 85, 143, 0.4);
}
a:not([class*="button" i]):hover {
  color: var(--ss-blue);
}

/* Dark mode: the dark navy link colour is unreadable on a dark background
   (it also styles the sidebar conversation titles), so use a light blue. */
.dark a:not([class*="button" i]) {
  color: #6cc5f5;
  text-decoration-color: rgba(108, 197, 245, 0.4);
}
.dark a:not([class*="button" i]):hover {
  color: #9bd6f8;
}

/* ---- Sidebar: active chat reads as a clean white card ---- */
#new-chat-button {
  border-radius: 12px !important;
}

/* ---- Branded scrollbars ---- */
* {
  scrollbar-color: #b9c4d0 transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: #c2ccd6;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--ss-blue);
  background-clip: content-box;
}

/* ---- Assistant avatar: animated loader while the turn is running, plus
 * the busy-word label's theme colours (issue #546) ----
 * Chainlit marks the streaming message with a blinking .loading-cursor; the
 * second selector covers the window before the first token, while the message
 * body is still empty and the composer still shows #stop-button. */
:root {
  --ss-avatar-loader: url("/public/avatar_loader_light.gif");
  --ss-busy-word-color: var(--ss-blue-strong);
}
html.dark {
  --ss-avatar-loader: url("/public/avatar_loader_dark.gif");
  --ss-busy-word-color: #9bd6f8;
}

.step[data-step-type="assistant_message"]:has(.loading-cursor)
  .ai-message img[alt^="Avatar for"],
body:has(#stop-button)
  .step[data-step-type="assistant_message"]:last-child:has(.message-content:empty)
  .ai-message img[alt^="Avatar for"] {
  content: var(--ss-avatar-loader);
  object-fit: contain;
}

/* ---- Busy-word label: cycles a supply-chain word next to the avatar ----
 * (issue #546). public/custom.js sets --ss-busy-word and the [data-ss-busy]
 * attribute on <html> every ~1.75s while a turn is busy and no content has
 * rendered yet; this rule only renders the word for THAT turn's assistant
 * step, not every past assistant message in the thread, because
 * :has(.message-content:empty) only ever matches the one step still
 * awaiting its first token -- every earlier turn's step is already
 * populated. Anchored on the avatar's own wrapper span (not the inner
 * h-5/w-5/overflow-hidden avatar-crop span, which would clip it) so the
 * word sits immediately after the avatar, before the message body.
 *
 * Brittleness warning: this shares its DOM markers with the avatar-loader
 * block above (#stop-button, .loading-cursor, .message-content:empty) and
 * with the predicate in public/custom.js -- a Chainlit frontend bump that
 * changes any of them can silently break both together; check custom.js too.
 *
 * The wrapper only ever sizes itself to the 20px avatar crop; without the
 * inline-flex rule below it stays that narrow and the ::after word wraps
 * onto its own line under the avatar instead of sitting beside it. */
html[data-ss-busy]
  .step[data-step-type="assistant_message"]:has(.message-content:empty)
  .ai-message
  > span.inline-block {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

html[data-ss-busy]
  .step[data-step-type="assistant_message"]:has(.message-content:empty)
  .ai-message
  > span.inline-block::after {
  content: var(--ss-busy-word, "");
  margin-left: 0.375rem;
  color: var(--ss-busy-word-color);
  font-family: var(--ss-sans);
  font-size: 0.75rem;
  font-style: italic;
  white-space: nowrap;
}

/* ---- Header Artifacts pane (public/artifacts.js) ---- */
.ss-artifacts-panel {
  position: fixed;
  z-index: 50;
  width: min(360px, calc(100vw - 16px));
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  box-shadow: var(--ss-shadow);
  font-family: var(--ss-sans);
  outline: none;
}

.ss-artifacts-panel[hidden] {
  display: none;
}

.ss-artifacts-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid hsl(var(--border));
}

.ss-artifacts-title {
  margin: 0;
  font-family: var(--ss-serif);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.ss-artifacts-subtitle {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.ss-artifacts-body {
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.ss-artifacts-status {
  margin: 0;
  padding: 18px 12px;
  text-align: center;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.ss-artifacts-status:empty {
  padding: 0;
}

.ss-artifacts-subtitle:empty {
  display: none;
}

.ss-artifacts-retry[hidden] {
  display: none;
}

.ss-artifacts-status-error {
  color: hsl(var(--destructive));
}

.dark .ss-artifacts-status-error {
  color: #ff8a8a;
}

.ss-artifacts-retry {
  display: block;
  margin: 0 auto 12px;
  padding: 6px 14px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}

.ss-artifacts-retry:hover {
  background: hsl(var(--accent));
}

.ss-artifacts-retry:focus-visible {
  outline: 2px solid var(--ss-blue);
  outline-offset: 2px;
}

.ss-artifacts-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ss-artifacts-row + .ss-artifacts-row {
  margin-top: 2px;
}

.ss-artifacts-list a.ss-artifacts-item {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
}

.ss-artifacts-item:hover {
  background: hsl(var(--accent));
}

.ss-artifacts-item:focus-visible {
  outline: 2px solid var(--ss-blue);
  outline-offset: -2px;
}

.ss-artifacts-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 500;
}

.ss-artifacts-date {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

#artifacts-header-button[aria-expanded="true"] {
  background: hsl(var(--accent));
}

/* ---- Settings panel: red X that deletes one of the caller's own skills (issue #1021) ----
   public/skill_delete_buttons.js adds the button as the last child of a skill's row. The row and
   its label are React nodes the script does not write to, so the anchoring is keyed on the button.
   Tailwind's space-y-2 gives every later child of the row a margin-top at a higher specificity than
   a class, and the button is placed by top and right, so that margin is cancelled. */
div:has(> button.ss-skill-delete) {
  position: relative;
}

div:has(> button.ss-skill-delete) > label {
  padding-right: 2rem;
}

button.ss-skill-delete {
  position: absolute;
  top: 10px;
  right: 0;
  transform: translateY(-50%);
  margin-top: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: hsl(var(--destructive, 0 72% 51%));
  cursor: pointer;
}

.dark button.ss-skill-delete {
  color: hsl(0 84% 66%);
}

button.ss-skill-delete:hover {
  background: hsl(var(--destructive, 0 72% 51%) / 0.12);
}

button.ss-skill-delete:focus-visible {
  outline: 2px solid hsl(var(--ring, 198 100% 45%));
  outline-offset: 1px;
}

button.ss-skill-delete svg {
  pointer-events: none;
}

/* ---- Composer Model picker: description above the model name (issue #1033) ----
   Chainlit 2.12.0 draws an option as one wrapper div holding the name (text-sm, font-medium) and,
   only when the option has a description, the description (text-xs, muted) after it. There is no
   setting for the layout, so this reverses it: column-reverse puts the description on top, and the
   two lines swap type styles, so the description is the larger line and the name the smaller one.
   An option with no description has one child, which none of the two-child rules match, so it
   keeps the larger style and leaves no empty line. The picker's button, the option ids and the
   submitted value are untouched, because nothing here changes data.
   The DOM order stays name then description on purpose: nothing inside the wrapper takes focus
   (the option itself does), so only the visual emphasis is reversed and the option is still read
   out as the model name followed by its description.
   Keyed on #mode-picker-popover-model, [cmdk-item] and the wrapper's flex-1 class, none of them
   documented. ui/tests/integration/test_model_picker_layout_browser.py fails first on a Chainlit
   bump; if the markup changes, these rules stop matching and the picker shows Chainlit's own
   layout again. */
#mode-picker-popover-model [cmdk-item] > div.flex-1 {
  display: flex;
  flex-direction: column-reverse;
}

#mode-picker-popover-model [cmdk-item] > div.flex-1 > div:first-child:not(:last-child) {
  margin-top: 2px;
  font-size: 0.75rem;
  font-weight: 400;
  color: inherit;
}

#mode-picker-popover-model [cmdk-item] > div.flex-1 > div:last-child:not(:first-child) {
  margin-top: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: inherit;
}

/* ---- Download failure toast (issue #1223) ----
   public/download_failure_toast.js draws one red message per failed download. Chainlit 2.12.0 has no
   way to raise its own toast from page script, so this is a plain element: role="alert" so a
   screen reader says it at once, a dismiss button that can take focus, and a timer in the script.
   The red is the theme's own --destructive with the theme's own white --destructive-foreground:
   white on 0 72% 51% (light) and on 0 62% 50% (dark) is above 4.5 to 1, checked in
   ui/tests/integration/test_download_failure_toast_browser.py. The toast has its own border so
   it stands out from the page in both themes. */
#ss-download-toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}

.ss-download-toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 8px 12px 14px;
  border: 1px solid hsl(0 0% 100% / 0.45);
  border-radius: 8px;
  background: hsl(var(--destructive, 0 72% 51%));
  color: hsl(var(--destructive-foreground, 0 0% 100%));
  box-shadow: 0 6px 20px hsl(0 0% 0% / 0.3);
  font-size: 0.875rem;
  line-height: 1.4;
  pointer-events: auto;
}

.ss-download-toast-text {
  flex: 1;
  padding-top: 3px;
  overflow-wrap: anywhere;
}

button.ss-download-toast-dismiss {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

button.ss-download-toast-dismiss:hover {
  background: hsl(0 0% 100% / 0.2);
}

button.ss-download-toast-dismiss:focus-visible {
  outline: 2px solid hsl(0 0% 100%);
  outline-offset: 1px;
}
