/* -----------------------------------------------------------
   Design Tokens
   Change values here to update the whole site at once.
----------------------------------------------------------- */
:root {
  --purple:       #4F2683;
  --purple-mid:   #7148a8;
  --purple-light: #ede9f6;
  --teal:         #1a8a7a;
  --amber:        #c97b0a;
  --rose:         #b83232;
  --slate:        #4b5563;
  --gold:         #807F36;
  --bg:           #eeecea;
  --card:         #ffffff;
  --border:       #dddad4;
  --text:         #1c1c2e;
  --muted:        #6b7280;
  --font-ui:      'Inter', sans-serif;
  --font-num:     'Outfit', sans-serif;
}


/* -----------------------------------------------------------
   Global Reset
----------------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }


/* -----------------------------------------------------------
   Root Font Size
   THIS is the one value that controls text size across the
   entire site. All component sizes use rem, which is a
   multiplier of this value. Change 15px here to resize
   everything proportionally — nothing else needs touching.
   (The topbar brand title and structural px heights are
   intentionally exempt and will not change.)
----------------------------------------------------------- */
html {
  font-size: 15px;
}


/* -----------------------------------------------------------
   Base Body
----------------------------------------------------------- */
body {
  min-height: 100vh;
  background: var(--bg);
  font-family: var(--font-ui);
  color: var(--text);
  font-size: 1rem;
}


/* -----------------------------------------------------------
   Sidebar font normalisation
   Keeps sidebar font consistent regardless of Bootstrap
   or other overrides.
----------------------------------------------------------- */
.app-sidebar, .sidebar, nav.sidebar, #sidebar,
.app-sidebar *, .sidebar *, nav.sidebar *, #sidebar * {
  font-family: var(--font-ui) !important;
}


/* -----------------------------------------------------------
   Global App Layout
----------------------------------------------------------- */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

.app-topbar  { grid-area: topbar; }
.app-sidebar { grid-area: sidebar; }
.app-header  { grid-area: header; }
.app-main    { grid-area: main; }


/* -----------------------------------------------------------
   Top Bar
----------------------------------------------------------- */
.app-topbar {
  background: #4F2683;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 200;
}

.app-topbar .topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; /* intentionally px — exempt from root scaling */
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.1px;
}

.app-topbar .topbar-brand i {
  font-size: 20px; /* intentionally px — exempt from root scaling */
  opacity: 0.9;
}

.app-topbar .topbar-back {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 0.3rem 0.85rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.app-topbar .topbar-back:hover {
  background: rgba(255,255,255,0.25);
  color: #fff;
  text-decoration: none;
}


/* -----------------------------------------------------------
   Sidebar Styling
----------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  border-right: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
}

.sidebar .nav-link {
  color: var(--bs-body-color);
  display: flex;
  align-items: flex-start;
  padding: 6px 10px;
}

.sidebar .nav-link.active {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
  border-radius: 4px;
}

.sidebar .nav-link i {
  margin-right: 6px;
  margin-top: 2px;
}


/* -----------------------------------------------------------
   Report page main area
   Used by index.cfm, report-*.cfm pages.
   The exam request and workspace pages override padding:0 inline.
   NOTE: overflow-x is intentionally NOT set here — it breaks
   position:sticky on children (e.g. thesis-workspace filter bar).
   Pages that need overflow clipping set it on their own containers.
----------------------------------------------------------- */
.app-main {
  padding: 0 2rem 2rem;
}


/* -----------------------------------------------------------
   Section Label
   Small uppercase eyebrow label used above content groups.
----------------------------------------------------------- */
.section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.75rem;
  margin-top: 1.25rem;
}


/* -----------------------------------------------------------
   Cards (report pages)
   .card-hd and .card-bd are the header/body sub-components.
----------------------------------------------------------- */
.card {
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-hd {
  padding: 0.65rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: #f7f6f3;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.card-bd {
  padding: 1.1rem;
}


/* -----------------------------------------------------------
   Page Header (report pages)
   The top title bar on each report: title + subtitle + date.
----------------------------------------------------------- */
.page-header {
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.page-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.page-header .ph-sub {
  font-size: 0.72rem;
  color: var(--muted);
}


/* -----------------------------------------------------------
   Stat Block
   Large centred number + label used in report summary cards.
----------------------------------------------------------- */
.stat-block {
  text-align: center;
  padding: 1rem 0.5rem;
}

.stat-num {
  font-family: var(--font-num);
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 0.35rem;
}

.stat-sub {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.2rem;
}


/* -----------------------------------------------------------
   Horizontal Bar (hbar)
   Used in report-examiners and index.cfm top-programs chart.
----------------------------------------------------------- */
.hbar-row { margin-bottom: 0.55rem; }

.hbar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  margin-bottom: 0.18rem;
}

.hbar-labels .hb-name {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.hbar-labels .hb-val {
  color: var(--muted);
  flex-shrink: 0;
}

.hbar-track {
  height: 6px;
  background: #e8e5df;
  border-radius: 99px;
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  border-radius: 99px;
}


/* -----------------------------------------------------------
   Animations
   fadeUp is used by report and index pages (.fu .d1-.d5).
   fade-up (with hyphen) is the exam-request variant.
   spin is used by the exam-request spinner.
----------------------------------------------------------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fu          { animation: fadeUp 0.35s ease both; }
.fade-up     { animation: fadeUp 0.25s ease both; }
.d1          { animation-delay: 0.04s; }
.d2          { animation-delay: 0.08s; }
.d3          { animation-delay: 0.12s; }
.d4          { animation-delay: 0.16s; }
.d5          { animation-delay: 0.20s; }

@keyframes spin { to { transform: rotate(360deg); } }

.etd-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}


/* -----------------------------------------------------------
   ETD Cards (exam request pages)
   Slightly different from .card/.card-hd — wider padding,
   used by thesis-exam-request.cfm and -details.cfm.
----------------------------------------------------------- */
.etd-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  margin-bottom: 1.25rem;
}

.etd-card-header {
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: #f7f6f3;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.etd-card-body {
  padding: 1.25rem;
}


/* -----------------------------------------------------------
   Step Bar (exam request pages)
   Multi-step wizard progress indicator.
----------------------------------------------------------- */
.step-bar {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 1.75rem;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.step-item.active { color: var(--purple); }
.step-item.done   { color: var(--teal); }

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e5e2dc;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step-item.active .step-num { background: var(--purple); color: #fff; }
.step-item.done   .step-num { background: var(--teal);   color: #fff; }

.step-divider {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 0.6rem;
  max-width: 48px;
}


/* -----------------------------------------------------------
   Form Elements (exam request pages)
   Labels, inputs, selects, textareas.
----------------------------------------------------------- */
.field-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.35rem;
  display: block;
}

.field-hint {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.etd-input, .etd-select, .etd-textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.42rem 0.75rem;
  font-size: 0.82rem;
  font-family: var(--font-ui);
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.etd-input:focus, .etd-select:focus, .etd-textarea:focus {
  border-color: var(--purple-mid);
  box-shadow: 0 0 0 3px rgba(113,72,168,0.12);
}

.etd-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7280' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 2rem;
}

.etd-textarea {
  resize: vertical;
  min-height: 80px;
}


/* -----------------------------------------------------------
   Form Row Layout (exam request pages)
----------------------------------------------------------- */
.form-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0.5rem 1.25rem;
  align-items: start;
  margin-bottom: 1rem;
}

.form-row.narrow { grid-template-columns: 200px 220px; }

.form-row label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  padding-top: 0.45rem;
}


/* -----------------------------------------------------------
   Card Section Label (exam request pages)
   Coloured divider label inside etd-card sections.
----------------------------------------------------------- */
.card-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--purple-mid);
  margin: 1.1rem 0 0.65rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--purple-light);
}

.card-section-label:first-child { margin-top: 0; }


/* -----------------------------------------------------------
   Alert Banners (exam request pages)
----------------------------------------------------------- */
.etd-alert {
  border-radius: 6px;
  padding: 0.65rem 0.9rem;
  font-size: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.etd-alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.etd-alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.etd-alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.etd-alert-info    { background: var(--purple-light); border: 1px solid #c4b5e8; color: var(--purple); }

.etd-alert ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }


/* -----------------------------------------------------------
   Summary Grid (exam request pages)
   Read-only candidate summary display.
----------------------------------------------------------- */
.summary-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 0.45rem 1rem;
  align-items: baseline;
}

.summary-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.summary-value {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
}

.summary-divider {
  grid-column: 1 / -1;
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.2rem 0;
}


/* -----------------------------------------------------------
   DataTables / Table Styling
----------------------------------------------------------- */
#thesisTable {
  width: 100%;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

#thesisTable th,
#thesisTable td {
  vertical-align: top;
  white-space: normal;
}

.table th,
.table td {
  padding: 0.5rem;
}

.nowrap {
  white-space: nowrap !important;
}

.dataTables_wrapper {
  background: transparent;
}

.dataTables_wrapper .row {
  margin: 0;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  background: transparent;
  border: 0;
}

.dataTables_wrapper .pagination .page-link {
  color: #4F2683 !important;
  border-color: #4F2683 !important;
}

.dataTables_wrapper .pagination .page-link:hover {
  background-color: #4F2683 !important;
  color: white !important;
}

.dataTables_wrapper .pagination .page-item.active .page-link {
  background-color: #4F2683 !important;
  color: white !important;
  border-color: #4F2683 !important;
}


/* -----------------------------------------------------------
   Workflow Filter Buttons (Purple Theme)
----------------------------------------------------------- */
#workflowFilters .btn {
  border-color: #4F2683 !important;
  color: #4F2683 !important;
}

#workflowFilters .btn.active,
#workflowFilters .btn:focus,
#workflowFilters .btn:hover {
  background-color: #4F2683 !important;
  color: white !important;
  border-color: #4F2683 !important;
}


/* -----------------------------------------------------------
   Row Action Button (3 dots)
----------------------------------------------------------- */
td .btn-outline-primary {
  border-color: #4F2683 !important;
  color: #4F2683 !important;
}

td .btn-outline-primary i {
  color: #4F2683 !important;
}

td .btn-outline-primary:hover {
  background-color: #4F2683 !important;
  color: white !important;
}

td .btn-outline-primary:hover i {
  color: white !important;
}


/* -----------------------------------------------------------
   Status Display Pills
----------------------------------------------------------- */
.status-cell .heading {
  text-transform: uppercase;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--bs-secondary-color);
  margin-bottom: 0.2rem;
}

.status-cell .badge {
  font-size: 0.7rem;
  font-weight: 600;
}

.pill-muted {
  background-color: #f2f2f2;
  color: #666;
  border: 1px solid #e5e5e5;
}

.pill-rev {
  background-color: #e7ddf7;
  color: #4a3a67;
  border: 1px solid #dbd0f1;
}

.pill-accept {
  background-color: #d8f5d4;
  color: #1f5a1f;
  border: 1px solid #cbeec7;
}

.pill-pending {
  background-color: #ffe8b3;
  color: #7a5200;
  border: 1px solid #ffd98a;
}


/* -----------------------------------------------------------
   Offcanvas Layout (Workspace Slide-out)
----------------------------------------------------------- */
.offcanvas-body {
  display: flex;
  flex-direction: column;
}

.offcanvas-main {
  flex: 1 1 auto;
}


/* -----------------------------------------------------------
   Status Editor (Drop-down section)
----------------------------------------------------------- */
.status-editor {
  border-top: 1px solid #ddd;
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.status-select {
  width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #4F2683;
  color: #4F2683;
  background: #ffffff;
  font-size: 0.8rem;
  appearance: none;
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}

.status-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(79, 38, 131, 0.3);
}


/* -----------------------------------------------------------
   Shared Utility Classes
----------------------------------------------------------- */
.col-program {
  width: 110px;
  max-width: 130px;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}

.examiner-block {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background-color: #f8f9fa;
}

.examiner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.btn-back-workspace {
  background: #4F2683;
  color: white;
  font-weight: 600;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: background 0.2s, transform 0.15s;
}

.btn-back-workspace:hover {
  background: #381A5F;
  transform: translateY(-2px);
  text-decoration: none;
}

.btn-back-workspace i {
  font-size: 1rem;
}

.status-pill-main {
  font-family: inherit !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  padding: 6px 12px !important;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 20px !important;
  background-color: #f4f4f7 !important;
  color: #222 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  letter-spacing: 0.3px;
}

#thesisTable th:first-child,
#thesisTable td:first-child {
  width: 52px !important;
  min-width: 52px !important;
  max-width: 52px !important;
  box-sizing: border-box !important;
  padding: 8px !important;
}

#thesisTable colgroup col:first-child {
  width: 52px !important;
  min-width: 52px !important;
  max-width: 52px !important;
}

#thesisTable {
  table-layout: fixed !important;
}


/* -----------------------------------------------------------
   Mobile Adjustments
----------------------------------------------------------- */
@media (max-width: 991.98px) {
  .app-layout {
    grid-template-columns: 0 1fr;
    grid-template-areas:
      "topbar topbar"
      "sidebar main";
  }
  .sidebar {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    height: calc(100vh - 52px);
    width: 260px;
    z-index: 1050;
    box-shadow: 4px 0 16px rgba(0,0,0,0.25);
  }
  .sidebar.mobile-open {
    display: block;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: 52px;
    background: rgba(0,0,0,0.45);
    z-index: 1040;
  }
  .sidebar-backdrop.mobile-open {
    display: block;
  }
  .topbar-hamburger {
    display: flex !important;
  }
}

.topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  margin-right: 0.5rem;
  border-radius: 5px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.topbar-hamburger:hover { background: rgba(255,255,255,0.12); color: #fff; }
.topbar-hamburger i { font-size: 1.25rem; line-height: 1; }
