/*
 * Shared theme for all portals. No inline styles anywhere (strict CSP), so every visual helper
 * lives here. Built on Bootstrap 5.3 variables.
 */
:root {
  --brand: #1f3a5f;
  --brand-dark: #152a45;
  --brand-light: #e8eef6;
  --accent: #f0a500;
  --sidebar-width: 260px;
  --radius: 0.75rem;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --bs-body-bg: #f4f6fa;
  --bs-link-color: #1f5fa8;
  --bs-link-color-rgb: 31, 95, 168;
  --bs-link-hover-color: var(--brand);
  --bs-border-radius: 0.5rem;
  --bs-border-radius-lg: var(--radius);
}

body {
  background: var(--bs-body-bg);
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  z-index: 2000;
  background: #fff;
  padding: 0.5rem 1rem;
}

/* ---------------------------------------------------------------- buttons, forms */
.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark);
  --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-dark);
  --bs-btn-active-border-color: var(--brand-dark);
  --bs-btn-disabled-bg: var(--brand);
  --bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-primary {
  --bs-btn-color: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand-dark);
}

.btn {
  font-weight: 500;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: #7a9cc6;
  box-shadow: 0 0 0 0.2rem rgba(31, 58, 95, 0.18);
}

.form-check-input:checked {
  background-color: var(--brand);
  border-color: var(--brand);
}

.form-label {
  font-weight: 500;
  margin-bottom: 0.3rem;
}

:focus-visible {
  outline: 3px solid rgba(240, 165, 0, 0.7);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- cards, tables, badges */
.card {
  border: 1px solid #e3e8ef;
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card.shadow-sm {
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.06) !important;
}

.table {
  --bs-table-bg: #fff;
  margin-bottom: 1rem;
}

.table-responsive {
  border: 1px solid #e3e8ef;
  border-radius: var(--radius);
  background: #fff;
}

.table-responsive > .table {
  margin-bottom: 0;
}

.table > thead th {
  background: #f8fafc;
  color: #475467;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table td,
.table th {
  padding: 0.7rem 0.85rem;
}

.badge {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.breadcrumb {
  font-size: 0.875rem;
}

h1.h3,
h1.h4 {
  font-weight: 650;
  letter-spacing: -0.01em;
}

.display-6 {
  font-weight: 650;
}

/* ---------------------------------------------------------------- brand */
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-logo {
  max-height: 38px;
  max-width: 120px;
  width: auto;
  background: #fff;
  border-radius: 0.4rem;
  padding: 0.15rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 0.6rem;
  background: var(--accent);
  color: var(--brand-dark);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-portal {
  font-size: 0.75rem;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------------------------------------------------------------- app shell (signed-in) */
.sidebar {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  --bs-offcanvas-width: var(--sidebar-width);
  --bs-offcanvas-bg: var(--brand);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar .brand {
  color: #fff;
}

.sidebar-nav {
  padding: 0.75rem 0.6rem;
  overflow-y: auto;
  flex-grow: 1;
}

.nav-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.5);
  padding: 0.9rem 0.75rem 0.35rem;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: rgba(255, 255, 255, 0.82);
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.93rem;
}

.sidebar .nav-link .bi {
  font-size: 1.05rem;
  width: 1.2rem;
  text-align: center;
}

.sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar .nav-link.active {
  background: #fff;
  color: var(--brand);
  font-weight: 600;
}

.sidebar-foot {
  padding: 0.9rem 1rem;
  color: rgba(255, 255, 255, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  word-break: break-all;
}

@media (min-width: 992px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    z-index: 1030;
  }

  .main-area {
    margin-left: var(--sidebar-width);
  }
}

.main-area {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #e3e8ef;
}

.topbar-title {
  font-weight: 600;
  font-size: 1.05rem;
}

.topbar .btn-light {
  background: #f1f4f8;
  border-color: #f1f4f8;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.content {
  flex-grow: 1;
  padding: 1.5rem;
  max-width: 1400px;
  width: 100%;
}

.content-foot {
  padding: 1rem 1.5rem;
}

@media (max-width: 575.98px) {
  .content {
    padding: 1rem;
  }

  .topbar {
    padding: 0.6rem 1rem;
  }
}

/* ---------------------------------------------------------------- public pages */
.app-public {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.public-header {
  background: linear-gradient(90deg, var(--brand-dark), var(--brand));
  color: #fff;
  padding: 0.9rem 0;
}

.public-header .brand {
  color: #fff;
}

.public-main {
  flex-grow: 1;
  padding: 2.5rem 0;
}

.public-footer {
  padding: 1.25rem 0;
  color: #667085;
  border-top: 1px solid #e3e8ef;
  background: #fff;
}

.auth-card {
  max-width: 440px;
  margin: 0 auto;
}

.auth-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  font-size: 1.6rem;
}

.hero-search {
  max-width: 640px;
  margin: 0 auto;
}

/* ---------------------------------------------------------------- dashboard tiles, empty states */
.stat-tile {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 0.75rem;
  font-size: 1.4rem;
  flex-shrink: 0;
  background: var(--brand-light);
  color: var(--brand);
}

.stat-icon.warn {
  background: #fff4dc;
  color: #a86b00;
}

.stat-icon.ok {
  background: #e3f6ec;
  color: #157347;
}

.stat-icon.danger {
  background: #fde8e8;
  color: #b42318;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #667085;
}

.empty-state .bi {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 0.5rem;
  color: #98a2b3;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.page-head h1 {
  margin-bottom: 0;
}

/* Registration progress: numbered dots joined by a line. */
.stepper {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

.stepper li {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #667085;
}

.stepper li + li::before {
  content: "";
  position: absolute;
  top: 1rem;
  right: 50%;
  width: 100%;
  height: 2px;
  background: #d0d5dd;
  z-index: 0;
}

.stepper li.done::before,
.stepper li.current::before {
  background: var(--brand);
}

.stepper-dot {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #d0d5dd;
  font-weight: 700;
}

.stepper li.current .stepper-dot {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.stepper li.done .stepper-dot {
  background: #e3f6ec;
  border-color: #157347;
  color: #157347;
}

.stepper li.current .stepper-label {
  color: var(--brand);
  font-weight: 600;
}

/* ---------------------------------------------------------------- page-specific helpers */
.institute-logo {
  max-height: 56px;
  max-width: 160px;
  width: auto;
}

.activity-details {
  max-width: 28rem;
}

.code-input {
  letter-spacing: 0.4em;
  font-variant-numeric: tabular-nums;
}

.totp-qr {
  max-width: 220px;
}

.student-photo {
  width: 72px;
  height: 72px;
  object-fit: cover;
}

.confirmation-list {
  max-width: 22rem;
}

.email-preview {
  height: 420px;
}

.exam-slip {
  max-width: 40rem;
}

.exam-bar {
  top: env(safe-area-inset-top, 0px);
  z-index: 1020;
}

.exam-question {
  border-left: 4px solid var(--brand-light);
}

.exam-question .form-check {
  padding: 0.55rem 0.75rem 0.55rem 2.25rem;
  border-radius: 0.5rem;
}

.exam-question .form-check:hover {
  background: #f4f6fa;
}

.exam-question .form-check-input {
  transform: scale(1.15);
}

.verify-photo {
  width: 96px;
  height: 120px;
  object-fit: cover;
}

.verify-cert.verify-revoked {
  border-left: 4px solid var(--bs-danger);
}

.verify-cert.verify-expired {
  border-left: 4px solid var(--bs-warning);
}

.verify-cert.verify-valid {
  border-left: 4px solid var(--bs-success);
}

@media print {
  .sidebar, .topbar, .content-foot, .public-header, .public-footer, .btn, .no-print, form {
    display: none !important;
  }

  .main-area {
    margin-left: 0 !important;
  }

  .card {
    border: 0 !important;
    box-shadow: none !important;
  }

  body {
    background: #fff !important;
  }
}
