/**
 * Admin panel — sidebar shell, top bar, responsive.
 * Loaded after style.css
 */

:root {
  --admin-sidebar-w: 280px;
  --admin-sidebar-bg: #0b1a30;
  --admin-sidebar-bg-grad: linear-gradient(180deg, #0b1a30 0%, #0e2442 60%, #15345b 100%);
  --admin-sidebar-border: rgba(148, 163, 184, 0.12);
  --admin-sidebar-text: #cbd5e1;
  --admin-sidebar-heading: #94a3b8;
  --admin-sidebar-active-bg: rgba(26, 128, 201, 0.18);
  --admin-sidebar-active-fg: #ffffff;
  --admin-topbar-h: 64px;
  --admin-content-max: 1200px;
}

html,
body.admin-body {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

html::-webkit-scrollbar,
body.admin-body::-webkit-scrollbar,
body.admin-body *::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent !important;
}

html::-webkit-scrollbar-button,
body.admin-body::-webkit-scrollbar-button,
body.admin-body *::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

html::-webkit-scrollbar-thumb,
body.admin-body::-webkit-scrollbar-thumb,
body.admin-body *::-webkit-scrollbar-thumb {
  background: transparent !important;
}

html::-webkit-scrollbar-track,
body.admin-body::-webkit-scrollbar-track,
body.admin-body *::-webkit-scrollbar-track {
  background: transparent !important;
}

/* --- Logged-in admin shell --- */
.admin-body {
  min-height: 100vh;
}

.admin-body.has-sidebar {
  overflow-x: hidden;
}

.admin-shell {
  display: flex;
  min-height: 100vh;
  background:
    radial-gradient(900px 360px at 100% 0%, rgba(26, 128, 201, 0.06), transparent 65%),
    radial-gradient(800px 320px at 0% 100%, rgba(126, 184, 92, 0.05), transparent 60%),
    var(--bg);
}

/* Sidebar */
.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--admin-sidebar-w);
  z-index: 100;
  background: var(--admin-sidebar-bg-grad);
  color: var(--admin-sidebar-text);
  border-right: 1px solid var(--admin-sidebar-border);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.admin-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--admin-sidebar-border);
  color: #f1f5f9;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.015em;
  text-decoration: none;
  position: relative;
}

.admin-sidebar__brand::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-purple));
  opacity: 0.92;
}

.admin-sidebar__brand:hover {
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
}

.admin-sidebar__brand .brand-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  display: block;
  border-radius: 6px;
}

.admin-sidebar__brand-mark {
  display: none;
}

.admin-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0 1.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.admin-sidebar__nav::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.admin-sidebar__nav::-webkit-scrollbar-button {
  display: none;
}

.admin-nav-group {
  margin-top: 1rem;
  padding: 0 0.65rem;
}

.admin-nav-group:first-child {
  margin-top: 0.35rem;
}

.admin-nav-group__label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--admin-sidebar-heading);
  padding: 0.35rem 0.5rem 0.5rem;
}

.admin-nav__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--admin-sidebar-text);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.admin-nav__link:hover {
  color: var(--admin-sidebar-active-fg);
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.admin-nav__link.is-active {
  color: #fff;
  background: var(--admin-sidebar-active-bg);
  border-color: rgba(26, 128, 201, 0.32);
  font-weight: 700;
}

.admin-nav__link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--brand-blue), var(--brand-purple));
}

.admin-nav__link:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

.admin-sidebar__footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--admin-sidebar-border);
  font-size: 0.8rem;
  color: var(--admin-sidebar-heading);
}

.admin-sidebar__user {
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.admin-sidebar__logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
  font-weight: 600;
  font-size: 0.84rem;
  text-decoration: none;
}

.admin-sidebar__logout:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fecaca;
  text-decoration: none;
}

/* Main column */
.admin-main {
  flex: 1;
  margin-left: var(--admin-sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar__menu {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.admin-topbar__menu:hover {
  background: #eef2f7;
}

.admin-topbar__menu-line {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  margin: 3px 0;
}

.admin-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Tricolor strip at the top of every admin page — matches the homepage */
.admin-scroll::before {
  content: "";
  display: block;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg,
    var(--saffron) 0%, var(--saffron) 33.33%,
    #ffffff 33.33%, #ffffff 66.66%,
    var(--portal-green) 66.66%, var(--portal-green) 100%);
  flex-shrink: 0;
}

.admin-page {
  flex: 1;
  width: 100%;
  max-width: var(--admin-content-max);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.25rem;
}

.admin-page-header {
  margin: 0 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Page heading — both <h1> and the <h2.admin-page-heading> pattern get an accent bar treatment. */
.admin-page > h1:first-of-type,
.admin-page > h2.admin-page-heading:first-of-type,
.admin-page > .admin-page-header:first-child .admin-page-header__title {
  margin: 0 0 0.4rem;
  font-size: clamp(1.5rem, 2.5vw, 1.9rem);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.18;
  position: relative;
  padding-left: 0.95rem;
}

.admin-page > h1:first-of-type::before,
.admin-page > h2.admin-page-heading:first-of-type::before,
.admin-page > .admin-page-header:first-child .admin-page-header__title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--saffron), var(--saffron-dark));
}

/* sub-paragraph (only when it's a description, not a toolbar) after page heading */
.admin-page > h1:first-of-type + p.muted,
.admin-page > h2.admin-page-heading:first-of-type + p.muted {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.96rem;
  max-width: 72ch;
  padding-left: 0.95rem;
}

.admin-page .alert:first-child {
  margin-top: 0;
}

/* Cards — same polish as student-page */
.admin-page .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 1.25rem 1.35rem;
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.admin-page .card:hover {
  box-shadow: var(--shadow-sm);
}

.admin-page .card > h2:first-child,
.admin-page .card > h3:first-child {
  margin: 0 0 0.85rem;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-page .card > h2:first-child::before,
.admin-page .card > h3:first-child::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--saffron), var(--saffron-dark));
  box-shadow: 0 0 0 3px rgba(255, 153, 51, 0.18);
}

/* admin-section-title (used inside split layouts) */
.admin-section-title {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Stats */
.admin-page .stat-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.admin-page .stat {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin-bottom: 0.15rem;
}

/* Forms — same polish as student-page */
.admin-page label {
  display: block;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-soft);
  margin: 0.85rem 0 0.3rem;
}

.admin-page .card > form > label:first-child,
.admin-page .card label:first-of-type {
  margin-top: 0;
}

.admin-page input[type="text"],
.admin-page input[type="email"],
.admin-page input[type="url"],
.admin-page input[type="password"],
.admin-page input[type="number"],
.admin-page input[type="date"],
.admin-page input[type="datetime-local"],
.admin-page input[type="search"],
.admin-page input[type="tel"],
.admin-page input[type="file"],
.admin-page select,
.admin-page textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.93rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.admin-page input[type="file"] {
  padding: 0.5rem 0.6rem;
  background: var(--surface-muted);
}

.admin-page textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.admin-page input:focus,
.admin-page select:focus,
.admin-page textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.admin-page .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}

/* Tables — polished */
.admin-page .data-table {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  width: 100%;
}

.admin-page .card .data-table {
  border: none;
  border-radius: 0;
  background: transparent;
}

.admin-page .data-table thead th {
  background: linear-gradient(180deg, var(--surface-muted), #eef2f8);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.admin-page .data-table tbody td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
}

.admin-page .data-table tbody tr:last-child td { border-bottom: none; }

.admin-page .data-table tbody tr:hover {
  background: rgba(29, 78, 216, 0.035);
}

/* Badges */
.admin-page .badge-pill {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: capitalize;
  background: rgba(29, 78, 216, 0.1);
  color: var(--accent);
  border: 1px solid rgba(29, 78, 216, 0.2);
}

.admin-page .badge-pill.badge-warn {
  background: rgba(194, 65, 12, 0.1);
  color: var(--warn);
  border-color: rgba(194, 65, 12, 0.22);
}

.admin-page .badge-pill.badge-success,
.admin-page .badge-pill.badge-ok {
  background: rgba(21, 128, 61, 0.1);
  color: var(--success);
  border-color: rgba(21, 128, 61, 0.22);
}

.admin-page .badge-pill[class*="reject"],
.admin-page .badge-pill[class*="closed"],
.admin-page .badge-pill.badge-error,
.admin-page .badge-pill.badge-danger {
  background: rgba(185, 28, 28, 0.1);
  color: var(--error);
  border-color: rgba(185, 28, 28, 0.22);
}

/* Alerts */
.admin-page .alert {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  margin: 0 0 1rem;
  font-size: 0.92rem;
  line-height: 1.5;
}

.admin-page .alert-error,
.admin-page .alert.alert-error {
  background: var(--error-bg);
  border-color: #fecaca;
  color: #991b1b;
}

.admin-page .alert-success,
.admin-page .alert.alert-success {
  background: var(--success-bg);
  border-color: #a7f3d0;
  color: #065f46;
}

.admin-page .alert-info,
.admin-page .alert.alert-info {
  background: var(--info-bg);
  border-color: #a5f3fc;
  color: #155e75;
}

.admin-page .alert-warn,
.admin-page .alert.alert-warn {
  background: var(--warn-bg);
  border-color: #fed7aa;
  color: #9a3412;
}

/* Progress bar polish */
.admin-page .progress-bar {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  border: none;
}

.admin-page .progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Buttons inside admin pages — subtle hover lift */
.admin-page .btn {
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.admin-page .btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.admin-page .btn-primary:hover {
  box-shadow: 0 6px 14px rgba(29, 78, 216, 0.22);
}

/* Grids — restate to ensure consistent gaps inside admin */
.admin-page .grid { display: grid; gap: 1rem; }
@media (min-width: 800px) {
  .admin-page .grid-2 { grid-template-columns: 1fr 1fr; }
  .admin-page .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* Backdrop + mobile sidebar */
.admin-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.admin-shell--sidebar-open .admin-sidebar-backdrop {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .admin-shell--sidebar-open .admin-sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.25);
  }

  .admin-main {
    margin-left: 0;
  }

  .admin-topbar__menu {
    display: inline-flex;
    flex-direction: column;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 95;
  }
}

@media print {
  .admin-sidebar,
  .admin-sidebar-backdrop,
  .admin-topbar__menu {
    display: none !important;
  }

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

  .admin-page {
    padding: 0;
    max-width: none;
  }
}

/* --- Guest (admin login) layout --- */
.admin-body--guest {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(255, 153, 51, 0.14), transparent 60%),
    radial-gradient(1000px 500px at 10% 110%, rgba(19, 136, 8, 0.08), transparent 60%),
    linear-gradient(160deg, #eef2f8 0%, #f5f7fb 50%, #eef2f8 100%);
  position: relative;
}

.admin-body--guest::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 50;
  background: linear-gradient(90deg,
    var(--saffron) 0%, var(--saffron) 33.33%,
    #ffffff 33.33%, #ffffff 66.66%,
    var(--portal-green) 66.66%, var(--portal-green) 100%);
}

.admin-auth-header {
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
  margin-top: 4px;
}

.admin-auth-header .admin-auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.admin-auth-header .admin-auth-brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.admin-auth-header .auth-brand-logo,
.student-auth-header .auth-brand-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  display: block;
}

.admin-auth-header .auth-brand-mark,
.student-auth-header .auth-brand-mark {
  display: none;
}

.admin-auth-header .auth-brand-text,
.student-auth-header .auth-brand-text {
  font-weight: 800;
  color: var(--text);
}

.admin-auth-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1.25rem 3rem;
}

.admin-auth-inner {
  width: 100%;
  max-width: 520px;
}

.admin-auth-inner .alert {
  margin-bottom: 1rem;
}

/* Split page layouts (e.g. programs form + table) */
.admin-lead {
  margin: 0 0 1.25rem;
  max-width: 62ch;
}

.admin-layout-split {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 960px) {
  .admin-layout-split {
    grid-template-columns: minmax(300px, 420px) 1fr;
  }
}

.admin-form-grid {
  display: grid;
  gap: 0 1rem;
}

@media (min-width: 560px) {
  .admin-form-grid--2 {
    grid-template-columns: 1fr 1fr;
  }
}

.admin-form-grid .full-row {
  grid-column: 1 / -1;
}

.admin-table-wrap {
  overflow-x: auto;
  margin: 0 -0.15rem;
}

/* Dashboard */
.admin-dash-section {
  margin-top: 1.5rem;
}

.admin-dash-section:first-of-type {
  margin-top: 0;
}

.admin-dash-section__title {
  margin: 0 0 0.85rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.admin-dash-section__title::before {
  content: "";
  display: inline-block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-purple));
}

.admin-dash-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Admin per-student checklist review */
.admin-checklist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.admin-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.admin-checklist-item.is-done {
  background: rgba(21, 128, 61, 0.05);
  border-color: rgba(21, 128, 61, 0.3);
}

.admin-checklist-mark {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 2px solid #cbd5e1;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  color: transparent;
  margin-top: 0.1rem;
}

.admin-checklist-item.is-done .admin-checklist-mark {
  background: linear-gradient(135deg, var(--success), #166534);
  border-color: #166534;
  color: #fff;
}

.admin-checklist-body {
  flex: 1;
  min-width: 0;
}

.admin-checklist-label {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.admin-checklist-item.is-done .admin-checklist-label {
  color: #166534;
}

.admin-checklist-meta {
  font-size: 0.76rem;
  color: #15803d;
  font-weight: 600;
  margin-top: 0.2rem;
}

.admin-checklist-meta--pending {
  color: var(--muted);
}

.admin-dash-batches .card h3 {
  font-size: 1.05rem;
}
