/* ==========================================================================
   Integrader — site-wide stylesheet (single source of truth for the shell)
   Derived from the builder/workspace look. Page-specific content styles are
   being migrated in gradually; this file owns the global shell:
   design tokens, the three-section banner, nav, buttons, cards, and flashes.
   ========================================================================== */

:root {
  /* surfaces & ink */
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #1e2530;
  --ink-soft: #2b3441;
  --muted: #7b8593;
  --muted-2: #8a929e;
  --line: #e2e6ec;
  --line-strong: #dfe3ea;

  /* dark banner */
  --header-bg: #1e2530;
  --header-ink: #f1f5f9;
  --header-muted: #aeb7c4;
  --header-sep: #3a4453;

  /* accents */
  --accent: #2563eb;
  --accent-hover: #1d54cf;
  --accent-blue: #3f78d6;
  --accent-teal: #0c8599;
  --amber: #f0b429;
  --green: #128a54;
  --green-soft: #5fd39a;
  --danger: #c0392b;

  /* shape & type */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-pill: 999px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, Menlo, Monaco, monospace;
  --shadow: 0 4px 14px rgba(0, 0, 0, .08);
}

/* --- base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); }

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: #8aa8e6;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c7cdd6; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* --- app layout ------------------------------------------------------------ */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.site-main { flex: 1; padding: 24px; }
.container { max-width: 1100px; margin: 0 auto; }
.muted { color: var(--muted); }

/* ==========================================================================
   Three-section top banner: left (page info) · middle (nav) · right (status)
   ========================================================================== */
.site-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 9px 18px;
  background: var(--header-bg);
  color: var(--header-ink);
  flex: 0 0 auto;
}
/* Left and right are equal-width (flex:1) so the middle nav is centered on the
   PAGE, not just within the leftover space. min-width:0 keeps the two sides
   exactly equal even when one has more content than the other. */
.site-banner__left  { flex: 1 1 0; min-width: 0; overflow: hidden;
                      display: flex; align-items: center; gap: 12px; justify-content: flex-start; }
.site-banner__nav   { flex: 0 0 auto;
                      display: flex; align-items: center; gap: 18px; justify-content: center; }
.site-banner__right { flex: 1 1 0; min-width: 0;
                      display: flex; align-items: center; gap: 12px; justify-content: flex-end; }

/* left: page info */
.site-title {
  font-weight: 700; font-size: 14px; letter-spacing: -.01em;
  white-space: nowrap; color: var(--header-ink);
}
.site-sep { width: 1px; height: 18px; background: var(--header-sep); }
.site-crumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--header-muted); min-width: 0; overflow: hidden;
}
.site-crumb .slash { color: #5b6675; }
.site-crumb .active {
  color: var(--header-ink); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* middle: nav links (rendered by the topnav macro) */
.topnav__link {
  color: var(--header-muted); font-size: 12.5px; font-weight: 500; text-decoration: none;
}
.topnav__link:hover { color: #fff; text-decoration: none; }
.topnav__link.is-active { color: #fff; font-weight: 600; }

/* right: status/notifications helpers (block content is per page) */
.header-link {
  color: var(--header-muted); font-size: 12.5px; font-weight: 500; text-decoration: none;
}
.header-link:hover { color: #fff; text-decoration: none; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; padding: 5px 11px; border-radius: var(--radius-pill);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.badge--amber { color: var(--amber);      background: rgba(240, 180, 41, .14); }
.badge--amber .dot { background: var(--amber); }
.badge--green { color: var(--green-soft);  background: rgba(31, 138, 91, .18); }
.badge--green .dot { background: var(--green-soft); }
.badge--muted { color: var(--header-muted); background: rgba(255, 255, 255, .06); }
.badge--muted .dot { background: var(--header-muted); }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  border: none; padding: 9px 14px; font-size: 13px; font-weight: 600;
  border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center;
  gap: 8px; text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #f4f6f9; color: var(--ink-soft); border: 1px solid var(--line-strong); }
.btn-finalize { background: var(--green); color: #fff; }
.btn-danger   { background: #fff; color: var(--danger); border: 1px solid #f0c9c4; }
.btn-mini {
  background: #f4f6f9; color: #5b6675; border: 1px solid var(--line-strong);
  padding: 5px 11px; font-size: 12px; font-weight: 600; border-radius: 6px; cursor: pointer;
}

/* ==========================================================================
   Cards & panes
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.card__title { margin: 0 0 8px; font-size: 20px; font-weight: 700; }
.pane-head {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin: 2px 0 8px;
}

/* ==========================================================================
   Flash messages (styled home for Flask flashes)
   ========================================================================== */
.flash-area { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px; border: 1px solid;
}
.flash--success                { background: #e9f8f0; border-color: #bfe6cf; color: #166b43; }
.flash--danger, .flash--error  { background: #fdecea; border-color: #f2c1bb; color: #a5342a; }
.flash--warning                { background: #fff6e6; border-color: #f3d79b; color: #8a5a12; }
.flash--info, .flash--message  { background: #eaf1fd; border-color: #cfe0fb; color: #1d54cf; }

/* ==========================================================================
   Toast (optional, for AJAX pages)
   ========================================================================== */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 13px; padding: 10px 16px;
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; }

/* ==========================================================================
   Forms (shared)
   ========================================================================== */
.form-group { margin-bottom: 14px; }
.form-group label,
label.field { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group input[type=number],
.form-group textarea,
.form-group select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
  background: #fff; color: var(--ink);
}
.button {
  display: block; width: 100%; padding: 10px 14px; background: var(--accent);
  color: #fff; border: none; border-radius: 7px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: center; text-decoration: none;
}
.button:hover { background: var(--accent-hover); text-decoration: none; }
.links { text-align: center; margin-top: 14px; font-size: 13.5px; }
.links p { margin: 6px 0; }

/* narrow centered card for auth / login-style forms */
.auth-wrap { max-width: 460px; margin: 24px auto; }
.auth-wrap h1 { text-align: center; font-size: 22px; margin: 0 0 18px; }

/* two-or-more inputs on one row */
.form-row { display: flex; flex-wrap: wrap; gap: 0 16px; }
.form-row .form-group { flex: 1 1 200px; }

/* ==========================================================================
   Tables, status pills, extra button variants (shared content components)
   ========================================================================== */
.btn-success { background: #1f8a5b; color: #fff; }
.btn-warning { background: #e0982b; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.table thead th { background: #f2f4f7; font-weight: 700; }
.table-responsive { overflow-x: auto; }

.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill); color: #fff; }
.pill-success { background: #1f8a5b; }
.pill-danger  { background: var(--danger); }
.pill-info    { background: #3f78d6; }
.pill-warning { background: #e0982b; }
.pill-muted   { background: #9aa2ad; }

/* ==========================================================================
   Layout + Bootstrap-compatible utilities used across content pages, so pages
   migrate with little or no page-specific CSS. (No Bootstrap is loaded.)
   ========================================================================== */
.container-fluid { width: 100%; }
/* 12-column grid (Bootstrap-compatible: gutters via padding, not gap) */
.row { display: flex; flex-wrap: wrap; margin-left: -8px; margin-right: -8px; }
.row > [class*="col-md-"] { padding-left: 8px; padding-right: 8px; box-sizing: border-box; min-width: 0; }
.col-md-1  { flex: 0 0 8.3333%;  max-width: 8.3333%; }
.col-md-2  { flex: 0 0 16.6667%; max-width: 16.6667%; }
.col-md-3  { flex: 0 0 25%;      max-width: 25%; }
.col-md-4  { flex: 0 0 33.3333%; max-width: 33.3333%; }
.col-md-6  { flex: 0 0 50%;      max-width: 50%; }
.col-md-12 { flex: 0 0 100%;     max-width: 100%; }
@media (max-width: 768px) {
  .row > [class*="col-md-"] { flex: 0 0 100%; max-width: 100%; }
}
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: #1f8a5b; }
.text-white { color: #fff; }
.sticky-top { position: sticky; top: 0; z-index: 1; }

.mb-1 { margin-bottom: .25rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

/* Bootstrap-style form controls (some pages use these instead of .form-group) */
.form-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.form-control, .form-select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
.form-control-plaintext { width: 100%; border: none; background: transparent; padding: 6px 4px; }
.form-text { font-size: 12px; color: var(--muted); }

/* card sub-parts + colored cards */
.card-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.card-header { margin: -24px -24px 16px; padding: 12px 24px; border-bottom: 1px solid var(--line); font-weight: 700; }
.card.bg-success   { background: #1f8a5b;      border-color: #1f8a5b; }
.card.bg-danger    { background: var(--danger); border-color: var(--danger); }
.card.bg-secondary { background: #9aa2ad;      border-color: #9aa2ad; }

/* alerts */
.alert { padding: 10px 14px; border-radius: var(--radius); border: 1px solid; margin-bottom: 12px; }
.alert-info    { background: #eaf1fd; border-color: #cfe0fb; color: #1d54cf; }
.alert-success { background: #e9f8f0; border-color: #bfe6cf; color: #166b43; }
.alert-warning { background: #fff6e6; border-color: #f3d79b; color: #8a5a12; }
.alert-danger  { background: #fdecea; border-color: #f2c1bb; color: #a5342a; }

/* badge background variants (Bootstrap bg-* used in dynamic JS) */
.badge.bg-success, .badge.bg-danger, .badge.bg-warning, .badge.bg-secondary, .badge.bg-info { color: #fff; }
.badge.bg-success   { background: #1f8a5b; }
.badge.bg-danger    { background: var(--danger); }
.badge.bg-warning   { background: #e0982b; }
.badge.bg-secondary { background: #9aa2ad; }
.badge.bg-info      { background: #3f78d6; }

/* progress bar */
.progress { background: #e2e6ec; border-radius: 6px; overflow: hidden; height: 20px; }
.progress-bar {
  background: var(--accent); color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 600; height: 100%; transition: width .3s ease;
}

/* table variants */
.table-sm th, .table-sm td { padding: 5px 7px; }
.table-striped tbody tr:nth-child(odd) { background: #fafbfc; }
thead.table-dark th, .table-dark thead th { background: #2b3441; color: #fff; border-color: #3a4453; }
.btn-lg { padding: 11px 18px; font-size: 15px; }

/* additional utilities used by grading pages */
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: .5rem; }
.p-2 { padding: .5rem; }
.w-100 { width: 100%; }
.form-control-sm { padding: 5px 8px; font-size: 13px; }
.badge.bg-primary { background: var(--accent); color: #fff; }
.table-hover tbody tr:hover { background: #f2f6ff; }
.table-light thead th, thead.table-light th { background: #f2f4f7; color: var(--ink); }

/* ==========================================================================
   Exam timeline (main/timeline.html) — lifecycle overview on a shared time
   axis. Ported from the Claude Design "3a · Timeline" prototype onto site
   tokens. v1 renders every task in a neutral state; status colours arrive
   with live progress stats.
   ========================================================================== */
.tl-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin: 4px 0 16px;
}
.tl-header__title { font-size: 20px; margin: 0 0 4px; }
.tl-header__sub { font-size: 13px; color: var(--muted); margin: 0; max-width: 560px; }

/* exam selector (upper-right, below the banner) */
.tl-exam-select { display: flex; align-items: center; gap: 8px; }
.tl-exam-select label { font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); }
.tl-exam-select select {
  padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px; background: #fff; color: var(--ink);
  min-width: 220px; max-width: 340px;
}

.tl-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}

/* horizontal scroll only kicks in on very narrow screens */
.tl-wrap { padding: 16px 16px 20px; overflow-x: auto; }
.tl-grid {
  min-width: 860px; display: grid;
  grid-template-columns: repeat(9, minmax(90px, 1fr));
  gap: 10px 7px; align-items: stretch;
}

/* phase bands (row 1) */
.tl-band {
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  text-align: center; padding: 6px; border-radius: 7px;
}
.tl-band--before { background: #eef4ff; color: var(--accent); }
.tl-band--exam   { background: #fdf3e2; color: #b9741a; }
.tl-band--after  { background: #f1f4f8; color: #5b6675; }

/* task cards */
.tl-node {
  background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 10px;
}
.tl-node--muted { background: #fbfcfd; border: 1px dashed #cfd6df; }
.tl-node--muted .tl-title { color: #5b6675; }

.tl-node__head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px;
}
.tl-num {
  width: 20px; height: 20px; border-radius: 50%;
  background: #9aa2ad; color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex: 0 0 20px;
}
.tl-pill {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill);
  white-space: nowrap;
}
.tl-pill--neutral, .tl-pill--locked { color: #9aa2ad; background: #eef1f5; }
.tl-pill--done     { color: #1f8a5b; background: rgba(31, 138, 91, .12); }
.tl-pill--progress { color: #2563eb; background: rgba(63, 120, 214, .12); }
.tl-pill--ready    { color: #b9741a; background: rgba(224, 152, 43, .15); }
/* allow a long descriptive pill (e.g. the questions box) to wrap */
.tl-pill--wrap { white-space: normal; text-align: right; }

.tl-title { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
/* the box heading doubles as the link to the task's page */
a.tl-title--link { display: block; color: var(--accent); text-decoration: none; }
a.tl-title--link:hover { text-decoration: underline; }
/* headings with several inline links (e.g. the grading box) */
.tl-title--multi { color: var(--ink); }
.tl-title--multi a { color: var(--accent); text-decoration: none; }
.tl-title--multi a:hover { text-decoration: underline; }

/* inline on/off toggle switch (dashboard grade box: turn grading on) */
.tl-switch { position: relative; display: inline-block; width: 32px; height: 17px; vertical-align: middle; }
.tl-switch input { opacity: 0; width: 0; height: 0; margin: 0; }
.tl-switch__slider { position: absolute; inset: 0; cursor: pointer; background: #c7cdd6; border-radius: 999px; transition: background .15s ease; }
.tl-switch__slider::before { content: ""; position: absolute; height: 13px; width: 13px; left: 2px; top: 2px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s ease; }
.tl-switch input:checked + .tl-switch__slider { background: var(--green); }
.tl-switch input:checked + .tl-switch__slider::before { transform: translateX(15px); }
.tl-switch input:disabled + .tl-switch__slider { opacity: .6; cursor: default; }
.tl-switch__label { font-size: 12.5px; font-weight: 600; }

.tl-track {
  height: 6px; background: #e2e6ec; border-radius: 4px; overflow: hidden; margin: 9px 0 0;
}
.tl-fill { height: 100%; background: #9aa2ad; }
.tl-fill--neutral, .tl-fill--locked { background: #9aa2ad; }
.tl-fill--done     { background: #1f8a5b; }
.tl-fill--progress { background: #3f78d6; }
.tl-fill--ready    { background: #e0982b; }

/* legend footer */
.tl-legend {
  display: flex; gap: 18px; flex-wrap: wrap;
  padding: 14px 26px 22px; border-top: 1px solid #eef1f5;
  font-size: 12px; color: var(--muted);
}
.tl-legend span { display: flex; align-items: center; gap: 6px; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
