/*
 * StoryClick admin — layout and components.
 *
 * Everything here is prototype markup that P7 lifts into Razor Pages, so class
 * names are the ones the real pages will use. Colours come only from
 * tokens.css — never hard-code a hex in this file.
 */

body {
  font-family: var(--sc-font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell ──────────────────────────────────────────────────────────────── */

.sc-shell { display: flex; min-height: 100vh; }

.sc-sidebar {
  width: 244px;
  flex: 0 0 244px;
  background: var(--sc-surface);
  border-right: 1px solid var(--sc-line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sc-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--sc-line);
  text-decoration: none;
}
/* The logo (img/storyclick-logo.svg, from the app's brand/storyclick-icon.svg), in its own colours. */
.sc-brand-mark {
  height: 30px; width: auto;
  display: block;
  flex: 0 0 auto;
}
.sc-brand-name {
  font-family: var(--sc-font-display);
  font-size: 19px;
  color: var(--sc-text);
  line-height: 1.1;
}
.sc-brand-env {
  font-family: var(--sc-font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  /* Not --sc-text-mute: at 9px that measures 3.17:1, below the 4.5:1 small-text
     floor. The dim token is the quietest one that still passes here. */
  color: var(--sc-text-dim);
  text-transform: uppercase;
}

.sc-nav { padding: 10px 10px 24px; flex: 1; }
.sc-nav-group + .sc-nav-group { margin-top: 14px; }
.sc-nav-group-label {
  font-family: var(--sc-font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sc-text-dim);  /* see .sc-brand-env — 9px needs 4.5:1 */
  padding: 0 8px 6px;
}
.sc-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--sc-radius-sm);
  color: var(--sc-text-dim);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.3;
}
.sc-nav-link:hover { background: var(--sc-chip); color: var(--sc-text); text-decoration: none; }
.sc-nav-link.active { background: var(--sc-chip); color: var(--sc-text); font-weight: 500; }
.sc-nav-link.active .ti { color: var(--sc-accent); }
.sc-nav-link .ti { font-size: 17px; opacity: 0.9; flex: 0 0 auto; }
.sc-nav-count {
  margin-left: auto;
  font-family: var(--sc-font-mono);
  font-size: 10.5px;
  background: var(--sc-accent);
  color: var(--sc-accent-ink);
  border-radius: 99px;
  padding: 1px 6px;
}

.sc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.sc-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--sc-line);
  background: var(--sc-bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.sc-search {
  flex: 1;
  max-width: 380px;
  background: var(--sc-chip);
  border: 1px solid var(--sc-line);
  border-radius: var(--sc-radius-sm);
  color: var(--sc-text);
  padding: 6px 12px;
  font-size: 13px;
}
.sc-search::placeholder { color: var(--sc-text-mute); }

/* Role switcher — lets the client SEE what each role sees. It is also the
   role matrix made tangible: the nav is filtered from the same data P7 tests. */
.sc-role-switch { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.sc-role-switch label {
  font-family: var(--sc-font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sc-text-mute);
}

.sc-content { padding: 22px; flex: 1; }
.sc-content.narrow { max-width: 1180px; }

/* Tabler underlines links on hover. In a dense table every row would flicker an
   underline as the pointer crosses it, which reads as noise rather than affordance —
   the row's own hover highlight already says the row is live. */
a:hover { text-decoration: none; }
.sc-content a:not(.btn):not(.page-link):hover,
.sc-brand:hover,
.sc-nav-link:hover,
.sc-story-title:hover { text-decoration: none; }

/* ── Page header ────────────────────────────────────────────────────────── */

.sc-page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.sc-eyebrow {
  font-family: var(--sc-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sc-accent);
}
.sc-title {
  font-family: var(--sc-font-display);
  font-size: 30px;
  line-height: 1.15;
  color: var(--sc-text);
  margin: 2px 0 0;
}
.sc-subtitle { color: var(--sc-text-dim); font-size: 13px; margin: 4px 0 0; }
.sc-page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── Cards, tables ──────────────────────────────────────────────────────── */

.card { border-color: var(--sc-line); }
.card-header { border-bottom-color: var(--sc-line); padding: 12px 16px; }
.card-title { font-size: 14px; font-weight: 600; margin: 0; }

.table { --tblr-table-bg: transparent; font-size: 13px; }
.table thead th {
  font-family: var(--sc-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sc-text-mute);
  font-weight: 400;
  border-bottom-color: var(--sc-line);
  white-space: nowrap;
}
.table td { border-bottom-color: var(--sc-line); vertical-align: middle; }
.table tbody tr:hover { background: var(--sc-chip); }
.sc-num { font-family: var(--sc-font-mono); font-size: 12px; color: var(--sc-text-dim); }

/* Bootstrap's Reboot sets `img { max-width: 100% }`, which in a ten-column table
   lets the browser squeeze the cover cell and collapse the image to a sliver while
   it keeps its height. The cover is a fixed-size thumbnail, so opt out. */
.sc-cover {
  width: 34px; height: 44px;
  min-width: 34px;
  max-width: none;
  display: block;
  border-radius: 5px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--sc-surface-hi);
}
/* The cell must not be a candidate for shrinking either. */
.sc-cover-cell { width: 34px; padding-right: 0 !important; }
.sc-cover-lg {
  width: 108px; height: 135px;
  min-width: 108px; max-width: none;
  object-fit: cover;
  border-radius: var(--sc-radius);
}

.sc-story-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sc-story-title { font-weight: 500; color: var(--sc-text); }
.sc-story-sub { font-size: 11.5px; color: var(--sc-text-mute); }

/* ── Status pills ───────────────────────────────────────────────────────── */

.sc-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--sc-chip);
  font-size: 11.5px;
  color: var(--sc-text-dim);
  white-space: nowrap;
}
.sc-pill::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.sc-pill.is-draft     { color: var(--sc-draft); }
.sc-pill.is-review    { color: var(--sc-review); }
.sc-pill.is-published { color: var(--sc-published); }
.sc-pill.is-rejected  { color: var(--sc-rejected); }
.sc-pill.is-blocked   { color: var(--sc-blocked); }
.sc-pill.is-agent     { color: var(--sc-agent); }
.sc-pill.no-dot::before { display: none; }

/* Risk chips carry severity — the reviewer scans these first. */
.sc-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
}
.sc-flag.sev-block  { color: var(--sc-blocked);  border-color: color-mix(in srgb, var(--sc-blocked) 40%, transparent);  background: color-mix(in srgb, var(--sc-blocked) 12%, transparent); }
.sc-flag.sev-review { color: var(--sc-rejected); border-color: color-mix(in srgb, var(--sc-rejected) 40%, transparent); background: color-mix(in srgb, var(--sc-rejected) 12%, transparent); }
.sc-flag.sev-info   { color: var(--sc-text-dim); border-color: var(--sc-line); background: var(--sc-chip); }

/* ── Stat tiles ─────────────────────────────────────────────────────────── */

.sc-stat { padding: 14px 16px; }
.sc-stat-label {
  font-family: var(--sc-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sc-text-mute);
}
.sc-stat-value {
  font-family: var(--sc-font-display);
  font-size: 30px;
  line-height: 1.1;
  color: var(--sc-text);
  margin-top: 4px;
}
.sc-stat-delta { font-size: 11.5px; margin-top: 2px; }
.sc-up   { color: var(--sc-published); }
.sc-down { color: var(--sc-rejected); }

/* ── Forms ──────────────────────────────────────────────────────────────── */

.form-label {
  font-family: var(--sc-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sc-text-mute);
  margin-bottom: 5px;
}
.form-control, .form-select {
  background: var(--sc-chip);
  border-color: var(--sc-line);
  color: var(--sc-text);
  font-size: 13.5px;
}
.form-control:focus, .form-select:focus {
  background: var(--sc-chip);
  color: var(--sc-text);
  border-color: var(--sc-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--sc-accent) 22%, transparent);
}
.form-control::placeholder { color: var(--sc-text-mute); }
.form-hint { font-size: 11.5px; color: var(--sc-text-mute); }
.sc-required::after { content: '*'; color: var(--sc-accent); margin-left: 3px; }

.sc-field-new {
  border-left: 2px solid var(--sc-agent);
  padding-left: 10px;
  margin-left: -12px;
}
.sc-new-badge {
  font-family: var(--sc-font-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sc-agent);
  border: 1px solid color-mix(in srgb, var(--sc-agent) 45%, transparent);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 6px;
  vertical-align: 2px;
}

select[multiple].form-select { padding: 4px; }
select[multiple].form-select option { padding: 4px 7px; border-radius: 5px; }

/* ── Chat preview — how a story actually reads ──────────────────────────── */

.sc-thread { display: flex; flex-direction: column; gap: 7px; padding: 14px; }
.sc-bubble {
  max-width: 76%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  background: var(--sc-surface-hi);
  color: var(--sc-text);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}
.sc-bubble.is-me {
  align-self: flex-end;
  background: var(--sc-accent);
  color: var(--sc-accent-ink);
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 5px;
}
.sc-bubble-who { font-size: 10px; color: var(--sc-text-mute); margin: 4px 0 -3px 10px; }

/* The reader's own lines sit on the right, so their label has to follow them. Left
   where the bubble is not, it reads as belonging to the line above. */
.sc-bubble-who.is-me { text-align: right; margin: 4px 10px -3px 0; }
/* Narration is story text, not a caption: the body face at reading size, bright enough
   to read, set apart by a quiet panel rather than by being faint. */
.sc-narr {
  align-self: center;
  max-width: 82%;
  margin: 6px 0;
  padding: 7px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--sc-text) 6%, transparent);
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
  color: var(--sc-text);
}
.sc-choice-set {
  align-self: stretch;
  border: 1px dashed color-mix(in srgb, var(--sc-accent) 45%, transparent);
  border-radius: var(--sc-radius-sm);
  padding: 8px 10px;
}
.sc-choice {
  border: 1px solid var(--sc-line);
  border-radius: 99px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--sc-text-dim);
  margin-top: 6px;
  display: inline-block;
  background: transparent;
  font: inherit; font-size: 12px; text-align: left;
}
button.sc-choice { cursor: pointer; }
button.sc-choice:hover { border-color: var(--sc-accent); color: var(--sc-text); }
button.sc-choice:focus-visible { outline: 2px solid var(--sc-accent); outline-offset: 2px; }
/* The option this reading took, and the ones it did not. */
.sc-choice.is-picked { border-color: var(--sc-accent); background: color-mix(in srgb, var(--sc-accent) 14%, transparent); color: var(--sc-text); font-weight: 600; }
.sc-choice.is-picked .sc-choice-to { color: var(--sc-text-dim); }
.sc-choice.is-other { opacity: .65; }
/* The story scrolls in its own box, so "Read as" above it never scrolls away. */
.sc-thread-scroll { overflow-y: auto; overscroll-behavior: contain; padding-right: 6px; border-top: 1px solid var(--sc-line); padding-top: 12px; }
.sc-flash { animation: sc-flash 1.6s ease-out; }
@keyframes sc-flash { from { background: color-mix(in srgb, var(--sc-accent) 22%, transparent); } to { background: transparent; } }

/* Highlight range — the lines the app's Feed animates. */
.sc-line-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border-radius: 6px; }
.sc-line-row:hover { background: var(--sc-chip); }
.sc-line-row.in-highlight { background: color-mix(in srgb, var(--sc-accent) 10%, transparent); }

/* The Feed-highlight range, marked in the preview as well as the numbered list, so an
   editor can judge the moment as bubbles rather than as line numbers. */
.sc-bubble.in-highlight { outline: 2px solid var(--sc-accent); outline-offset: 1px; }
.sc-line-seq { font-family: var(--sc-font-mono); font-size: 11px; color: var(--sc-text-mute); width: 26px; flex: 0 0 auto; }

/* ── Empty and error states ─────────────────────────────────────────────── */

.sc-empty { padding: 56px 20px; text-align: center; }
.sc-empty .ti { font-size: 30px; color: var(--sc-text-mute); }
.sc-empty-title { font-family: var(--sc-font-display); font-size: 20px; color: var(--sc-text); margin-top: 10px; }
.sc-empty-body { color: var(--sc-text-dim); font-size: 13px; margin-top: 4px; }

/* ── Screen map (index) ─────────────────────────────────────────────────── */

.sc-map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.sc-map-card {
  border: 1px solid var(--sc-line);
  border-radius: var(--sc-radius);
  background: var(--sc-surface);
  padding: 14px 16px;
  text-decoration: none;
  display: block;
}
.sc-map-card:hover { border-color: var(--sc-accent); }
.sc-map-card h3 { font-size: 14px; color: var(--sc-text); margin: 0; font-weight: 600; }
.sc-map-card p { font-size: 12.5px; color: var(--sc-text-dim); margin: 4px 0 0; }
.sc-map-card .sc-status { font-family: var(--sc-font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; }

/* ── Prototype banner ───────────────────────────────────────────────────── */

.sc-proto-bar {
  background: color-mix(in srgb, var(--sc-agent) 16%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--sc-agent) 35%, transparent);
  color: var(--sc-text-dim);
  font-size: 11.5px;
  padding: 5px 22px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.sc-proto-bar strong { color: var(--sc-agent); font-weight: 600; }

@media (max-width: 992px) {
  .sc-sidebar { display: none; }
}

/* An empty state is a normal outcome, not a warning — it sits on the card like
   any other content rather than announcing itself with colour. */
.sc-empty .btn { display: inline-flex; }

/* Bootstrap's disabled pagination link lands at 3.34:1 on our surfaces. WCAG
   exempts inactive controls, but "Prev" that nobody can read is still worse
   than "Prev" that is merely obviously unavailable. */
.pagination .page-item.disabled .page-link { color: var(--sc-text-mute); opacity: 1; }

/* A switched-off block of fields.
   Dimming the whole container with opacity dims its labels too, and a label
   nobody can read is the one part that still has to work — it says what is
   switched off. So the controls fade and the words only step back to the muted
   token, which passes contrast on its own. */
.sc-off .form-control,
.sc-off .form-select,
.sc-off .form-check-input { opacity: 0.55; }
.sc-off .form-label,
.sc-off .form-check-label,
.sc-off .form-hint { color: var(--sc-text-mute); }

/* Pictures in a thread, and covers that do not exist yet. */
.sc-bubble-img { display: block; max-width: 220px; border-radius: 14px; overflow: hidden; margin: 2px 0; background: var(--sc-surface-hi); }
.sc-bubble-img.is-me { margin-left: auto; }
.sc-bubble-img img { display: block; width: 100%; max-width: none; height: auto; aspect-ratio: 1 / 1; object-fit: cover; }
.sc-cover-none { display: flex; align-items: center; justify-content: center; color: var(--sc-text-mute); background: var(--sc-surface-hi); }
.sc-line-pic { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; max-width: none; flex: none; }
.sc-media-thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; max-width: none; display: block; background: var(--sc-surface-hi); }

/* A choice as the reader meets it, and where each path goes. */
.sc-choice-label { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--sc-accent); font-weight: 600; }
.sc-choice-prompt { font-size: 13px; color: var(--sc-text); margin-top: 4px; }
.sc-choice-to { color: var(--sc-text-mute); font-size: 11px; }
.sc-path-mark {
  align-self: center;
  font-size: 11px;
  color: var(--sc-text-dim);
  border: 1px dashed var(--sc-line);
  border-radius: 99px;
  padding: 2px 10px;
  margin: 2px 0 6px;
}

/* Branches: each option's own scene carries a coloured bar, and a label where it starts. */
.sc-line { display: flex; flex-direction: column; gap: 7px; }
.sc-line.sc-branch { border-left: 3px solid var(--sc-branch); padding-left: 10px; margin-left: -13px; }
.sc-branch-start {
  align-self: stretch;
  font-size: 11.5px; font-weight: 600;
  color: var(--sc-text);
  border-left: 3px solid var(--sc-branch);
  background: color-mix(in srgb, var(--sc-branch) 14%, transparent);
  padding: 5px 10px; margin: 8px 0 0 -13px; border-radius: 0 8px 8px 0;
}
.sc-branch-1 { --sc-branch: #4f8cff; }
.sc-branch-2 { --sc-branch: #e0a030; }
.sc-branch-3 { --sc-branch: #3fb68b; }
.sc-branch-4 { --sc-branch: #b07cff; }
.sc-readas { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.sc-readas-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--sc-text-mute); margin-right: 4px; }
.sc-readas .btn.active { border-color: var(--sc-accent); color: var(--sc-accent); }
.sc-readas-hint { font-size: 11.5px; color: var(--sc-text-mute); margin-left: 4px; }
.sc-line-path { display: inline-flex; flex-direction: column; gap: 2px; min-width: 38px; }
.sc-opt-badge {
  font-size: 10px; font-weight: 600; white-space: nowrap; text-align: center;
  border-radius: 6px; padding: 1px 5px;
  border: 1px solid var(--sc-branch, var(--sc-line));
  color: var(--sc-text-dim);
}
.sc-scene-img { align-self: center; }
/* Continuous bar: each line's bar also covers the gap to the next line in its branch. */
.sc-line.sc-branch { padding-bottom: 7px; margin-bottom: -7px; }

/* A card that opens on click: the header is the summary line. */
details.sc-collapse > summary { cursor: pointer; list-style: none; }
details.sc-collapse > summary::-webkit-details-marker { display: none; }
details.sc-collapse:not([open]) > summary { border-bottom: 0; }
.sc-collapse-label { font-size: 12px; color: var(--sc-accent); white-space: nowrap; }
.sc-collapse-label::after { content: " ▾"; }
details.sc-collapse[open] .sc-collapse-label { font-size: 0; }
details.sc-collapse[open] .sc-collapse-label::after { content: "Hide scores ▴"; font-size: 12px; }
details.sc-collapse > summary .card-title { white-space: nowrap; }

/* What a run printed. Themed explicitly: the framework's own <pre> is dark in both themes,
   which made this unreadable in light mode. */
.sc-run-output {
  margin: 0;
  white-space: pre-wrap;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--sc-text-dim);
  background: var(--sc-chip);
  border: 1px solid var(--sc-line);
  border-radius: 8px;
  padding: 8px 10px;
  max-height: 220px;
  overflow: auto;
}

/* Agent settings: one collapsible card per language. The header (name and switches) stays
   visible; the settings fold under a one-line summary of what matters at a glance. */
.sc-lang > .sc-lang-summary {
  list-style: none;
  cursor: pointer;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom-color: transparent;
  user-select: none;
}
.sc-lang > .sc-lang-summary::-webkit-details-marker { display: none; }
.sc-lang > .sc-lang-summary:hover { background: var(--tblr-bg-surface-secondary, rgba(0,0,0,.02)); }
.sc-lang[open] > .sc-lang-summary { border-bottom-color: var(--tblr-border-color, rgba(0,0,0,.08)); }
.sc-lang-glance { font-size: 12.5px; }
.sc-lang[open] .sc-lang-glance { display: none; }
.sc-lang-chevron { transition: transform .15s ease; }
.sc-lang[open] .sc-lang-chevron { transform: rotate(90deg); }

/* Genres as chips (Agent settings): a field that holds removable values and a box to type more. */
.sc-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; height: auto; min-height: 38px; cursor: text; }
.sc-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px 2px 10px; border-radius: 999px; font-size: 12.5px;
  background: var(--tblr-primary-lt, rgba(32,107,196,.1)); color: var(--tblr-primary, #206bc4);
}
.sc-chip-x {
  border: 0; background: none; color: inherit; line-height: 1; font-size: 15px;
  padding: 0 4px; border-radius: 999px; cursor: pointer; opacity: .7;
}
.sc-chip-x:hover { opacity: 1; background: rgba(0,0,0,.06); }
.sc-chips-entry { border: 0; outline: 0; flex: 1; min-width: 120px; background: transparent; color: inherit; font-size: 13px; }

/* The unit beside a number field (":00", "hours", "$"). The theme's grey measured 3.39:1 on the
   dark field, under the 4.5:1 small text needs; the dim text colour meets it. */
.input-group-text { color: var(--sc-text-dim); }
