/* ==========================================================================
   CdLHub UI layer · v1 (2026-10-10)
   Scope: instructor shell (body.teacher-body) + Assignments pages.
   Loaded AFTER style.css and assignments-scope.css. Rollback: remove the
   <link> to this file. Nothing here changes markup, routes, or behaviour.
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
body.teacher-body {
  --ui-ink: #102a23;
  --ui-text: #23332e;
  --ui-muted: #5d6d68;
  --ui-line: #e2e8e5;
  --ui-line-strong: #c9d4cf;
  --ui-surface: #ffffff;
  --ui-canvas: #f3f6f5;
  --ui-brand: #0f5c4c;
  --ui-brand-strong: #0b4a3d;
  --ui-brand-soft: #e5f2ed;
  --ui-accent: #f2c230;
  --ui-focus: 0 0 0 3px rgba(15, 92, 76, .28);
  --ui-radius-sm: 8px;
  --ui-radius: 10px;
  --ui-radius-lg: 12px;
  --ui-shadow: 0 1px 2px rgba(16, 42, 35, .06);
  --ui-shadow-hover: 0 6px 16px rgba(16, 42, 35, .08);
  --ui-fs-title: 22px;   /* page title */
  --ui-fs-h2: 17px;      /* section heading */
  --ui-fs-card: 15px;    /* card title */
  --ui-fs-body: 14px;
  --ui-fs-meta: 12.5px;
  --ui-fs-label: 11px;
  background: var(--ui-canvas);
}

/* ---------- 2. Shared shell: sidebar ---------- */
@media (min-width: 961px) {
  body.teacher-body .teacher-sidebar { width: 232px; padding: 6px 12px 12px; gap: 6px; }
  body.teacher-body .teacher-main { margin-left: 232px; }
}
body.teacher-body .teacher-brand-logo { height: 96px; }
body.teacher-body .teacher-brand { margin-bottom: 0; transform: none; }
body.teacher-body .teacher-brand p { font-size: 10.5px; letter-spacing: .1em; margin: 2px 0 4px; }
body.teacher-body .teacher-sidebar-nav { gap: 2px; }
body.teacher-body .teacher-nav-link {
  min-height: 40px; padding: 6px 10px; gap: 10px; border-radius: var(--ui-radius-sm);
  font-size: 13.5px; font-weight: 600; line-height: 1.25;
}
body.teacher-body .teacher-nav-link:hover {
  background: rgba(255, 255, 255, .08); transform: none; box-shadow: none;
}
body.teacher-body .teacher-nav-link.is-active,
body.teacher-body .teacher-nav-link.is-active:hover {
  background: rgba(255, 255, 255, .16); transform: none;
  box-shadow: inset 3px 0 0 var(--ui-accent);
}
body.teacher-body .teacher-nav-link:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
@media (max-width: 960px) { body.teacher-body .teacher-nav-link { min-height: 44px; } } /* touch target in the phone drawer */
body.teacher-body .teacher-nav-icon { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 7px; }
body.teacher-body .teacher-nav-icon svg { width: 16px; height: 16px; }
body.teacher-body .teacher-sidebar-footer { margin-top: 4px; padding-top: 8px; }

/* ---------- 3. Shared shell: top bar ---------- */
/* Desktop only: on phones style.css pairs the sticky top bar's negative margins with the
   main padding, so those two values are left alone below 961px. */
@media (min-width: 961px) {
  body.teacher-body .teacher-main { padding: 12px 20px 88px; }
  body.teacher-body .teacher-topbar { min-height: 48px; margin-bottom: 12px; padding: 0; }
}
@media (max-width: 960px) {
  body.teacher-body .teacher-main { padding-bottom: 84px; }
  body.teacher-body .teacher-topbar { background: rgba(243, 246, 245, .96); }
}
body.teacher-body .teacher-topbar-label { margin: 0 0 2px; font-size: var(--ui-fs-label); letter-spacing: .08em; }
body.teacher-body .teacher-topbar h2 {
  font-size: var(--ui-fs-title); line-height: 1.2; color: var(--ui-ink); letter-spacing: -.01em;
}
body.teacher-body .teacher-topbar-actions { gap: 8px; }
body.teacher-body .teacher-icon-btn {
  width: 40px; height: 40px; padding: 0; border-radius: var(--ui-radius);
  border-color: var(--ui-line); box-shadow: none;
}
body.teacher-body .teacher-profile-link {
  gap: 8px; padding: 4px 10px 4px 4px; border-radius: var(--ui-radius-lg);
  background: var(--ui-surface); border: 1px solid var(--ui-line); box-shadow: none;
}
body.teacher-body .teacher-profile-link .profile-avatar { width: 32px; height: 32px; font-size: 13px; }
body.teacher-body .teacher-profile-copy strong { font-size: 13px; }
body.teacher-body .teacher-profile-copy span { font-size: 11.5px; }
@media (max-width: 768px) {
  body.teacher-body .teacher-topbar h2 { font-size: 20px; }
}

/* Floating faculty chat: smaller, and the page keeps 88px of bottom room so it never covers row actions */
body.teacher-body .staff-chat-toggle {
  min-width: 0; padding: 8px 14px; font-size: 13px; box-shadow: 0 4px 12px rgba(9, 58, 43, .18);
}

/* ---------- 4. Assignments + Quizzes · page header (was the gradient hero) ---------- */
body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) {
  grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  margin-bottom: 12px; padding: 12px 16px;
  background: var(--ui-surface); color: var(--ui-text);
  border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); box-shadow: var(--ui-shadow);
}
body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner)::after { display: none; }
body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) :is(h2, h3, p, .eyebrow, .muted) { color: inherit; }
body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) .eyebrow {
  margin: 0 0 2px; font-size: var(--ui-fs-label); letter-spacing: .08em; color: var(--ui-brand);
}
body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) .page-title {
  margin: 0; font-size: var(--ui-fs-h2); line-height: 1.3; color: var(--ui-ink);
}
body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) p:not(.eyebrow) { margin: 2px 0 0; font-size: 13px; color: var(--ui-muted); }
body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) .actions { width: auto; justify-self: end; margin: 0; }
body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) .btn {
  display: inline-flex; align-items: center; justify-content: center; line-height: 1.2;
  min-height: 36px; margin: 0; padding: 0 14px; border-radius: var(--ui-radius-sm);
  font-size: 13px; background: var(--ui-brand); border-color: var(--ui-brand); color: #fff; box-shadow: none;
}
body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) .btn:hover { background: var(--ui-brand-strong); }
body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) .btn:focus-visible { outline: none; box-shadow: var(--ui-focus); }
/* On the course-picker page the title repeats the top bar, so show only the purpose line + action */
body.teacher-body .teacher-container:has(.asg-grid) :is(.assignments-hero-banner, .quizzes-hero-banner) :is(.page-title, .eyebrow) { display: none; }
@media (max-width: 640px) {
  body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) { grid-template-columns: 1fr; }
  body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) .actions { justify-self: stretch; }
  body.teacher-body :is(.assignments-hero-banner, .quizzes-hero-banner) .btn { width: 100%; min-height: 44px; }
}

/* ---------- 5. Assignments · course picker ---------- */
body.teacher-body .asg-wrap {
  padding: 16px; border-radius: var(--ui-radius-lg); box-shadow: var(--ui-shadow); border-color: var(--ui-line);
}
body.teacher-body .asg-wrap:has(> .asg-grid) { padding: 0; background: none; border: 0; box-shadow: none; }
body.teacher-body .asg-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
body.teacher-body .asg-course {
  gap: 2px; padding: 12px 14px; border-radius: var(--ui-radius-lg); border-top-width: 3px;
  border-color: var(--ui-line); border-top-color: var(--ui-brand); box-shadow: var(--ui-shadow);
}
body.teacher-body .asg-course:hover { transform: translateY(-1px); border-color: var(--ui-line-strong); border-top-color: var(--ui-brand); box-shadow: var(--ui-shadow-hover); }
body.teacher-body .asg-course:focus-visible { box-shadow: var(--ui-focus); }
body.teacher-body .asg-course__code { font-size: var(--ui-fs-label); letter-spacing: .07em; color: var(--ui-brand); }
body.teacher-body .asg-course__name { font-size: var(--ui-fs-card); line-height: 1.3; color: var(--ui-ink); }
body.teacher-body .asg-course__section { font-size: var(--ui-fs-meta); font-weight: 500; color: var(--ui-muted); }
body.teacher-body .asg-course__stats { gap: 4px; margin: 6px 0 2px; }
body.teacher-body .asg-course__foot { padding-top: 8px; font-size: var(--ui-fs-meta); color: var(--ui-text); }
body.teacher-body .asg-course__ref { font-size: var(--ui-fs-label); }
body.teacher-body .asg-pill { padding: 1px 8px; font-size: 11.5px; font-weight: 600; }
body.teacher-body .asg-label { font-size: 10.5px; }
body.teacher-body .asg-rel { font-size: 12px; }

/* ---------- 6. Assignments · course page (switcher + rows) ---------- */
body.teacher-body .asg-crumbs { margin: 0 0 8px; }
body.teacher-body .asg-back { min-height: 32px; padding: 0 10px; border-radius: var(--ui-radius-sm); font-size: 12.5px; }
body.teacher-body .asg-switch { gap: 6px; margin-bottom: 12px; padding-bottom: 4px; }
body.teacher-body .asg-switch a { padding: 5px 12px; font-size: 12.5px; }
body.teacher-body .asg-switch a[aria-current="page"] { background: var(--ui-brand); border-color: var(--ui-brand); }
body.teacher-body .asg-group { margin-bottom: 16px; }
body.teacher-body .asg-group h3 { margin: 0 0 8px; font-size: var(--ui-fs-label); }
body.teacher-body .asg-list { gap: 8px; }
body.teacher-body .asg-row { gap: 12px; padding: 10px 14px; border-radius: var(--ui-radius); border-left-width: 3px; }
body.teacher-body .asg-row__title { font-size: 14.5px; line-height: 1.35; }
body.teacher-body .asg-row__meta { margin-top: 2px; font-size: 12px; }
body.teacher-body .asg-row__due { font-size: 13px; }
body.teacher-body .asg-row__status { gap: 4px; }
body.teacher-body .asg-row__actions { gap: 6px; }
@media (min-width: 861px) {
  body.teacher-body .asg-btn { min-height: 32px; padding: 0 12px; border-radius: var(--ui-radius-sm); font-size: 12.5px; }
}
body.teacher-body .asg-btn:focus-visible { box-shadow: var(--ui-focus); }

/* ==========================================================================
   v2 (2026-10-10): course-picker hierarchy, toolbar, list view, balanced grid.
   The toolbar, summary and list view are added by cdlhub-ui.js; without the
   script, sections 7-8 simply have nothing to style.
   ========================================================================== */
body.teacher-body .asg-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
body.teacher-body .asg-course[hidden] { display: none !important; }

/* Sidebar alignment: section label lines up with the link icons */
body.teacher-body .teacher-brand-logo { height: 104px; }
body.teacher-body .teacher-brand p { padding-left: 10px; }

/* ---------- 7. Course card hierarchy ---------- */
body.teacher-body .asg-course { position: relative; gap: 2px; padding: 14px 16px 12px; }
body.teacher-body .asg-course__code { padding-right: 76px; }
body.teacher-body .asg-course__ref {
  position: absolute; top: 14px; right: 16px; font-size: var(--ui-fs-label);
  color: var(--ui-muted); font-variant-numeric: tabular-nums;
}
body.teacher-body .asg-course__name { margin-top: 2px; font-size: 15.5px; font-weight: 650; }
body.teacher-body .asg-course__foot { justify-content: flex-start; }
body.teacher-body .asg-course:not([data-due]) .asg-course__foot { color: var(--ui-muted); }
body.teacher-body .asg-course[data-due-soon] .asg-rel { color: #b45309; font-weight: 600; }
body.teacher-body .asg-pill--amber { font-weight: 700; }
/* Amber top edge = this section has submissions waiting to be graded (matches the amber pill) */
body.teacher-body .asg-course[data-grading],
body.teacher-body .asg-course[data-grading]:hover { border-top-color: #d97706; }

/* Balanced columns: the script picks the fewest rows with the fewest empty slots */
@media (min-width: 700px) {
  body.teacher-body .asg-grid[style*="--asg-cols"] {
    grid-template-columns: repeat(var(--asg-cols), minmax(0, 1fr));
    max-width: calc(var(--asg-cols) * 440px);
  }
}

/* ---------- 8. Header: summary + toolbar ---------- */
body.teacher-body .asg-summary { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--ui-text); }
body.teacher-body .asg-summary strong { color: var(--ui-ink); font-weight: 700; }
body.teacher-body .asg-summary__grade strong { color: #b45309; }
body.teacher-body .asg-summary__sep { margin: 0 8px; color: var(--ui-line-strong); }
body.teacher-body .asg-summary__muted { color: var(--ui-muted); }

body.teacher-body .asg-toolbar {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--ui-line);
}
body.teacher-body .asg-search { position: relative; flex: 1 1 240px; max-width: 360px; margin: 0; }
body.teacher-body .asg-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ui-muted); pointer-events: none; }
body.teacher-body .asg-search input {
  width: 100%; height: 34px; margin: 0; padding: 0 10px 0 32px;
  border: 1px solid var(--ui-line-strong); border-radius: var(--ui-radius-sm);
  background: var(--ui-surface); color: var(--ui-text); font: inherit; font-size: 13px; box-shadow: none;
}
body.teacher-body .asg-search input:focus { outline: none; border-color: var(--ui-brand); box-shadow: var(--ui-focus); }
body.teacher-body .asg-seg {
  display: inline-flex; border: 1px solid var(--ui-line-strong); border-radius: var(--ui-radius-sm);
  overflow: hidden; background: var(--ui-surface);
}
body.teacher-body .asg-seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 32px; min-width: 34px; margin: 0; padding: 0 12px; border: 0; border-right: 1px solid var(--ui-line);
  border-radius: 0; background: transparent; color: var(--ui-text); font: inherit; font-size: 12.5px; font-weight: 600;
  box-shadow: none; cursor: pointer; white-space: nowrap;
}
body.teacher-body .asg-seg button:last-child { border-right: 0; }
body.teacher-body .asg-seg button:hover { background: #f6f8f7; }
body.teacher-body .asg-seg button[aria-pressed="true"] { background: var(--ui-brand-soft); color: var(--ui-brand); font-weight: 700; }
body.teacher-body .asg-seg button:focus-visible { outline: none; box-shadow: inset var(--ui-focus); }
body.teacher-body .asg-view button { padding: 0 9px; }
body.teacher-body .asg-sort { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 0 auto; font-size: 12.5px; color: var(--ui-muted); }
body.teacher-body .asg-sort select {
  height: 34px; margin: 0; padding: 0 28px 0 10px; border: 1px solid var(--ui-line-strong); border-radius: var(--ui-radius-sm);
  background-color: var(--ui-surface); color: var(--ui-text); font: inherit; font-size: 13px; width: auto; box-shadow: none;
}
body.teacher-body .asg-sort select:focus { outline: none; border-color: var(--ui-brand); box-shadow: var(--ui-focus); }
body.teacher-body .asg-nomatch { margin-top: 0; }

/* ---------- 9. List view (desktop and wide tablets) ---------- */
body.teacher-body .asg-listhead { display: none; }
@media (min-width: 861px) {
  body.teacher-body { --asg-list-cols: minmax(0, 2.2fr) minmax(0, 1.4fr) minmax(0, 2.5fr) minmax(0, 1.8fr) 64px; }
  body.teacher-body .asg-listhead.is-on {
    display: grid; grid-template-columns: var(--asg-list-cols); gap: 12px; padding: 0 17px 6px 19px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ui-muted);
  }
  body.teacher-body .asg-listhead.is-on span:last-child { text-align: right; }
  body.teacher-body .asg-grid.is-list {
    display: flex; flex-direction: column; gap: 0; max-width: none;
    background: var(--ui-surface); border: 1px solid var(--ui-line); border-bottom: 0;
    border-radius: var(--ui-radius-lg); overflow: hidden; box-shadow: var(--ui-shadow);
  }
  body.teacher-body .asg-grid.is-list .asg-course {
    display: grid; grid-template-columns: var(--asg-list-cols);
    grid-template-areas: "code section stats due ref" "name section stats due ref";
    align-items: center; column-gap: 12px; row-gap: 0; padding: 10px 16px;
    border: 0; border-bottom: 1px solid var(--ui-line); border-left: 3px solid transparent;
    border-radius: 0; box-shadow: none; transform: none;
  }
  body.teacher-body .asg-grid.is-list .asg-course:hover { background: #f8faf9; box-shadow: none; transform: none; }
  body.teacher-body .asg-grid.is-list .asg-course[data-grading] { border-left-color: #d97706; }
  body.teacher-body .asg-grid.is-list .asg-course__code { grid-area: code; padding-right: 0; }
  body.teacher-body .asg-grid.is-list .asg-course__name { grid-area: name; margin: 0; font-size: 14.5px; }
  body.teacher-body .asg-grid.is-list .asg-course__section { grid-area: section; }
  body.teacher-body .asg-grid.is-list .asg-course__stats { grid-area: stats; margin: 0; }
  /* grading status first, so it never wraps out of sight */
  body.teacher-body .asg-grid.is-list .asg-course__stats :is(.asg-pill--amber, .asg-pill--green) { order: -1; }
  body.teacher-body .asg-grid.is-list .asg-course__foot { display: contents; }
  body.teacher-body .asg-grid.is-list .asg-course__foot > span:first-child { grid-area: due; font-size: var(--ui-fs-meta); }
  body.teacher-body .asg-grid.is-list .asg-course__foot .asg-label { display: none; }
  body.teacher-body .asg-grid.is-list .asg-course__ref { grid-area: ref; position: static; justify-self: end; }
}
/* Phones and small tablets: always cards; the layout switch is hidden there */
@media (max-width: 860px) {
  body.teacher-body .asg-view { display: none; }
  body.teacher-body .asg-search { flex-basis: 100%; max-width: none; }
  body.teacher-body .asg-sort { margin-left: 0; }
}

/* ==========================================================================
   v3 (2026-10-10): Quizzes scoped by course section (script builds the picker
   and the section view from the existing table; table itself is unchanged).
   ========================================================================== */
body.teacher-body .qz-panel[hidden],
body.teacher-body .qz-panel tr[hidden],
body.teacher-body .qz-panel table[hidden] { display: none !important; }

/* Compact quiz table */
body.teacher-body .qz-panel { padding: 4px 16px 8px; border-radius: var(--ui-radius-lg); border-color: var(--ui-line); box-shadow: var(--ui-shadow); }
body.teacher-body .qz-panel table { width: 100%; border-collapse: collapse; }
body.teacher-body .qz-panel th {
  padding: 10px 12px 8px; border-bottom: 1px solid var(--ui-line); background: none; text-align: left;
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ui-muted);
}
body.teacher-body .qz-panel td {
  padding: 10px 12px; border-bottom: 1px solid var(--ui-line); vertical-align: top;
  font-size: 13px; line-height: 1.45; color: var(--ui-text);
}
body.teacher-body .qz-panel tbody tr:last-child td { border-bottom: 0; }
body.teacher-body .qz-panel tbody tr:hover td { background: #f8faf9; }
body.teacher-body .qz-panel td strong { display: inline-block; margin-bottom: 2px; font-size: 14px; font-weight: 650; color: var(--ui-ink); }
body.teacher-body .qz-panel td .muted { font-size: 12px; color: var(--ui-muted); }
body.teacher-body .qz-panel td:nth-child(3) { font-variant-numeric: tabular-nums; }
body.teacher-body .qz-panel td:nth-child(4) { white-space: nowrap; font-size: 12.5px; color: var(--ui-muted); }
body.teacher-body .qz-panel .assignment-table-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
body.teacher-body .qz-panel .assignment-action-link { font-size: 13px; font-weight: 600; }
/* In a single section the Course column only repeats the header */
body.teacher-body .qz-panel table.qz-scoped :is(th, td):nth-child(2) { display: none; }

/* Status chips (added by the script, in the Status column) */
body.teacher-body .qz-state {
  display: inline-flex; align-items: center; margin: 0 6px 2px 0; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; line-height: 1.5; background: #f1f5f9; color: #475569;
}
body.teacher-body .qz-state--open { background: #dcfae6; color: #067647; }
body.teacher-body .qz-state--scheduled { background: #e8efff; color: #1d4ed8; }

/* Quiz picker cards: sections without quizzes stay visible but quieter */
body.teacher-body .asg-course[data-empty] { border-top-color: var(--ui-line-strong); }
body.teacher-body .asg-course[data-empty] .asg-course__name { color: var(--ui-text); }

@media (max-width: 760px) {
  body.teacher-body .qz-panel { padding: 0 8px; }
  body.teacher-body .qz-panel thead { display: none; }
  body.teacher-body .qz-panel table,
  body.teacher-body .qz-panel tbody,
  body.teacher-body .qz-panel tr,
  body.teacher-body .qz-panel td { display: block; width: auto; min-width: 0; white-space: normal; }
  body.teacher-body .qz-panel { overflow-x: visible; }
  body.teacher-body .qz-panel td { overflow-wrap: anywhere; }
  body.teacher-body .qz-panel tr { padding: 10px 4px; border-bottom: 1px solid var(--ui-line); }
  body.teacher-body .qz-panel tbody tr:last-child { border-bottom: 0; }
  body.teacher-body .qz-panel td { padding: 2px 4px; border: 0; }
  body.teacher-body .qz-panel td:nth-child(3)::before { content: "Questions: "; color: var(--ui-muted); }
  body.teacher-body .qz-panel .assignment-table-actions { padding-top: 6px; gap: 8px; }
  body.teacher-body .qz-panel .assignment-action-link { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border: 1px solid var(--ui-line-strong); border-radius: var(--ui-radius-sm); }
}
