/* SlideConvert — pharmtrace design system */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; }

:root {
  --brand: #c0392b;
  --brand-dark: #9b2821;
  --brand-light: #fdecea;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --green: #16a34a; --green-bg: #f0fdf4; --green-border: #bbf7d0;
  --orange: #ea580c; --orange-bg: #fff7ed; --orange-border: #fed7aa;
  --red: #dc2626;   --red-bg: #fef2f2;   --red-border: #fecaca;
  --blue: #2563eb;  --blue-bg: #eff6ff;  --blue-border: #bfdbfe;
  --sidebar-w: 220px;
  --topbar-h: 52px;
}

html, body { margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  /*
   * No align-items and no height here, on purpose. The default align-items: stretch is what
   * takes the sidebar down the whole page rather than the first viewport of it; a height on
   * body would give this flex container a definite cross size, which caps the flex line at
   * one viewport and strands the sidebar again.
   */
}

/* ── Sidebar ── */
/* Stretched by the body's flex row to the full height of the page, so it carries nothing but
   the grey column and its border. Its floor comes from .app-body's min-height. */
.app-sidebar {
  width: var(--sidebar-w);
  background: #e2e8f0;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
/* The part that stays in view: pinned to the top as the page scrolls, and capped at one
   viewport so a window shorter than the nav can still scroll down to its last link. */
.sidebar-inner { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
.sidebar-logo {
  padding: 18px 18px 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo img { height: 26px; width: auto; }
.sidebar-nav { padding: 10px 0; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all .12s;
}
.nav-link:hover { background: rgba(0,0,0,.04); color: var(--text); }
.nav-link.active { background: var(--accent-light); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.nav-link .bi { font-size: 14px; }
.sidebar-section {
  padding: 14px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ── App body ── */
.app-body { flex: 1; min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }

/* ── Topbar ── */
.app-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-user { font-size: 13px; font-weight: 500; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.role-chip {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-2);
}
.signout-form { margin: 0; }
.signout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .12s;
}
.signout-btn:hover { border-color: var(--red); color: var(--red); }

/* ── Page wrap ── */
.page-wrap { max-width: 1280px; margin: 0 auto; padding: 28px 32px; flex: 1; }
/* Opted into per page via {% block page_wrap_class %} for wide tables. */
.wide-page-wrap { max-width: 1600px; }

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.3px; margin: 0; }
.page-subtitle { font-size: 13.5px; color: var(--text-2); margin: 2px 0 0; }

/* ── Flash messages ── */
.flash-list { margin: 0; padding: 0; list-style: none; }
.flash {
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 500;
  border-bottom: 1px solid;
  display: flex;
  align-items: center;
  gap: 8px;
}
.flash-success { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.flash-danger   { background: var(--red-bg);   color: var(--red);   border-color: var(--red-border); }
.flash-warning  { background: var(--orange-bg); color: var(--orange); border-color: var(--orange-border); }
.flash-info     { background: var(--blue-bg);  color: var(--blue);  border-color: var(--blue-border); }

/* ── Cards ── */
.sc-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.sc-card-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 600;
}
.sc-card-body { padding: 18px 20px; }
/* A narrow card holding a single form. */
.sc-card-narrow { max-width: 32rem; }
/* The head of a card reporting a failure. */
.sc-card-head-danger { background: var(--red-bg); color: var(--red); }

/*
 * Cards laid out side by side in a grid. The grid's gap does the spacing, so each
 * card's own bottom margin would double it -- hence the reset on the children.
 */
.sc-card-grid { display: grid; gap: 20px; }
.sc-card-grid > .sc-card { margin-bottom: 0; }
/* Paired cards stretch to their row's height, so the two columns end level. */
.sc-card-grid-2 { grid-template-columns: 1fr 1fr; }
/* A main column beside a narrow informational rail, which keeps its own height. */
.sc-card-grid-aside { grid-template-columns: 1fr 300px; align-items: start; }
/* A card spanning every column of the grid it sits in. */
.sc-card-grid-full { grid-column: 1 / -1; }

/* ── Tables ── */
.sc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.sc-table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  white-space: nowrap;
}
.sc-table tbody td { padding: 11px 10px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.sc-table tbody:last-child tr:last-child td { border-bottom: none; }
.sc-table tbody tr:hover { background: var(--surface-2); }
.sc-table-wrap { overflow-x: auto; }
/* A table below a card body needs the rule a card head would have drawn. */
.sc-card-body + .sc-table-wrap { border-top: 1px solid var(--border); }
/* Two related values stacked in one cell, so a wide table needs fewer columns. */
.sc-cell-stack { display: flex; flex-direction: column; gap: 2px; line-height: 1.35; }

/*
 * A list whose records are two rows -- a summary line and a detail line -- with each
 * pair grouped in its own <tbody>. The rule then falls under the pair rather than
 * between its halves, and hovering either half lights the whole record. Grouping is
 * what gives us the second one: CSS has no previous-sibling selector, so a plain
 * tr:hover could never reach back from the detail line to the summary line above it.
 * Bordering a <tbody> needs border-collapse: collapse, which .sc-table already sets.
 */
.sc-table-grouped tbody { border-bottom: 1px solid var(--border); }
.sc-table-grouped tbody:last-child { border-bottom: none; }
.sc-table-grouped tbody td { border-bottom: none; }
.sc-table-grouped tbody tr:hover { background: none; }
.sc-table-grouped tbody:hover { background: var(--surface-2); }
.sc-table-grouped .sc-row-detail td { padding-top: 0; }
/* The detail line stacks its labelled values one per line, so a long comment
   lengthens the row instead of running on beside the location. */
.sc-detail-item { display: block; color: var(--text-3); font-size: 12.5px; }
.sc-detail-item + .sc-detail-item { margin-top: 3px; }
.sc-detail-label { font-weight: 600; color: var(--text-2); margin-right: 6px; }

/* ── Buttons ── */
.sc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.sc-btn-sm { font-size: 12px; padding: 5px 11px; border-radius: 6px; }
.sc-btn-xs { font-size: 11px; padding: 3px 8px; border-radius: 5px; }
.sc-btn-primary { background: var(--accent); color: white; }
.sc-btn-primary:hover { background: #1d4ed8; color: white; }
.sc-btn-ghost { background: white; color: var(--text-2); border: 1px solid var(--border); }
.sc-btn-ghost:hover { background: var(--bg); color: var(--text); border-color: var(--border-strong); }
.sc-btn-danger { background: var(--red); color: white; }
.sc-btn-danger:hover { background: #b91c1c; color: white; }
.sc-btn-success { background: var(--green); color: white; }
.sc-btn-success:hover { background: #15803d; color: white; }
.sc-btn-warning { background: var(--orange); color: white; }
.sc-btn-warning:hover { background: #c2410c; color: white; }
.sc-btn-upload { background: var(--accent-light); color: var(--accent); border: 1px solid var(--blue-border); }
.sc-btn-upload:hover { background: var(--accent); color: white; }
/* A button filling its container; .sc-btn is inline-flex, so its content needs centring. */
.sc-btn-block { width: 100%; justify-content: center; }

/* ── Badges ── */
.sc-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
  white-space: nowrap;
}
.sc-badge-green  { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green-border); }
.sc-badge-orange { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange-border); }
.sc-badge-red    { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-border); }
.sc-badge-blue   { background: var(--blue-bg);   color: var(--blue);   border: 1px solid var(--blue-border); }
.sc-badge-grey   { background: var(--bg);        color: var(--text-2); border: 1px solid var(--border); }
.sc-badge-brand  { background: var(--brand-light); color: var(--brand); border: 1px solid #f5c0b8; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.stat-icon { font-size: 24px; }
.stat-num { font-size: 32px; font-weight: 700; line-height: 1; }
.stat-lbl { font-size: 12.5px; color: var(--text-2); }

/* ── Form inputs ── */
.sc-input {
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  background: white;
  color: var(--text);
  width: 100%;
  transition: border .12s, box-shadow .12s;
}
.sc-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.sc-input::placeholder { color: var(--text-3); }
.sc-label { font-size: 12px; font-weight: 600; color: var(--text-2); display: block; margin-bottom: 5px; letter-spacing: .01em; }

/* ── Misc ── */
.text-muted-sc { color: var(--text-3); font-size: 13px; }
.empty-state { padding: 48px 20px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.empty-state .bi { font-size: 2.5rem; display: block; margin-bottom: 12px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.fallback-warning { background: var(--orange-bg); border: 1px solid var(--orange-border); border-radius: 8px; padding: 12px 16px; font-size: 13px; color: var(--orange); margin-bottom: 16px; }
.error-block { background: var(--red-bg); border: 1px solid var(--red-border); border-radius: 8px; padding: 16px 20px; margin-top: 16px; }
.success-block { background: var(--green-bg); border: 1px solid var(--green-border); border-radius: 8px; padding: 16px 20px; margin-top: 16px; }
/* The informational sibling of .fallback-warning: a panel, not a badge. */
.info-block { background: var(--blue-bg); border: 1px solid var(--blue-border); border-radius: 8px; padding: 12px 16px; font-size: 13px; color: var(--blue); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
/* The upload form's per-slide outcome log: one .success-block or .error-block per
   finished upload, most recent first, each listing one <li> per file. */
.upload-results { margin-top: 4px; }
.result-head { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.result-meta { color: var(--text-2); font-size: 12.5px; margin-top: 6px; }
/* Reboot's own ul margin would double up on the block's spacing, so set all four. */
.result-files { font-family: 'SF Mono','Fira Code',monospace; font-size: 12px; color: var(--text-2); margin: 4px 0 0; padding-left: 18px; list-style: disc; word-break: break-all; }
.result-files-summary { color: var(--text-2); font-size: 12.5px; margin-top: 4px; }
.log-pre { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 8px; font-size: 12px; font-family: 'SF Mono','Fira Code',monospace; max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; margin-top: 10px; }
.dl-grid { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 13.5px; margin-bottom: 0; }
/* Most pages build the grid from divs and spans, but viewer.html uses real
   <dl>/<dt>/<dd>, and Bootstrap Reboot gives those margins that double up on the gap. */
.dl-grid dt, .dl-grid dd { margin: 0; }
.dl-label { font-weight: 600; color: var(--text-2); }
.dl-value { color: var(--text); }
/* A value typed into a textarea can carry newlines worth keeping -- a property of the
   data, so it belongs here rather than at each render site. */
.dl-value-wrap { white-space: pre-wrap; }

/* ── Signed-out pages ── */
/*
 * Sign-in, and any error reached before signing in. There is no sidebar to anchor the
 * page, so the panel is centred in the viewport and the wordmark stands in for the
 * chrome. body already carries the background and display:flex.
 */
body.auth-body { align-items: center; justify-content: center; min-height: 100vh; padding: 24px 16px; }
.auth-panel { width: 100%; max-width: 380px; }
/* Wider, for pages carrying a message rather than a form. */
.auth-panel-wide { max-width: 600px; }
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand img { height: 32px; width: auto; margin-bottom: 16px; }
.auth-brand-name { font-size: 20px; font-weight: 700; margin: 0 0 4px; }

/* A full-page single-message card: errors, and the pending-assignment page. */
.notice-card { max-width: 600px; }
.notice-card .sc-card-body { padding: 32px 28px; text-align: center; }
.notice-icon { font-size: 48px; color: var(--brand); display: block; margin-bottom: 20px; }
.notice-title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.notice-text { font-size: 14px; color: var(--text-3); line-height: 1.6; }

/* One rule of the password-strength hint, built as markup by the script in base.html. */
.pw-rule { display: block; font-size: 12px; }
.pw-ok { color: var(--green); }
.pw-fail { color: var(--red); }

/* ── Viewer page layout ── */
/*
 * .viewer-page-wrap is injected via {% block page_wrap_class %} in viewer.html.
 * It overrides the default page-wrap max-width/padding so the canvas fills
 * the full app-body width.  All other rules live in viewer.html <style> so
 * they are only loaded on viewer pages.
 */
.viewer-page-wrap {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: row !important;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* ── Bootstrap overrides — keep modals/tooltips working ── */
.modal-content { border-radius: 12px; border: 1px solid var(--border); }
.modal-header { background: var(--surface-2); border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; }
.modal-footer { border-top: 1px solid var(--border); }
.form-control, .form-select { font-size: 13.5px; border-color: var(--border); border-radius: 7px; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.tooltip-inner { font-size: 12px; }
/*
 * Bootstrap's semantic text colours sit off our palette -- its muted is a warm
 * rgba(33,37,41,.75), its danger #dc3545. Point them at the tokens, so muted text is
 * one colour everywhere and a template never needs a colour of its own.
 */
.text-muted { color: var(--text-3) !important; }
.text-danger { color: var(--red) !important; }
.text-success { color: var(--green) !important; }
.text-warning { color: var(--orange) !important; }
.text-primary { color: var(--accent) !important; }
/* The brand red has no Bootstrap counterpart. */
.text-brand { color: var(--brand) !important; }
/* Form help text keeps Bootstrap's .875em and .25rem top margin, and takes our colour. */
.form-text { color: var(--text-3); }
