/* ============================================================
   CBT Management Portal — Design System v2
   Bootstrap 5 base + custom theme
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --sb-width:       260px;
  --sb-bg:          #1c3832;
  --sb-active:      #dc5a2a;
  --sb-text:        rgba(255,255,255,.82);
  --sb-muted:       rgba(255,255,255,.42);
  --accent:         #dc5a2a;
  --accent-hover:   #c04d22;
  --top-h:          62px;
  --card-r:         14px;
  --page-bg:        #f0f2f8;
  --panel-border:   #e8ecf4;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page-bg);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #212529;
}
a { text-decoration: none; color: inherit; }


/* ══════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sb-width);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 1045;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.12) transparent;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1044;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* Brand block */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-brand-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 1.25rem; color: #fff;
  flex-shrink: 0;
}
.sidebar-brand-name {
  font-weight: 700;
  color: #fff;
  font-size: .95rem;
  line-height: 1.2;
  display: block;
}
.sidebar-brand-sub {
  font-size: .67rem;
  color: var(--sb-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  display: block;
}

/* User chip */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin: 12px 12px 4px;
  background: rgba(255,255,255,.08);
  border-radius: 10px;
  flex-shrink: 0;
}
.sidebar-avatar {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; color: #fff; font-size: .82rem;
  flex-shrink: 0;
}
.sidebar-user-name  { color: #fff; font-size: .82rem; font-weight: 600; display: block; line-height: 1.3; }
.sidebar-user-role  {
  font-size: .65rem;
  background: rgba(255,255,255,.18);
  color: rgba(255,255,255,.85);
  padding: 2px 7px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 2px;
}

/* Nav links */
.sidebar-nav { flex: 1; padding: 8px 10px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--sb-text);
  font-size: .84rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 1px;
  cursor: pointer;
}
.nav-item .nav-icon { font-size: .95rem; width: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item-danger:hover { background: rgba(220,53,69,.25); color: #ff8080; }

/* Nav group label */
.nav-group-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.38);
  padding: 14px 12px 4px;
  margin-top: 4px;
}

/* Footer */
.sidebar-footer {
  padding: 10px 10px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}


/* ══════════════════════════════════════════════════════════════
   MAIN WRAPPER + TOPBAR
══════════════════════════════════════════════════════════════ */
.main-wrapper {
  margin-left: var(--sb-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: var(--top-h);
  background: #fff;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  flex-shrink: 0;
}
.topbar-toggle {
  display: none;
  border: none;
  background: none;
  font-size: 1.5rem;
  color: #495057;
  padding: 4px 6px;
  line-height: 1;
  cursor: pointer;
}
.topbar-title { flex: 1; }
.topbar-title .breadcrumb { font-size: .82rem; }
.topbar-title .breadcrumb-item a { color: #6c757d; }
.topbar-title .breadcrumb-item.active { color: #212529; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Page content */
.page-content { padding: 28px; flex: 1; }


/* ══════════════════════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════════════════════ */
.page-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--panel-border);
  background: #fff;
  font-size: .78rem;
  color: #7a8394;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.page-footer-product { font-weight: 600; color: #55606f; }
.page-footer-sep     { color: #c3cad6; }

/* Standalone pages (login, access denied) centre their footer */
.page-footer-standalone {
  margin-top: 28px;
  text-align: center;
  font-size: .74rem;
  font-weight: 400;
  color: #98a1b0;
}
/* Vendor attribution — pinned to the bottom of the promo pane, quiet by
   design so it reads as a credit rather than a feature. */
.login-promo-footer {
  margin-top: auto;
  padding-top: 40px;          /* clear separation from the feature list */
  font-size: .705rem;
  font-weight: 400;           /* never bold — it is a credit, not a feature */
  color: rgba(255,255,255,.38);
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.login-promo-footer::before {
  content: "";
  flex: 0 0 18px;
  height: 1px;
  background: rgba(255,255,255,.20);
}


/* ══════════════════════════════════════════════════════════════
   METRIC CARDS
══════════════════════════════════════════════════════════════ */
.metric-card {
  background: #fff;
  border-radius: var(--card-r);
  padding: 22px;
  border: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  transition: box-shadow .2s, transform .2s;
}
.metric-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,.1); transform: translateY(-2px); }

.metric-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.4rem;
}
.icon-primary   { background: #dbeafe; color: #1d4ed8; }
.icon-success   { background: #dcfce7; color: #16a34a; }
.icon-warning   { background: #fef9c3; color: #ca8a04; }
.icon-info      { background: #cffafe; color: #0891b2; }
.icon-secondary { background: #f1f5f9; color: #475569; }
.icon-danger    { background: #fee2e2; color: #dc2626; }

.metric-value { font-size: 2rem; font-weight: 800; line-height: 1; color: #1a1a2e; }
.metric-label { font-size: .73rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #6c757d; }


/* ══════════════════════════════════════════════════════════════
   CHART CARDS
══════════════════════════════════════════════════════════════ */
.chart-card {
  background: #fff;
  border-radius: var(--card-r);
  border: 1px solid var(--panel-border);
  height: 100%;
  display: flex;
  flex-direction: column;
}
.chart-card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid #f4f6fb;
  flex-shrink: 0;
}
.chart-card-title {
  font-size: .88rem;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0;
  display: flex;
  align-items: center;
}
.chart-card-body {
  padding: 16px 22px 22px;
  flex: 1;
}


/* ══════════════════════════════════════════════════════════════
   DATA PANELS (tables, alerts, activity)
══════════════════════════════════════════════════════════════ */
.data-panel {
  background: #fff;
  border-radius: var(--card-r);
  border: 1px solid var(--panel-border);
  overflow: hidden;
}
.data-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f0f2f8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.data-panel-title {
  font-size: .88rem;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0;
  display: flex;
  align-items: center;
}
.data-panel-footer {
  border-top: 1px solid #f0f2f8;
  color: #6c757d;
}


/* ══════════════════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════════════════ */
.portal-table { width: 100%; border-collapse: collapse; margin: 0; }
.portal-table thead th {
  background: #f8fafc;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #64748b;
  padding: 12px 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}
.portal-table tbody td {
  padding: 12px 16px;
  font-size: .85rem;
  color: #374151;
  border-bottom: 1px solid #f4f6fb;
  vertical-align: middle;
}
.portal-table tbody tr:last-child td { border-bottom: none; }
.portal-table tbody tr:hover td { background: #f8f9ff; }


/* ══════════════════════════════════════════════════════════════
   TOOLBAR + SEARCH
══════════════════════════════════════════════════════════════ */
.portal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border-bottom: 1px solid #f0f2f8;
}
.search-box .form-control { min-width: 200px; }
.search-box .input-group-text { background: #fff; }


/* ══════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════ */
.btn-accent {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.btn-accent:hover, .btn-accent:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.btn-accent:focus { box-shadow: 0 0 0 .2rem rgba(220,90,42,.35); }

.btn-outline-accent {
  color: var(--accent);
  border-color: var(--accent);
  background: transparent;
}
.btn-outline-accent:hover {
  background: var(--accent);
  color: #fff;
}

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


/* ══════════════════════════════════════════════════════════════
   ALERT LIST (dashboard proctoring alerts)
══════════════════════════════════════════════════════════════ */
.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-item {
  display: flex;
  align-items: center;
  padding: 11px 20px;
  border-bottom: 1px solid #f4f6fb;
  font-size: .84rem;
  gap: 6px;
}
.alert-item:last-child { border-bottom: none; }
.alert-type { font-weight: 600; color: #374151; }
.alert-time { margin-left: auto; white-space: nowrap; }


/* ══════════════════════════════════════════════════════════════
   QUICK ACTIONS GRID (dashboard)
══════════════════════════════════════════════════════════════ */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px 20px 20px;
}
.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 12px;
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  font-size: .8rem;
  font-weight: 600;
  color: #374151;
  text-align: center;
  transition: all .15s;
}
.quick-btn i { font-size: 1.4rem; color: var(--accent); }
.quick-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.quick-btn:hover i { color: #fff; }


/* ══════════════════════════════════════════════════════════════
   FORM CARDS
══════════════════════════════════════════════════════════════ */
.form-card {
  background: #fff;
  border-radius: var(--card-r);
  border: 1px solid var(--panel-border);
  overflow: hidden;
}
.form-card-header {
  padding: 22px 28px 20px;
  border-bottom: 1px solid #f0f2f8;
}
.form-card-body { padding: 28px; }

/* Delete icon wrapper */
.delete-icon-wrap {
  width: 52px; height: 52px;
  background: rgba(220,53,69,.12);
  border-radius: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
}


/* ══════════════════════════════════════════════════════════════
   BS-FORM (auto-style Django native widgets as Bootstrap)
══════════════════════════════════════════════════════════════ */
.bs-form input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=file]),
.bs-form select,
.bs-form textarea {
  display: block;
  width: 100%;
  padding: .45rem .75rem;
  font-size: .9rem;
  line-height: 1.5;
  color: #212529;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  appearance: auto;
}
.bs-form input:focus,
.bs-form select:focus,
.bs-form textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 .2rem rgba(220,90,42,.18);
}
.bs-form textarea { min-height: 88px; resize: vertical; }
.bs-form .errorlist {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  color: #dc3545;
  font-size: .8rem;
}


/* ══════════════════════════════════════════════════════════════
   QUESTION FORM — sections + option rows
══════════════════════════════════════════════════════════════ */
.qsection {
  background: #f8fafc;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 20px 22px;
}
.qsection-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #64748b;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
}

.option-row {
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: border-color .15s;
}
.option-row:hover { border-color: #b8c0d4; }
.option-row-body { display: flex; align-items: flex-start; gap: 10px; }
.option-num {
  width: 26px; height: 26px; flex-shrink: 0;
  background: var(--accent); color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: .72rem; font-weight: 700;
  margin-top: 7px;
}
.option-text-wrap textarea,
.option-text-wrap .form-control { min-height: 54px; }
.option-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: .7rem;
  color: #6c757d;
  min-width: 50px;
  padding-top: 5px;
  cursor: pointer;
  user-select: none;
}
.option-toggle input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent); }
.correct-toggle { color: #198754; }
.delete-toggle  { color: #dc3545; }


/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(140deg, #1c3832 0%, #2e5c50 50%, #1a3530 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(900px, 100%);
  background: #fff;
  border-radius: 22px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  box-shadow: 0 40px 80px rgba(0,0,0,.28);
}
.login-promo {
  position: relative;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(220,90,42,.20) 0%, transparent 55%),
    linear-gradient(160deg, #1c3832 0%, #2e5c50 100%);
  padding: 0;
  color: #fff;
  display: flex;
  overflow: hidden;
}
/* Soft decorative halo behind the content */
.login-promo::after {
  content: "";
  position: absolute;
  right: -80px; bottom: -110px;
  width: 280px; height: 280px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  pointer-events: none;
}
.login-promo-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 44px 40px 34px;
  display: flex;
  flex-direction: column;
}
.login-logo {
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 1.6rem; color: #fff;
  margin-bottom: 22px;
  box-shadow: 0 10px 24px rgba(220,90,42,.38);
}
.login-promo-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.22;
  letter-spacing: -.015em;
  text-wrap: balance;          /* avoids a lone orphan word on the last line */
  margin: 0 0 12px;
}
.login-promo-sub {
  font-size: .84rem;
  color: rgba(255,255,255,.70);
  line-height: 1.65;
  margin: 0 0 22px;
  max-width: 34ch;
}
/* Accent rule separating the pitch from the feature list */
.login-promo-sub::after {
  content: "";
  display: block;
  width: 44px; height: 3px;
  border-radius: 3px;
  background: var(--accent);
  margin-top: 22px;
}
.login-features {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.login-features li {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: .845rem;
  line-height: 1.35;
  color: rgba(255,255,255,.86);
}
.login-features li i {
  flex: 0 0 auto;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: rgba(93,206,160,.16);
  color: #5dcea0;
  font-size: .72rem;
  display: grid; place-items: center;
}

.login-form-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.login-form-inner {
  width: 100%;
  padding: 48px 44px;
}
.login-eyebrow {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin-bottom: 6px;
}
.login-form-title {
  font-size: 1.55rem;
  font-weight: 800;
  color: #1a1a2e;
  margin-bottom: 6px;
}
.login-form-sub { font-size: .85rem; margin-bottom: 28px; }
.login-form-header { margin-bottom: 28px; }


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .topbar-toggle { display: block; }
  .page-content { padding: 18px 16px; }
  .page-footer { padding: 14px 16px; }
  .topbar { padding: 0 16px; }
  .metric-value { font-size: 1.6rem; }
}

@media (max-width: 767.98px) {
  .login-card { grid-template-columns: 1fr; }
  .login-promo { display: none; }
  .login-form-inner { padding: 36px 28px; }
  .portal-toolbar { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 575.98px) {
  .page-content { padding: 12px; }
  .form-card-body { padding: 20px 16px; }
  .quick-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}
