/* ============================================================================
   Semantik × Blazor Blueprint: the few rules the settings, workspace, files and notification parts add
   on top of Blueprint's components. Everything is sm-bb- prefixed (menus and dialogs render in Blueprint's
   portal host, outside the components, so these cannot be component-scoped) and reads Blueprint's
   tokens, so it follows every base colour, accent, radius and mode the host's theme offers.
   ========================================================================= */

/* ── Settings panel ───────────────────────────────────────────────────── */

.sm-bb-settings {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 48rem;
  margin-inline: auto;
  padding: 1.5rem 1rem 0;
}

.sm-bb-settings__header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.sm-bb-settings__heading { min-width: 0; flex: 1 1 20rem; }
.sm-bb-settings__title { margin: 0; font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; color: var(--foreground); }
/* Section cards sit under the page title (h2): smaller than Blueprint's default card title. */
.sm-bb-settings__section-title { font-size: 1rem; letter-spacing: 0; }
.sm-bb-settings__description { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--muted-foreground); }
.sm-bb-settings__meta { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sm-bb-settings__loading { display: grid; place-items: center; padding: 3rem 0; }
.sm-bb-settings__empty { margin-top: 2rem; }

.sm-bb-settings__fields { display: flex; flex-direction: column; gap: 1.25rem; }
.sm-bb-settings__advanced { margin-top: 0.25rem; }
.sm-bb-settings__advanced .sm-bb-settings__fields { padding-top: 0.5rem; }

.sm-bb-settings__revisions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sm-bb-settings__revision { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.5rem 0; }
.sm-bb-settings__revision + .sm-bb-settings__revision { border-top: 1px solid var(--border); }
.sm-bb-settings__revision-name { font-weight: 500; font-size: 0.875rem; }
.sm-bb-settings__revision-meta { flex: 1; min-width: 10rem; color: var(--muted-foreground); font-size: 0.8125rem; }

.sm-bb-settings__footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.75rem 0 1rem;
  border-top: 1px solid var(--border);
  background: var(--background);
}

/* One field: label row (label, read-only badge, Reset/Clear menu), help, control, errors. */
.sm-bb-setting__head { display: flex; align-items: center; gap: 0.5rem; min-height: 1.5rem; }
.sm-bb-setting__label { flex: 0 1 auto; }
.sm-bb-setting__badge { flex-shrink: 0; }
.sm-bb-setting__menu { width: 1.5rem; height: 1.5rem; margin-inline-start: auto; color: var(--muted-foreground); }

.sm-bb-setting__control { min-width: 0; }
/* Blueprint's combobox trigger is a fixed 200px; model names need the room, on one line. */
.sm-bb-setting__combobox { width: 100%; max-width: 28rem; }
.sm-bb-setting__combobox > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.sm-bb-setting__number { display: flex; align-items: center; gap: 0.5rem; max-width: 16rem; }
.sm-bb-setting__unit { flex-shrink: 0; font-size: 0.875rem; color: var(--muted-foreground); }
.sm-bb-setting__textarea { min-height: 8rem; font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.8125rem; line-height: 1.6; }
.sm-bb-setting__pairs { display: flex; flex-direction: column; gap: 0.5rem; }
.sm-bb-setting__pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 0.5rem; align-items: center; }
.sm-bb-setting__add { align-self: flex-start; }
.sm-bb-setting__note { margin: 0 0 0.25rem; font-size: 0.8125rem; color: var(--muted-foreground); }
.sm-bb-setting__raw {
  display: block;
  padding: 0.375rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  background: var(--muted);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

/* ── Personal settings (SemantikPreferencesPanel) ───────────────────────── */

.sm-bb-setting__select { width: 100%; max-width: 28rem; }
.sm-bb-preferences__footer { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ── Colour families (SemantikPalettePicker) ───────────────────────────── */

.sm-bb-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.75rem; }
.sm-bb-palette__option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--card-foreground);
  text-align: start;
  cursor: pointer;
}
.sm-bb-palette__option:hover { border-color: color-mix(in oklab, var(--foreground) 30%, var(--border)); }
.sm-bb-palette__option[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.sm-bb-palette__option:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.sm-bb-palette__swatch { display: block; padding: 0.5rem; border-radius: calc(var(--radius) - 2px); border: 1px solid color-mix(in oklab, var(--border) 60%, transparent); }
.sm-bb-palette__surface { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem; border-radius: calc(var(--radius) - 4px); }
.sm-bb-palette__accent { width: 2.25rem; height: 0.75rem; border-radius: 999px; }
.sm-bb-palette__series { display: flex; gap: 0.25rem; }
.sm-bb-palette__series > span { width: 0.75rem; height: 0.75rem; border-radius: 999px; }
.sm-bb-palette__text { display: grid; gap: 0.125rem; padding: 0 0.125rem; }
.sm-bb-palette__name { font-size: 0.875rem; font-weight: 600; }
.sm-bb-palette__description { font-size: 0.75rem; color: var(--muted-foreground); }
.sm-bb-palette__check { position: absolute; top: 0.75rem; right: 0.75rem; width: 1rem; height: 1rem; padding: 0.125rem; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); }

/* Notification bell (SemantikNotificationsBell): badge on a ghost icon button, popover with sections. */
.sm-bb-notifications-bell { display: inline-flex; }

.sm-bb-notifications { width: min(24rem, calc(100vw - 2rem)); padding: 0; max-height: min(32rem, 70vh); overflow-y: auto; }
.sm-bb-notifications__header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--border); }
.sm-bb-notifications__title { margin: 0; font-size: 0.875rem; font-weight: 600; }
.sm-bb-notifications__empty { padding: 1.5rem 1rem; }
.sm-bb-notifications__list { display: grid; padding: 0.25rem 0; }
.sm-bb-notifications__section { display: grid; }
.sm-bb-notifications__heading { margin: 0; padding: 0.5rem 0.75rem 0.25rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; color: var(--muted-foreground); }
.sm-bb-notifications__item {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.sm-bb-notifications__item:hover { background: var(--accent); }
.sm-bb-notifications__item:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.sm-bb-notifications__icon { flex: none; width: 1rem; height: 1rem; margin-top: 0.125rem; color: var(--muted-foreground); }
.sm-bb-notifications__item--action .sm-bb-notifications__icon { color: var(--primary); }
.sm-bb-notifications__text { display: grid; flex: 1; min-width: 0; gap: 0.125rem; }
.sm-bb-notifications__item-title { font-size: 0.875rem; line-height: 1.25; }
.sm-bb-notifications__item--unread .sm-bb-notifications__item-title { font-weight: 600; }
.sm-bb-notifications__detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; color: var(--muted-foreground); }
.sm-bb-notifications__time { flex: none; font-size: 0.75rem; color: var(--muted-foreground); white-space: nowrap; }
.sm-bb-notifications__dot { flex: none; width: 0.5rem; height: 0.5rem; margin-top: 0.3125rem; border-radius: 999px; background: var(--primary); }

/* Session side panel (SemantikWorkspace): the chat and a resizable panel with tabs; a sheet on a phone. */
.sm-bb-workspace { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; height: 100%; }
.sm-bb-workspace__group { flex: 1; min-height: 0; }
.sm-bb-workspace__chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
/* The split stays mounted; while the panel is closed (or on a phone) its panel and handle are hidden and the chat fills the width. */
.sm-bb-workspace--closed .sm-bb-workspace__panel,
.sm-bb-workspace--closed .sm-bb-workspace__handle { display: none; }
.sm-bb-workspace__panel { min-height: 0; border-inline-start: 1px solid var(--border); background: var(--background); }
.sm-bb-workspace__tabs { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sm-bb-workspace__tablist { height: auto; flex-wrap: wrap; justify-content: flex-start; gap: 0.25rem; }
.sm-bb-workspace__tab { position: relative; display: inline-flex; align-items: center; }
.sm-bb-workspace__tab > [role="tab"] { gap: 0.375rem; padding-inline-end: 1.5rem; }
.sm-bb-workspace__tab > [role="tab"] svg { width: 1rem; height: 1rem; flex: none; }
.sm-bb-workspace__close { position: absolute; inset-inline-end: 0.25rem; display: inline-grid; place-items: center; width: 1.125rem; height: 1.125rem; padding: 0; border: 0; border-radius: var(--radius-sm, 0.25rem); background: transparent; color: inherit; opacity: 0.6; cursor: pointer; }
.sm-bb-workspace__close svg { width: 0.75rem; height: 0.75rem; }
.sm-bb-workspace__close:hover,
.sm-bb-workspace__close:focus-visible { opacity: 1; background: var(--accent); }
.sm-bb-workspace__close:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.sm-bb-workspace__content { flex: 1; min-height: 0; margin-top: 0.5rem; padding: 0.25rem; overflow-y: auto; }
.sm-bb-workspace__content[hidden],
.sm-bb-workspace__content[data-state="inactive"] { display: none; }
.sm-bb-workspace__sheet { display: flex; flex-direction: column; width: min(24rem, 100vw); padding: 1rem; }
.sm-bb-workspace__sheet-title { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* The toggle and the bell sit beside the chat's own header buttons: they take the SDK's sm-icon-button
   (28px, 16px icon, muted ghost) instead of Blueprint's 40px icon button. */
.sm-bb-workspace-toggle.sm-icon-button,
.sm-bb-notifications__trigger.sm-icon-button { width: 1.75rem; height: 1.75rem; min-width: 0; padding: 0; }
.sm-bb-workspace-toggle.sm-icon-button svg,
.sm-bb-notifications__trigger.sm-icon-button svg { width: 1rem; height: 1rem; }
.sm-bb-workspace-toggle[aria-pressed="true"] { background: var(--muted); color: var(--foreground); }

/* Files panel (SemantikFilesPanel): a folder tree beside a table or a grid of tiles; on a narrow panel the tree sits above the list. */
.sm-bb-files { display: flex; flex-direction: column; gap: 0.5rem; height: 100%; min-height: 0; container-type: inline-size; }
.sm-bb-files__toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
.sm-bb-files__crumbs { flex: 1 1 8rem; min-width: 0; }
.sm-bb-files__crumbs ol { flex-wrap: nowrap; overflow: hidden; }
.sm-bb-files__crumb { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.sm-bb-files__crumb:hover { color: var(--foreground); text-decoration: underline; }
.sm-bb-files__crumb:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; border-radius: var(--radius-sm, 0.25rem); }
.sm-bb-files__crumb-file { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-bb-files__search { display: flex; align-items: center; gap: 0.375rem; flex: 1 1 9rem; min-width: 0; height: 2rem; padding-inline: 0.625rem; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); }
.sm-bb-files__search:focus-within { outline: 2px solid var(--ring); outline-offset: 1px; }
.sm-bb-files__search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--foreground); font: inherit; font-size: 0.8125rem; }
.sm-bb-files__tree-toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-foreground); }
.sm-bb-files__body { display: flex; flex: 1; min-height: 0; gap: 0.5rem; }
.sm-bb-files__tree { flex: 0 0 11rem; min-width: 0; overflow-y: auto; padding-inline-end: 0.5rem; border-inline-end: 1px solid var(--border); }
.sm-bb-files__main { flex: 1; min-width: 0; min-height: 0; overflow: auto; }
@container (max-width: 26rem) {
  .sm-bb-files__body { flex-direction: column; }
  .sm-bb-files__tree { flex: none; max-height: 9rem; padding: 0 0 0.5rem; border-inline-end: 0; border-bottom: 1px solid var(--border); }
}
.sm-bb-files__name { display: inline-flex; align-items: center; gap: 0.5rem; max-width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.sm-bb-files__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-bb-files__name svg { flex: none; color: var(--muted-foreground); }
.sm-bb-files__name:hover span { text-decoration: underline; }
.sm-bb-files__name:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-sm, 0.25rem); }
.sm-bb-files__grid { gap: 0.5rem; }
.sm-bb-files__tile { display: flex; flex-direction: column; align-items: center; gap: 0.375rem; width: 100%; padding: 0.5rem; border: 1px solid transparent; border-radius: var(--radius-md, 0.5rem); background: transparent; color: inherit; font: inherit; cursor: pointer; }
.sm-bb-files__tile:hover { background: var(--accent); }
.sm-bb-files__tile:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.sm-bb-files__thumb { display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius-sm, 0.25rem); background: var(--muted); color: var(--muted-foreground); }
.sm-bb-files__thumb img { width: 100%; height: 100%; object-fit: cover; }
.sm-bb-files__tile-name { width: 100%; overflow: hidden; font-size: 0.75rem; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.sm-bb-files__error { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.75rem; border: 1px solid var(--destructive); border-radius: var(--radius-md, 0.5rem); color: var(--destructive); font-size: 0.8125rem; }
.sm-bb-files__loading { padding: 0.75rem; color: var(--muted-foreground); font-size: 0.8125rem; }
.sm-bb-files__preview { min-width: 0; }

/* Code panel (SemantikCodePanel): the code interpreter's files by workspace; a file opens as highlighted source or a read-only line diff. */
.sm-bb-code { display: flex; flex-direction: column; gap: 0.5rem; height: 100%; min-height: 0; }
.sm-bb-code__toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
.sm-bb-code__title { flex: 1 1 6rem; min-width: 0; overflow: hidden; font-size: 0.8125rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.sm-bb-code__version select { height: 2rem; max-width: 14rem; padding-inline: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius-md, 0.5rem); background: var(--background); color: var(--foreground); font: inherit; font-size: 0.8125rem; }
.sm-bb-code__version select:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.sm-bb-code__body { flex: 1; min-height: 0; min-width: 0; overflow: auto; }
.sm-bb-code__workspace + .sm-bb-code__workspace { margin-top: 0.75rem; }
.sm-bb-code__workspace-title { margin: 0 0 0.25rem; color: var(--muted-foreground); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
.sm-bb-code__files { margin: 0; padding: 0; list-style: none; }
.sm-bb-code__file { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.375rem 0.5rem; border: 0; border-radius: var(--radius-sm, 0.25rem); background: transparent; color: inherit; font: inherit; font-size: 0.8125rem; text-align: start; cursor: pointer; }
.sm-bb-code__file:hover { background: var(--accent); }
.sm-bb-code__file:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.sm-bb-code__file svg { flex: none; color: var(--muted-foreground); }
.sm-bb-code__file-name { flex: 1; min-width: 0; overflow: hidden; font-family: var(--font-mono, ui-monospace, monospace); text-overflow: ellipsis; white-space: nowrap; }
.sm-bb-code__badge { flex: none; padding: 0 0.375rem; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); font-size: 0.6875rem; }
.sm-bb-code__error { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.75rem; border: 1px solid var(--destructive); border-radius: var(--radius-md, 0.5rem); color: var(--destructive); font-size: 0.8125rem; }
.sm-bb-code__loading, .sm-bb-code__note { padding: 0.5rem 0.75rem; color: var(--muted-foreground); font-size: 0.8125rem; }
.sm-bb-code__diff { font-size: 0.8125rem; }
.sm-bb-code__diff-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; color: var(--muted-foreground); }
.sm-bb-code__count { font-family: var(--font-mono, ui-monospace, monospace); font-weight: 600; }
.sm-bb-code__count--added { color: #1a7f37; }
.sm-bb-code__count--removed { color: #cf222e; }
.sm-bb-code__hunk { margin-bottom: 0.5rem; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md, 0.5rem); }
.sm-bb-code__hunk-head { padding: 0.25rem 0.5rem; background: var(--muted); color: var(--muted-foreground); font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.75rem; }
.sm-bb-code__lines { width: 100%; border-collapse: collapse; font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.75rem; line-height: 1.5; }
.sm-bb-code__ln { width: 1%; padding: 0 0.5rem; color: var(--muted-foreground); text-align: end; white-space: nowrap; user-select: none; }
.sm-bb-code__mark { width: 1%; padding: 0 0.25rem; text-align: center; user-select: none; }
.sm-bb-code__text { padding: 0 0.5rem; white-space: pre; }
.sm-bb-code__line--added { background: color-mix(in srgb, #2da44e 16%, transparent); }
.sm-bb-code__line--added .sm-bb-code__mark { color: #1a7f37; }
.sm-bb-code__line--removed { background: color-mix(in srgb, #cf222e 14%, transparent); }
.sm-bb-code__line--removed .sm-bb-code__mark { color: #cf222e; }
.dark .sm-bb-code__count--added, .dark .sm-bb-code__line--added .sm-bb-code__mark { color: #3fb950; }
.dark .sm-bb-code__count--removed, .dark .sm-bb-code__line--removed .sm-bb-code__mark { color: #f85149; }

@media (forced-colors: active) {
  .sm-bb-setting__menu { opacity: 1; forced-color-adjust: none; color: ButtonText; }
  .sm-bb-setting__menu:focus-visible { outline-color: Highlight; }
  .sm-bb-palette__option[aria-pressed="true"] { outline: 2px solid Highlight; }
  .sm-bb-palette__swatch { forced-color-adjust: none; }
  .sm-bb-files__tile:hover, .sm-bb-files__tree-toggle[aria-pressed="true"] { outline: 1px solid Highlight; }
  .sm-bb-code__line--added .sm-bb-code__mark, .sm-bb-code__line--removed .sm-bb-code__mark { forced-color-adjust: none; color: Highlight; }
}

/* Organisation defaults: a card per section, a "users may change" switch and the allowed values under each field. */
.sm-bb-tenant { display: flex; flex-direction: column; gap: 1.25rem; }
.sm-bb-tenant__switch { display: flex; align-items: center; gap: 0.625rem; }
.sm-bb-tenant__switch-label { font-size: 0.875rem; color: var(--foreground); }
.sm-bb-tenant__allowed { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px); min-width: 0; }
.sm-bb-tenant__allowed[aria-invalid="true"] { border-color: var(--destructive); }
.sm-bb-tenant__footer { margin-top: 0; }
.sm-bb-tenant__choices { display: flex; flex-direction: column; gap: 0.5rem; }
.sm-bb-tenant__choice { display: flex; align-items: center; gap: 0.625rem; }
