/* ==========================================================================
   DigiVal Admin — visual reskin layered on top of the existing
   NiceAdmin/Bootstrap template. Loads after style.css / hover.css /
   bootstrap.min.css and wins the cascade by selector order.

   Colour palette is intentionally UNCHANGED from the original template
   (blue #4154f1, navy #012970, green #2eca6a, orange #ff771d,
   red #dc3545, muted #899bbd, canvas #f6f9ff) — this pass only tightens
   typography, spacing and adds a few shared components (pills, the
   valuation rail, ledger stat cards) built from those same colours.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,500;8..60,600;8..60,700&family=IBM+Plex+Mono:wght@500;600&display=swap");

:root {
  /* -- Existing template colours, named for reuse -------------------- */
  --brand-blue: #4154f1;
  --brand-navy: #012970;
  --brand-green: #2eca6a;
  --brand-orange: #ff771d;
  --brand-red: #dc3545;
  --brand-yellow: #ffc107;
  --brand-muted: #899bbd;

  --brand-blue-tint: #eceefe;
  --brand-green-tint: #e0f8e9;
  --brand-orange-tint: #ffecdf;
  --brand-red-tint: #f8d7da;
  --brand-yellow-tint: #fff3cd;

  --page-bg: #f6f9ff;
  --surface: #ffffff;
  --rule: #ebeef4;

  /* -- Type -------------------------------------------------------------- */
  --font-display: "Source Serif 4", "Poppins", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* -- Base ------------------------------------------------------------- */
h1, h2, h3,
.card-title, .title, .title-2, .card-title-2, .card-title-3, .card-title-4,
.logo span {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

.code, code, .exam-id {
  font-family: var(--font-mono);
}

/* ==========================================================================
   Shell — header, sidebar, page title
   ========================================================================== */

.pagetitle {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.pagetitle h1 {
  font-family: var(--font-display);
  font-weight: 600;
}
.pagetitle-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--brand-muted);
  margin-top: 2px;
}

.section-subtitle {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--brand-muted);
  margin-top: 3px;
}

.header {
  box-shadow: none;
  border-bottom: 1px solid var(--rule);
}

/* ==========================================================================
   Cards, tables — light spacing/typography polish, same colours
   ========================================================================== */

.card {
  border: 1px solid var(--rule);
  box-shadow: 0 1px 2px rgba(1, 41, 112, 0.05);
}
.card-title {
  font-weight: 600;
}

.table thead th,
.table.thead-dark th,
thead.thead-dark th {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--brand-navy);
}
.table td, .table th {
  vertical-align: middle;
}

/* ==========================================================================
   Status pills — a shared vocabulary for exam / valuation state,
   replacing one-off inline-styled spans and coloured circles. Uses the
   same four semantic colours the template already defines.
   ========================================================================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  line-height: 1.6;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.pill-seal { background: var(--brand-blue-tint); color: var(--brand-blue); }
.pill-amber { background: var(--brand-orange-tint); color: var(--brand-orange); }
.pill-ok { background: var(--brand-green-tint); color: var(--brand-green); }
.pill-red { background: var(--brand-red-tint); color: var(--brand-red); }
.pill-slate { background: #eef1f8; color: var(--brand-muted); }
.pill-icon::before { display: none; }

/* ==========================================================================
   Active Exams table — per-exam valuation completion at a glance
   ========================================================================== */

.exam-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px 20px;
  padding-top: 20px;
  margin-bottom: 20px;
}
.exam-table-toolbar .card-title {
  padding: 0;
}

.exam-table-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  flex: none;
}

.exam-search {
  position: relative;
  flex: none;
  width: 220px;
}
.exam-search i {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--brand-muted);
}
.exam-search-input {
  width: 100%;
  padding: 6px 10px 6px 32px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--surface);
  font-size: 13px;
  color: var(--brand-navy);
}
.exam-search-input:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px var(--brand-blue-tint);
}
.exam-search-input::placeholder {
  color: var(--brand-muted);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-muted);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.filter-chip span {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  color: inherit;
  opacity: 0.75;
}
.filter-chip:hover {
  border-color: var(--brand-muted);
}
.filter-chip.active {
  color: var(--brand-blue);
  background: var(--brand-blue-tint);
  border-color: var(--brand-blue-tint);
}
.filter-chip-red.active {
  color: var(--brand-red);
  background: var(--brand-red-tint);
  border-color: var(--brand-red-tint);
}
.filter-chip-amber.active {
  color: var(--brand-orange);
  background: var(--brand-orange-tint);
  border-color: var(--brand-orange-tint);
}
.filter-chip-ok.active {
  color: var(--brand-green);
  background: var(--brand-green-tint);
  border-color: var(--brand-green-tint);
}

.exam-table-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--brand-muted);
  font-size: 13px;
  text-align: center;
}
.exam-table-empty i {
  font-size: 22px;
}

.exam-table thead th {
  white-space: nowrap;
}
.exam-table td {
  font-size: 13px;
}
.exam-table .exam-name {
  font-weight: 600;
  /* .table-striped's odd-row rule (.table-striped>tbody>tr:nth-of-type(odd)>*)
     out-specifies a plain two-class selector, so odd rows would otherwise
     fall back to Bootstrap's default body color. */
  color: var(--brand-navy) !important;
}

.row-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
}
.row-progress-track {
  flex: 1;
  height: 8px;
}
.row-progress-pct {
  flex: none;
  width: 34px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--brand-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--brand-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover:not(:disabled) {
  color: var(--brand-blue);
  border-color: var(--brand-blue-tint);
  background: var(--brand-blue-tint);
}
.icon-btn-danger:hover:not(:disabled) {
  color: var(--brand-red);
  border-color: var(--brand-red-tint);
  background: var(--brand-red-tint);
}
.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.row-action {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--brand-blue);
  font-size: 20px;
  line-height: 1;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.row-action:hover {
  background: var(--brand-blue-tint);
}

.exam-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--brand-muted);
  margin-top: 2px;
  white-space: nowrap;
}
.exam-meta i {
  margin-right: 3px;
}

/* ==========================================================================
   Valuation Progress — the number an exam controller actually tracks:
   what share of uploaded scripts have been valued. Mapped/Uploaded/Pending
   are shown as supporting counts, not stacked into the same bar, because
   they're different units (students vs. scripts) and a shared scale would
   misrepresent the ratio.
   ========================================================================== */

.ledger-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-muted);
}

.funnel-card {
  background: linear-gradient(180deg, #fbfcff 0%, var(--surface) 140px);
}

.progress-hero {
  display: flex;
  align-items: center;
  gap: 24px;
}
.progress-hero-figure {
  flex: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 44px;
  color: var(--brand-navy);
  line-height: 1;
}
.progress-hero-figure span {
  font-size: 22px;
  font-weight: 600;
  color: var(--brand-muted);
}
.progress-hero-body {
  flex: 1;
  min-width: 0;
}
.funnel-track {
  height: 10px;
  border-radius: 5px;
  background: #eef1f8;
  overflow: hidden;
}
.progress-hero-track {
  height: 14px;
}
.funnel-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.funnel-bar-green { background: var(--brand-green); }
.funnel-bar-orange { background: var(--brand-orange); }
.funnel-bar-red { background: var(--brand-red); }
.progress-hero-caption {
  margin-top: 9px;
  font-size: 13px;
  color: var(--brand-muted);
}
.progress-hero-caption .code {
  color: var(--brand-navy);
  font-weight: 600;
}

.progress-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}
.progress-stat {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--brand-muted);
}
.progress-stat b {
  font-family: var(--font-mono);
  color: var(--brand-navy);
  font-weight: 600;
}
.progress-stat .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.dot-blue { background: var(--brand-blue); }
.dot-orange { background: var(--brand-orange); }
.dot-red { background: var(--brand-red); }

@media (prefers-reduced-motion: reduce) {
  .funnel-bar { transition: none; }
}

@media (max-width: 575px) {
  .progress-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .progress-hero-body {
    width: 100%;
  }
}

/* ==========================================================================
   Step rail — a linear step-progress indicator, shared by the Exam Detail
   "Setup Progress" rail and the Grading Layout wizard.
   ========================================================================== */
.rail-steps {
  display: flex;
  align-items: flex-start;
}
.rail-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  width: 100px;
  border: none;
  background: none;
  padding: 4px 0;
}
.rail-connector {
  flex: 1;
  height: 2px;
  background: var(--rule);
  margin-top: 23px;
  min-width: 12px;
}
.rail-connector.is-filled {
  background: var(--brand-blue);
}
.rail-step-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex: none;
}
.rail-step-label {
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
  color: var(--brand-navy);
}

.rail-step.is-locked {
  cursor: not-allowed;
}
.rail-step.is-locked .rail-step-circle {
  background: #eef0f4;
  color: #aab2c5;
}
.rail-step.is-locked .rail-step-label {
  color: var(--brand-muted);
}

.rail-step.is-available .rail-step-circle {
  background: var(--brand-blue-tint);
  color: var(--brand-blue);
}
.rail-step.is-available:hover .rail-step-label {
  color: var(--brand-blue);
}

.rail-step.is-current .rail-step-circle {
  background: var(--brand-blue);
  color: #fff;
  box-shadow: 0 0 0 4px var(--brand-blue-tint);
}
.rail-step.is-current .rail-step-label {
  color: var(--brand-blue);
}

.rail-step.is-done .rail-step-circle {
  background: var(--brand-green-tint);
  color: var(--brand-green);
}

@media (max-width: 767px) {
  .rail-steps {
    flex-direction: column;
    align-items: stretch;
  }
  .rail-step {
    flex-direction: row;
    width: auto;
    justify-content: flex-start;
    gap: 12px;
    padding: 6px 0;
  }
  .rail-step-label {
    text-align: left;
  }
  .rail-connector {
    width: 2px;
    height: 18px;
    margin: 0 0 0 18px;
  }
}

.text-navy {
  color: var(--brand-navy) !important;
}

/* ==========================================================================
   Stat-card summary grids — shared 4-up KPI layout used by Paper Allotment
   and Subject Overview (allotment/valuation stats, cohort score stats).
   ========================================================================== */

.allotment-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 16px 0 20px;
}
.allotment-stat {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px 16px;
}
.allotment-stat-pct {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--brand-navy);
}
.allotment-stat-pct-loading {
  font-family: inherit;
  font-weight: 500;
  font-size: 13px;
  color: var(--brand-muted);
}
.allotment-stat-caption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--brand-muted);
}
.allotment-stat-caption-hl {
  font-size: 11px;
}
.allotment-stat-caption-hl div {
  max-width: 100%;
}
.allotment-stat-caption-hl div + div {
  margin-top: 3px;
}

.allotment-total-row th {
  background: var(--page-bg);
}

@media (max-width: 991px) {
  .allotment-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 575px) {
  .allotment-summary {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Dashboard ledger cards — same info-card data, tidier layout
   ========================================================================== */

.ledger-card {
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--surface);
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.ledger-card:hover {
  box-shadow: 0px 0 30px rgba(1, 41, 112, 0.1);
  transform: translateY(-1px);
}
.ledger-card .ledger-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 34px;
  color: var(--brand-navy);
  line-height: 1.1;
  margin-top: 4px;
}
.ledger-card .ledger-caption {
  font-size: 12px;
  color: var(--brand-muted);
  margin-top: 3px;
}
.ledger-card .ledger-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.ledger-card-static {
  cursor: default;
}
.ledger-card-static:hover {
  box-shadow: none;
  transform: none;
}
.ledger-value-unit {
  font-size: 18px;
  font-weight: 600;
  color: var(--brand-muted);
}

@media (prefers-reduced-motion: reduce) {
  .ledger-card { transition: none; }
}
