/* Skips LMS — combined stylesheet (ported from the React app) */
/* =========================================================================
   CSS Design Tokens — Skips Online LMS
   ========================================================================= */

:root {
  /* Brand Colors */
  --color-primary: #002c44;
  --color-primary-light: #0b4566;
  --color-primary-dark: #001a2b;
  --color-accent: #e0961e;
  --color-accent-light: #eba63a;
  --color-accent-dark: #b8770e;

  /* Tints (flat, no gradients) */
  --tint-primary: rgba(0, 44, 68, 0.07);
  --tint-primary-strong: rgba(0, 44, 68, 0.12);
  --tint-accent: rgba(224, 150, 30, 0.12);

  /* Neutral Colors (cool slate) */
  --color-white: #ffffff;
  --color-gray-50: #f7f8fa;
  --color-gray-100: #f1f3f6;
  --color-gray-200: #e6e9ee;
  --color-gray-300: #d5dae1;
  --color-gray-400: #b3bbc6;
  --color-gray-500: #8b95a3;
  --color-gray-600: #667085;
  --color-gray-700: #475467;
  --color-gray-800: #283240;
  --color-gray-900: #121a26;

  /* Semantic Colors */
  --color-success: #13805c;
  --color-success-bg: #e6f5ee;
  --color-warning: #b4640a;
  --color-warning-bg: #fdf3e2;
  --color-danger: #c4372d;
  --color-danger-bg: #fdecea;
  --color-info: #1f6fb2;
  --color-info-bg: #e8f1fb;

  /* Surfaces */
  --surface-page: #f5f6f8;
  --surface-card: #ffffff;
  --border-subtle: #e8ebf0;
  --border-strong: #d5dae1;

  /* Text Colors */
  --text-primary: #121a26;
  --text-secondary: #475467;
  --text-muted: #687384;
  --text-on-primary: #ffffff;
  --text-on-accent: #ffffff;

  /* Typography */
  --font-heading: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.75rem;   /* 28px */
  --text-4xl: 2rem;      /* 32px */
  --text-5xl: 2.5rem;    /* 40px */

  --leading-tight: 1.25;
  --leading-normal: 1.55;
  --leading-relaxed: 1.75;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Spacing Scale */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.5rem;    /* 24px */
  --space-6: 2rem;      /* 32px */
  --space-8: 3rem;      /* 48px */
  --space-10: 4rem;     /* 64px */
  --space-12: 5rem;     /* 80px */

  /* Layout */
  --max-width: 1200px;
  --sidebar-width: 280px;

  /* Borders */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows: soft and layered, tinted toward the brand navy */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 14px 28px -8px rgba(16, 24, 40, 0.12), 0 4px 8px -4px rgba(16, 24, 40, 0.05);
  --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, 0.22);
  --ring: 0 0 0 4px rgba(0, 44, 68, 0.12);

  /* Motion: one easing curve everywhere so the app feels consistent */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --transition-fast: 160ms var(--ease-out);
  --transition-base: 260ms var(--ease-out);
  --transition-slow: 420ms var(--ease-out);

  /* Z-Index Scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-toast: 600;
}

/* =========================================================================
   Global Styles — Skips Online LMS
   ========================================================================= */

/* Reset */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--surface-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01';
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

#root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.015em;
  color: var(--color-gray-900);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

p {
  margin-bottom: var(--space-3);
  color: var(--text-secondary);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-light);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul, ol {
  list-style: none;
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Selection color */
::selection {
  background-color: var(--color-accent);
  color: var(--color-white);
}

/* Scrollbar styling: thin and quiet */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-gray-300) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-gray-300);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-gray-400);
}

/* Layout utilities */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.page-content {
  flex: 1;
  padding: var(--space-6) var(--space-5) var(--space-8);
  margin-top: var(--navbar-height);
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }

/* Grid utilities */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Text utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-muted { color: var(--text-muted); }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Spacing utilities */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }

/* Width utilities */
.w-full { width: 100%; }

/* Responsive grid breakpoints */
@media (max-width: 768px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }

  .page-content {
    padding: var(--space-4) var(--space-4) var(--space-6);
  }

  h1 { font-size: var(--text-2xl); }
  h2 { font-size: var(--text-xl); }
  h3 { font-size: var(--text-lg); }
}

@media (min-width: 576px) and (max-width: 768px) {
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Animation keyframes */
/* Animations end on "transform: none" on purpose: a leftover transform on a page wrapper
   would trap position:fixed children (popups, backdrops) inside that wrapper. */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes fadeOnly {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(16px) scale(0.98); }
}

@keyframes growX {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in {
  animation: fadeIn var(--transition-slow) both;
}

.animate-slide-right {
  animation: slideInRight var(--transition-base) both;
}

/* =========================================================================
   Component Styles — Skips Online LMS
   ========================================================================= */

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast),
              color var(--transition-fast), box-shadow var(--transition-fast), transform 120ms var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--text-on-primary);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-light);
  border-color: var(--color-primary-light);
  color: var(--text-on-primary);
  box-shadow: var(--shadow-md);
}

.btn-accent {
  background-color: var(--color-accent);
  color: var(--text-on-accent);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-xs);
}

.btn-accent:hover:not(:disabled) {
  background-color: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
  color: var(--text-on-accent);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background-color: var(--color-white);
  color: var(--color-primary);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--color-primary);
  background-color: var(--tint-primary);
  color: var(--color-primary);
}

.btn-danger {
  background-color: var(--color-danger);
  color: var(--color-white);
  border-color: var(--color-danger);
}

.btn-danger:hover:not(:disabled) {
  background-color: #a92d24;
  border-color: #a92d24;
  color: var(--color-white);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--color-gray-100);
  color: var(--text-primary);
}

.btn-sm {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  min-height: 48px;
  padding: 0 var(--space-6);
  font-size: var(--text-base);
}

.btn-icon {
  padding: 0;
  width: 38px;
  min-height: 38px;
  height: 38px;
}

/* Submit in progress: keeps the button size, shows a spinner */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading > * {
  visibility: hidden;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-color: rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-ghost.is-loading::after,
.btn-outline.is-loading::after {
  border-color: var(--color-gray-300);
  border-top-color: var(--color-primary);
}

/* ---------------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------------- */
.card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

.card-body {
  padding: var(--space-5);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-heading);
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  color: var(--text-primary);
}

.card-header i {
  color: var(--color-primary);
  margin-right: var(--space-1);
}

.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background-color: var(--color-gray-50);
}

.card-thumbnail {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background-color: var(--color-gray-200);
}

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  min-height: 42px;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background-color: var(--color-white);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--color-gray-400);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--ring);
}

.form-select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

/* File pickers: a tidy drop area instead of the browser's default */
.form-input[type='file'] {
  padding: var(--space-3);
  border-style: dashed;
  background-color: var(--color-gray-50);
  cursor: pointer;
  color: var(--text-secondary);
}

.form-input[type='file']:hover {
  border-color: var(--color-primary);
  background-color: var(--tint-primary);
}

.form-input[type='file']::file-selector-button {
  margin-right: var(--space-3);
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  color: var(--color-primary);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.form-input[type='file']:hover::file-selector-button {
  border-color: var(--color-primary);
}

input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input.error,
.form-textarea.error {
  border-color: var(--color-danger);
}

.form-error {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-danger);
}

.form-textarea {
  min-height: 100px;
  padding: var(--space-3);
  line-height: var(--leading-normal);
  resize: vertical;
}

/* ---------------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------------- */
.table-container {
  overflow-x: auto;
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background-color: transparent;
}

.table th,
.table td {
  padding: 14px var(--space-4);
  text-align: left;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.table th {
  background-color: var(--color-gray-50);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.table tbody tr {
  transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
  background-color: var(--color-gray-50);
}

.table tr:last-child td {
  border-bottom: none;
}

/* ---------------------------------------------------------------------------
   Badges / Tags
   --------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  letter-spacing: 0.01em;
  border-radius: var(--radius-full);
  white-space: nowrap;
  text-transform: capitalize;
}

.badge-primary {
  background-color: var(--tint-primary);
  color: var(--color-primary);
}

.badge-accent {
  background-color: var(--tint-accent);
  color: var(--color-accent-dark);
}

.badge-success {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.badge-warning {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-danger {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
}

/* ---------------------------------------------------------------------------
   Progress Bar
   --------------------------------------------------------------------------- */
.progress {
  height: 6px;
  background-color: var(--color-gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transform-origin: left center;
  animation: growX 900ms var(--ease-out) both;
  transition: width var(--transition-slow);
}

/* ---------------------------------------------------------------------------
   Tabs
   --------------------------------------------------------------------------- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-1);
}

.tab {
  position: relative;
  padding: var(--space-3) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition-fast);
  white-space: nowrap;
}

.tab::after {
  content: '';
  position: absolute;
  left: var(--space-2);
  right: var(--space-2);
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--color-primary);
  transform: scaleX(0);
  transition: transform var(--transition-base);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--color-primary);
  font-weight: var(--weight-semibold);
}

.tab.active::after {
  transform: scaleX(1);
}

.tab-content {
  padding: var(--space-4) 0;
}

/* Tab panels fade in when switched */
[data-tab-panel]:not([hidden]) {
  animation: fadeOnly var(--transition-base) both;
}

/* ---------------------------------------------------------------------------
   Toast Notifications
   --------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: calc(var(--navbar-height) + var(--space-4));
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background-color: var(--color-white);
  box-shadow: var(--shadow-lg);
  animation: slideInRight var(--transition-slow) both;
  min-width: 300px;
  max-width: 420px;
  pointer-events: auto;
}

.toast.is-leaving {
  animation: toastOut 220ms var(--ease-in-out) forwards;
}

.toast > i:first-child {
  font-size: var(--text-lg);
}

.toast-message {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.toast-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-lg);
  line-height: 1;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.toast-close:hover {
  background: var(--color-gray-100);
  color: var(--text-primary);
}

@media (max-width: 576px) {
  .toast-container {
    left: var(--space-3);
    right: var(--space-3);
  }

  .toast {
    min-width: 0;
    max-width: none;
  }
}

/* ---------------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(10, 18, 30, 0.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeOnly var(--transition-base) both;
}

.modal {
  display: flex;
  flex-direction: column;
  background-color: var(--color-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 2 * var(--space-6));
  overflow: hidden; /* header + footer stay put, the body scrolls */
  z-index: var(--z-modal);
  animation: scaleIn var(--transition-slow) both;
}

.modal > .modal-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.modal > .modal-header,
.modal > .modal-footer { flex-shrink: 0; }

/* Closing: quick fade-out before the page changes (app.js) */
.modal-backdrop.is-leaving { animation: fadeOnly 180ms var(--ease-in-out) reverse both; }
.modal-backdrop.is-leaving .modal { animation: scaleIn 180ms var(--ease-in-out) reverse both; }

/* A page that opens with a popup skips its fade-in, so nothing can move under the popup */
.animate-fade-in:has(.modal-backdrop) { animation: none; }

/* No background scrolling while a popup is open */
body:has(.modal-backdrop:not([hidden])),
body:has(.confirm-backdrop) { overflow: hidden; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-size: var(--text-lg);
  margin: 0;
}

.modal-body {
  padding: var(--space-5);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background-color: var(--color-gray-50);
}

/* ---------------------------------------------------------------------------
   Empty State
   --------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-4);
  text-align: center;
  background: var(--surface-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty-state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: var(--tint-primary);
  font-size: 1.75rem;
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 400px;
  margin-bottom: var(--space-5);
}

/* ---------------------------------------------------------------------------
   Loading Spinner
   --------------------------------------------------------------------------- */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-gray-200);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* ---------------------------------------------------------------------------
   Collapsible / Accordion
   --------------------------------------------------------------------------- */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  user-select: none;
  transition: background-color var(--transition-fast);
  border-radius: var(--radius-sm);
}

.collapsible-header:hover {
  background-color: var(--color-gray-100);
}

.collapsible-icon {
  transition: transform var(--transition-fast);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.collapsible-icon.open {
  transform: rotate(90deg);
}

.collapsible-body {
  padding: 0 var(--space-4) var(--space-3);
}

/* ---------------------------------------------------------------------------
   Page Header
   --------------------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.page-header h1,
.page-header h2 {
  margin: 0;
  font-size: var(--text-3xl);
}

@media (max-width: 768px) {
  .page-header h1,
  .page-header h2 {
    font-size: var(--text-2xl);
  }
}

.page-header-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}
/* =========================================================================
   Login / set-password
   One screen high at every size (no page scroll); spacing and type scale
   with the viewport so the layout keeps its proportions.
   ========================================================================= */

.login-page {
  --navy: #003C57;
  --navy-deep: #00283b;
  --gold: #DEAB30;
  --ink: #0f1f2b;
  --muted: #5b6b78;
  --line: #d5dde3;

  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(360px, 32vw, 460px);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--navy-deep) url('../img/campus.jpg') 30% center / cover no-repeat;
  position: relative;
  isolation: isolate;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(0, 32, 48, 0.82);
}

/* ---- Left: branding --------------------------------------------------- */
.login-left {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 0;
  padding: clamp(24px, 5.5vh, 56px) clamp(24px, 5vw, 80px);
  color: #fff;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand-logo {
  width: clamp(38px, 5vh, 46px);
  height: clamp(38px, 5vh, 46px);
  padding: 5px;
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.login-brand-name {
  font-family: 'Poppins', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}

.login-brand-name span {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.7);
}

.login-hero { max-width: 34rem; }

.login-hero::before {
  content: '';
  display: block;
  width: 48px;
  height: 3px;
  margin-bottom: clamp(14px, 2.6vh, 22px);
  background: var(--gold);
}

.login-hero h1 {
  margin: 0 0 clamp(10px, 2vh, 18px);
  color: #fff;
  font-size: clamp(1.75rem, 1.2rem + 1.6vw + 0.8vh, 2.9rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.login-hero p {
  margin: 0 0 clamp(14px, 3vh, 26px);
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(0.95rem, 0.85rem + 0.3vw, 1.05rem);
  line-height: 1.6;
}

.login-features {
  margin: 0;
  padding: 0;
  list-style: none;
}

.login-features li {
  position: relative;
  padding: clamp(6px, 1.2vh, 10px) 0 clamp(6px, 1.2vh, 10px) 18px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.93rem;
}

.login-features li + li { border-top: 1px solid rgba(255, 255, 255, 0.12); }

.login-features li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  background: var(--gold);
}

.login-left-footer {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.78rem;
}

/* ---- Right: form -------------------------------------------------------- */
.login-right {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: clamp(16px, 4vh, 40px) clamp(16px, 2.5vw, 40px);
}

.login-form {
  width: 100%;
  max-width: 400px;
  padding: clamp(24px, 4.5vh, 40px) clamp(22px, 2.4vw, 36px);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.45);
  animation: scaleIn 520ms var(--ease-out) both;
}

.login-form-header { margin-bottom: clamp(18px, 3.4vh, 28px); }

.login-form-header h2 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.login-form-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-left: 3px solid #c62828;
  background: #fdecec;
  color: #8e1c1c;
  font-size: 0.86rem;
  line-height: 1.45;
}

.login-error i { margin-top: 2px; }

.login-form .form-group { margin-bottom: clamp(12px, 2.2vh, 18px); }

.login-form .form-label {
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
}

.login-input-wrapper { position: relative; }

.login-input-wrapper > i {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #8a98a3;
  font-size: 0.85rem;
  pointer-events: none;
}

.login-input-wrapper .form-input {
  height: clamp(42px, 5.6vh, 46px);
  padding: 0 42px 0 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink);
  font-size: 0.93rem;
}

.login-input-wrapper .form-input::placeholder { color: #9aa7b1; }

.login-input-wrapper .form-input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(0, 60, 87, 0.14);
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: #6b7a86;
  cursor: pointer;
}

.password-toggle:hover { color: var(--navy); }
.password-toggle:focus-visible { outline: 2px solid var(--navy); outline-offset: -2px; }

.login-form .btn-login {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: clamp(42px, 5.6vh, 46px);
  margin-top: clamp(4px, 1vh, 8px);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--navy);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition-fast), transform 120ms var(--ease-out);
}

.login-form .btn-login:active { transform: scale(0.98); }

.login-form .btn-login:hover { background: #00506f; }
.login-form .btn-login:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.login-help {
  margin: clamp(16px, 3vh, 24px) 0 0;
  padding-top: clamp(12px, 2.4vh, 18px);
  border-top: 1px solid #e8edf0;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.login-help a { color: var(--navy); font-weight: 600; text-decoration: none; }
.login-help a:hover { text-decoration: underline; }

/* Short laptop screens: drop the feature list, keep everything on one screen */
@media (min-width: 961px) and (max-height: 700px) {
  .login-features { display: none; }
}

/* Tablet & phone: one column — logo on top, form below */
@media (max-width: 960px) {
  .login-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    background-position: center;
  }
  .login-page::before { background: rgba(0, 32, 48, 0.86); }
  .login-left { padding: clamp(18px, 3.5vh, 32px) 20px 0; }
  .login-hero, .login-left-footer { display: none; }
  .login-right { padding: 16px 16px clamp(16px, 4vh, 40px); }
}

/* Very short screens (phones in landscape): allow scrolling inside the page
   rather than cutting off the form. */
@media (max-height: 520px) {
  .login-page { overflow-y: auto; }
  .login-right { align-items: flex-start; }
}

/* Admin Dashboard */

.admin-dashboard {
  max-width: var(--max-width);
  margin: 0 auto;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

.admin-stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.admin-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  flex-shrink: 0;
}

/* Flat tinted icon chips (used by stat cards) */
.tone-primary { background: var(--tint-primary); color: var(--color-primary); }
.tone-accent  { background: var(--tint-accent); color: var(--color-accent-dark); }
.tone-success { background: var(--color-success-bg); color: var(--color-success); }
.tone-violet  { background: #f1ebfa; color: #7a3fb8; }
.tone-info    { background: var(--color-info-bg); color: var(--color-info); }

.admin-stat-info {
  display: flex;
  flex-direction: column;
}

.admin-stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-heading);
  color: var(--text-primary);
  line-height: 1;
}

.admin-stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* Activity list */
.activity-list {
  padding: 0;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-gray-100);
  transition: background var(--transition-fast);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-item:hover {
  background: var(--color-gray-50);
}

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(0, 44, 68, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  color: var(--color-primary);
  flex-shrink: 0;
}

.activity-info {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  align-items: baseline;
}

.activity-user {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.activity-type {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-transform: capitalize;
}

.activity-course {
  font-size: var(--text-xs);
  color: var(--color-accent-dark);
  background: rgba(224, 150, 30, 0.1);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.activity-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 576px) {
  .admin-stats-grid {
    grid-template-columns: 1fr;
  }
}
/* =========================================================================
   Student Dashboard
   ========================================================================= */

.student-dashboard {
  max-width: var(--max-width);
  margin: 0 auto;
}

.dashboard-greeting {
  margin-bottom: var(--space-6);
}

.dashboard-eyebrow {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent-dark);
}

.dashboard-greeting h1 {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-1);
  color: var(--text-primary);
}

.dashboard-greeting p {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin: 0;
}

/* Stats Row */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.stat-value {
  display: block;
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  line-height: 1.15;
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
}

/* Section Title */
.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xl);
  margin-bottom: var(--space-5);
  color: var(--text-primary);
}

.section-title i {
  color: var(--color-accent);
  font-size: var(--text-base);
}

/* Courses Grid */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-5);
}

.course-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.course-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
  color: inherit;
}

.course-card:active {
  transform: translateY(-1px);
}

.course-card-thumbnail {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--color-gray-100);
}

.course-card-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 700ms var(--ease-out), opacity var(--transition-slow);
}

.course-card:hover .course-card-thumbnail img {
  transform: scale(1.04);
}

.course-card-placeholder {
  width: 100%;
  height: 100%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: rgba(255, 255, 255, 0.22);
}

.course-card-badge {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
}

/* Badges sitting on a picture get a solid white pill so they stay readable */
.course-card-badge .badge {
  background: var(--color-white);
  box-shadow: var(--shadow-md);
}

.course-card .card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.course-card-title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-5);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card-progress {
  margin-top: auto;
}

.course-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-primary);
}

.course-card-cta i {
  transition: transform var(--transition-base);
}

.course-card:hover .course-card-cta i {
  transform: translateX(4px);
}

/* Responsive */
@media (max-width: 768px) {
  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .courses-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-greeting h1 {
    font-size: var(--text-2xl);
  }
}
/* =========================================================================
   Course View
   ========================================================================= */

.course-view {
  --course-sidebar-w: 360px;
  --stage-pad: var(--space-4);
  /* screen height minus navbar, course header (57px) and the stage padding */
  --stage-h: calc(100dvh - var(--navbar-height) - 57px - var(--stage-pad) * 2);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--navbar-height));
  height: calc(100dvh - var(--navbar-height));
  margin-top: var(--navbar-height);
  background: var(--surface-page);
  overflow: hidden;
}

.course-view-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 56px;
  padding: var(--space-2) var(--space-4);
  background: var(--color-white);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.course-view-header h2 {
  flex: 1;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  margin: 0;
}

.sidebar-toggle {
  display: none !important;
}

/* Body layout */
.course-view-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.course-main {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scroll-behavior: smooth;
}

/* Video / Content Player */
.content-player {
  background: #0a0f16;
  width: 100%;
  animation: fadeOnly var(--transition-slow) both;
}

/* The video always fits on screen: its width is limited by the height that is
   left under the navbar + course header ("Fit"). "Wide" uses the full width. */
.video-stage {
  display: flex;
  justify-content: center;
  padding: var(--stage-pad);
  background: #0a0f16;
  transition: padding var(--transition-base);
}

.video-container {
  position: relative;
  width: min(100%, max(420px, calc(var(--stage-h) * 16 / 9)));
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
  transition: width var(--transition-slow), border-radius var(--transition-base);
}

.course-view.is-video-wide .video-stage { padding: 0; }
.course-view.is-video-wide .video-container { width: 100%; border-radius: 0; box-shadow: none; }

/* Header controls: Fit / Wide + hide lessons */
.player-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--color-gray-100);
  border: 1px solid var(--border-subtle);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.segmented button:hover { color: var(--text-primary); }
.segmented button[aria-pressed='true'] { background: var(--color-white); color: var(--color-primary); box-shadow: var(--shadow-sm); }

[data-toggle-focus][aria-pressed='true'] { background: var(--tint-primary); color: var(--color-primary); }

/* Drag handle between the lesson and the lessons panel */
.sidebar-resizer {
  position: relative;
  flex: 0 0 6px;
  margin: 0 -3px;
  z-index: 2;
  cursor: col-resize;
  touch-action: none;
}

.sidebar-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 2px;
  background: transparent;
  transition: background-color var(--transition-fast);
}

.sidebar-resizer:hover::after,
.sidebar-resizer:focus-visible::after,
.course-view.is-resizing .sidebar-resizer::after { background: var(--color-accent); }
.sidebar-resizer:focus-visible { outline: none; }

.course-view.is-resizing { cursor: col-resize; user-select: none; }
.course-view.is-resizing iframe,
.course-view.is-resizing video { pointer-events: none; } /* the player would swallow the drag */

/* No sliding on first paint while saved preferences are applied */
.course-view.no-anim *,
.course-view.no-anim { transition: none !important; }

.video-player {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
}

.content-link-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: var(--space-8) var(--space-6);
  background: var(--color-gray-100);
  text-align: center;
  gap: var(--space-3);
}

.content-link-panel > i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-white);
  box-shadow: var(--shadow-md);
  font-size: 1.75rem;
  color: var(--color-primary);
}

.content-link-panel h3 {
  font-size: var(--text-xl);
  margin: 0;
}

.content-link-panel p {
  margin: 0;
}

/* Content info */
.content-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-white);
  border-bottom: 1px solid var(--border-subtle);
}

.content-info h3 {
  font-size: var(--text-lg);
  margin: 0 0 var(--space-1);
}

.content-info-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Previous / next lesson */
.lesson-nav {
  display: flex;
  gap: var(--space-2);
}

.lesson-nav .btn {
  max-width: 220px;
}

.lesson-nav .btn span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Notes / lab panels under the player */
.notes-panel {
  margin: var(--space-4) var(--space-5);
  padding: var(--space-5);
  background: var(--color-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  scroll-margin-top: var(--space-4);
}

.notes-panel h4 {
  font-size: var(--text-base);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.notes-panel h4 > i {
  color: var(--color-accent);
}

@media (max-width: 768px) {
  .content-info { padding: var(--space-4); }
  .notes-panel { margin: var(--space-3); padding: var(--space-4); }
  .lesson-nav { width: 100%; }
  .lesson-nav .btn { flex: 1; max-width: none; }
}

/* Course Sidebar */
.course-sidebar {
  width: var(--course-sidebar-w);
  min-width: var(--course-sidebar-w);
  background: var(--color-white);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-right 320ms var(--ease-out);
}

/* "Hide lessons": slide the panel out so the video gets the whole width */
@media (min-width: 769px) {
  .course-view.is-focus .course-sidebar { margin-right: calc(-1 * var(--course-sidebar-w)); }
  .course-view.is-focus .sidebar-resizer { display: none; }
}

.course-sidebar .tabs {
  flex-shrink: 0;
  padding: 0 var(--space-2);
  overflow-x: auto;
}

.course-sidebar .tab {
  padding: var(--space-3) var(--space-2);
  font-size: 13px;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Chapters list */
.chapter-group {
  border-bottom: 1px solid var(--border-subtle);
}

.chapter-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  background: var(--color-gray-50);
  border-bottom: 1px solid var(--border-subtle);
}

.chapter-header i {
  color: var(--color-accent);
  font-size: var(--text-xs);
}

.subtopics-list {
  padding: var(--space-1) 0;
}

.subtopic-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 10px var(--space-4) 10px var(--space-6);
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: left;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  font-family: var(--font-body);
  scroll-margin: var(--space-8) 0;
}

.subtopic-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--color-accent);
  transform: scaleY(0);
  transition: transform var(--transition-base);
}

.subtopic-item:hover {
  background-color: var(--color-gray-50);
  color: var(--text-primary);
}

.subtopic-item.active {
  background-color: var(--tint-primary);
  color: var(--color-primary);
  font-weight: var(--weight-semibold);
}

.subtopic-item.active::before {
  transform: scaleY(1);
}

.subtopic-item i {
  width: 16px;
  text-align: center;
  font-size: var(--text-xs);
  flex-shrink: 0;
  color: var(--text-muted);
}

.subtopic-item.active i {
  color: var(--color-primary);
}

.subtopic-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtopic-duration {
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Resource list */
.resource-list {
  padding: var(--space-2);
}

.resource-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color var(--transition-fast);
}

.resource-item:hover {
  background-color: var(--color-gray-50);
  color: var(--text-primary);
}

.resource-item:hover .resource-arrow {
  transform: translateX(3px);
  color: var(--color-primary);
}

.resource-item .badge {
  margin-top: 4px;
}

.resource-item > i:first-child {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--tint-primary);
  color: var(--color-primary);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.resource-item > div {
  flex: 1;
  min-width: 0;
}

.resource-title {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-chapter {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.resource-arrow {
  color: var(--text-muted);
  font-size: var(--text-xs);
  flex-shrink: 0;
  transition: transform var(--transition-base), color var(--transition-fast);
}

/* Notes list */
.notes-list {
  padding: var(--space-2);
}

.note-item {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  animation: fadeIn var(--transition-base) both;
}

.notes-panel .note-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-gray-50);
}

.note-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.note-timestamp {
  font-size: var(--text-xs);
  color: var(--color-accent);
  font-weight: var(--weight-medium);
}

.note-chapter {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.note-meta .btn {
  margin-left: auto;
}

.note-content {
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin: 0;
  white-space: pre-wrap;
}

.sidebar-overlay {
  display: none;
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex !important;
  }

  .player-controls,
  .sidebar-resizer { display: none; }

  .course-view { --stage-pad: 0px; }
  .video-container { width: 100%; border-radius: 0; box-shadow: none; }

  .course-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 88%;
    min-width: 0;
    max-width: 380px;
    z-index: var(--z-modal);
    transform: translateX(105%);
    transition: transform 360ms var(--ease-out);
    box-shadow: var(--shadow-xl);
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    margin-top: 0;
  }

  .course-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(10, 18, 30, 0.45);
    z-index: calc(var(--z-modal) - 1);
    animation: fadeOnly var(--transition-base) both;
  }
}

/* ---------------------------------------------------------------------------
   PHP version additions
   --------------------------------------------------------------------------- */
[hidden] { display: none !important; }
.inline-form { display: inline; margin: 0; }
.toast-icon-success { color: var(--color-success); }
.toast-icon-error { color: var(--color-danger); }
.toast-icon-warning { color: var(--color-warning); }
.toast-icon-info { color: var(--color-info); }
a.modal-close-link { text-decoration: none; }
.video-container iframe,
.video-container video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; background: #000; object-fit: contain; }
.form-error { color: var(--color-danger); font-size: var(--text-sm); margin-top: var(--space-1); }
.install-card { max-width: 520px; margin: 40px auto; }
a.subtopic-item { text-decoration: none; color: inherit; }

/* ---------------------------------------------------------------------------
   Course content reordering (admin)
   --------------------------------------------------------------------------- */
.sort-block {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--color-gray-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  scroll-margin-top: calc(var(--navbar-height, 64px) + 16px);
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.sort-block:target { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(224, 150, 30, 0.15); }
.sort-subtopics { padding-left: var(--space-5); min-height: 12px; border-radius: var(--radius-sm); }
.sort-row { padding: var(--space-2) var(--space-1); border-bottom: 1px solid var(--color-gray-200); background: transparent; }
.sort-row:last-child { border-bottom: 0; }
.sort-handle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 26px; border-radius: 4px;
  color: var(--color-gray-400, #9ca3af); cursor: grab; user-select: none;
}
.sort-handle:hover { background: var(--color-gray-200); color: var(--color-primary); }
.sort-number {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--color-primary); color: #fff; font-size: 11px; font-weight: 700;
}
.sort-arrow { padding-left: 8px; padding-right: 8px; }
.sort-arrow:disabled { opacity: 0.3; cursor: default; }
.sort-empty { margin: 0; padding: var(--space-2) 0; }
[data-sort-item].dragging { opacity: 0.45; }
[data-sort-list].drop-target { outline: 2px dashed var(--color-accent); outline-offset: 4px; }
@media (hover: none) { .sort-handle { display: none; } } /* touch screens: use the arrow buttons */

/* ---------------------------------------------------------------------------
   Installable app (PWA)
   --------------------------------------------------------------------------- */

.login-install {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 12px; padding: 9px; border: 1px solid #d5dde3; border-radius: 4px;
  background: #fff; color: #003C57; font-size: 0.86rem; font-weight: 600; cursor: pointer;
}
.login-install:hover { border-color: #003C57; }

.ios-install-hint {
  display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-4); padding: 10px 14px;
  border-left: 3px solid #DEAB30; border-radius: 4px; background: #fff8e6; color: #5c4400; font-size: 0.88rem;
}
.ios-install-hint > i:first-child { color: #003C57; font-size: 1.1rem; }
.ios-install-hint span { flex: 1; }
.ios-install-close { border: 0; background: none; font-size: 1.3rem; line-height: 1; color: #8a6a1a; cursor: pointer; }

/* Running as an installed app: respect the phone notch / home bar */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ---------------------------------------------------------------------------
   Smooth navigation
   --------------------------------------------------------------------------- */

/* Cross-fade between pages in browsers that support it (others just navigate). */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 220ms;
  animation-timing-function: var(--ease-out);
}

::view-transition-group(sidenav) {
  animation: none;
}

/* Slim bar at the top while the next page loads (added by app.js) */
.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: calc(var(--z-toast) + 1);
  background: var(--color-accent);
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  pointer-events: none;
}

.page-progress.is-active {
  opacity: 1;
  transform: scaleX(0.85);
  transition: transform 8s cubic-bezier(0.1, 0.7, 0.2, 1), opacity 120ms linear;
}

/* Pictures fade in once loaded instead of popping in (class set by app.js) */
img.img-fade {
  opacity: 0;
  transition: opacity var(--transition-slow), transform 700ms var(--ease-out);
}

img.img-fade.is-loaded {
  opacity: 1;
}

/* Respect "reduce motion" in the OS: keep everything, drop the movement. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }

  @view-transition {
    navigation: none;
  }
}

/* ---------------------------------------------------------------------------
   Forms: hints, required marks, locked fields
   --------------------------------------------------------------------------- */
.req { color: var(--color-danger); font-weight: var(--weight-semibold); }
.form-hint { margin: 6px 0 0; font-size: var(--text-xs); color: var(--text-muted); line-height: 1.5; }
.mb-0 { margin-bottom: 0; }
.text-danger { color: var(--color-danger); font-weight: var(--weight-semibold); }
.form-input.error, .form-select.error { border-color: var(--color-danger); box-shadow: 0 0 0 4px rgba(196, 55, 45, 0.1); }
.form-locked { position: relative; }
.form-locked .form-input { padding-right: 36px; background: var(--color-gray-50); color: var(--text-secondary); cursor: not-allowed; box-shadow: none; }
.form-locked .form-input:hover { border-color: var(--border-strong); }
.form-locked > i { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-size: var(--text-xs); color: var(--text-muted); }
.inline-check { display: inline-flex; align-items: center; gap: 6px; margin-left: var(--space-2); color: var(--text-secondary); cursor: pointer; }
.progress-bar.is-complete { background: var(--color-success); }

/* ---------------------------------------------------------------------------
   Profile
   --------------------------------------------------------------------------- */
.profile-page { max-width: var(--max-width); margin: 0 auto; }

.profile-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.profile-summary {
  position: sticky;
  top: calc(var(--navbar-height) + var(--space-5));
  text-align: center;
}

.profile-photo-frame {
  position: relative;
  width: 140px;
  aspect-ratio: 35 / 45; /* passport proportions */
  margin: 0 auto var(--space-4);
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--color-gray-100);
  box-shadow: 0 0 0 4px var(--color-white), 0 0 0 5px var(--border-subtle), var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.profile-photo-frame > i { font-size: 3rem; color: var(--color-gray-300); }
.profile-photo-frame.is-empty { border: 2px dashed var(--border-strong); box-shadow: none; }
.profile-photo-frame img:not([hidden]) + i { display: none; }

.profile-summary-name { font-size: var(--text-lg); margin: 0 0 2px; word-break: break-word; }
.profile-summary-email { font-size: var(--text-sm); color: var(--text-muted); margin: 0 0 var(--space-5); word-break: break-all; }

.profile-meter { text-align: left; }
.profile-meter-value { font-family: var(--font-heading); font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--color-primary); font-variant-numeric: tabular-nums; }
.profile-meter .progress { height: 8px; }

.profile-checklist { margin: var(--space-4) 0 0; padding: 0; text-align: left; }
.profile-checklist li > a,
.profile-checklist li > span {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: background-color var(--transition-fast);
}
.profile-checklist li > a:hover { background: var(--color-gray-50); color: var(--text-primary); }
.profile-checklist li > * > span:first-of-type { flex: 1; }
.profile-checklist i { font-size: 13px; color: var(--color-gray-300); }
.profile-checklist li.is-done i { color: var(--color-success); }
.profile-checklist li.is-done > * { color: var(--text-muted); }
.profile-checklist .badge { font-size: 10.5px; padding: 1px 8px; }

.profile-form { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.profile-section { scroll-margin-top: calc(var(--navbar-height) + var(--space-4)); }
.profile-section:target { border-color: var(--color-accent); box-shadow: 0 0 0 4px var(--tint-accent); }
.profile-section .form-group:last-child { margin-bottom: 0; }
.profile-section .grid .form-group { margin-bottom: 0; }

.profile-notice {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid #f3dcb0;
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-md);
  background: #fffaf0;
  color: #6b4a0e;
  font-size: var(--text-sm);
  line-height: 1.55;
}
.profile-notice > i { margin-top: 2px; font-size: var(--text-lg); color: var(--color-accent); }

.profile-photo-field { margin-bottom: var(--space-4); padding-bottom: var(--space-4); border-bottom: 1px solid var(--border-subtle); }

/* Education rows */
.edu-list { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-3); }
.edu-row {
  position: relative;
  padding: var(--space-4);
  padding-right: 48px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-gray-50);
  animation: fadeIn var(--transition-base) both;
}
.edu-row.is-leaving { animation: toastOut 200ms var(--ease-in-out) forwards; }
.edu-grid { display: grid; grid-template-columns: 1fr 2fr 2fr 1fr 1fr; gap: var(--space-3); }
.edu-grid .form-group { margin: 0; }
.edu-grid .form-label { font-size: var(--text-xs); color: var(--text-secondary); }
.edu-remove { position: absolute; top: var(--space-2); right: var(--space-2); }

.profile-savebar {
  position: sticky;
  bottom: var(--space-4);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg);
}

/* Read-only details (admin view) */
.detail-list { margin: 0; }
.detail-row { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: var(--space-3); padding: 10px 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); }
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { color: var(--text-muted); }
.detail-row dd { margin: 0; color: var(--text-primary); font-weight: var(--weight-medium); word-break: break-word; }
.certificate-card { text-align: left; padding: var(--space-3) var(--space-4); border: 1px solid #f3dcb0; border-radius: var(--radius-md); background: #fffaf0; }
.certificate-card .detail-row { grid-template-columns: 70px minmax(0, 1fr); padding: 6px 0; border-color: #f3e3c4; }
.certificate-card-label { display: block; margin-bottom: 4px; font-size: 11px; font-weight: var(--weight-semibold); letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-accent-dark); }

/* Users table: small completion meter */
.table-meter { display: flex; align-items: center; gap: var(--space-2); color: inherit; }
.table-meter .progress { flex: 1; display: block; height: 6px; min-width: 60px; }
.table-meter .progress-bar { display: block; }

/* Dashboard: "complete your profile" prompt */
.profile-prompt {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
}
.profile-prompt:hover { color: var(--text-primary); border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.profile-prompt.is-urgent { border-left: 4px solid var(--color-accent); }
.profile-prompt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-prompt-body strong { font-family: var(--font-heading); font-weight: var(--weight-semibold); }
.profile-prompt-body span { font-size: var(--text-sm); color: var(--text-muted); }
.profile-prompt-ring { position: relative; flex-shrink: 0; width: 56px; height: 56px; }
.profile-prompt-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.profile-prompt-ring circle { fill: none; stroke-width: 3.5; }
.ring-track { stroke: var(--color-gray-200); }
.ring-value { stroke: var(--color-accent); stroke-linecap: round; animation: ringIn 1s var(--ease-out) both; }
@keyframes ringIn { from { stroke-dasharray: 0 100; } }
.profile-prompt-ring span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: var(--weight-semibold); color: var(--text-primary); }


@media (max-width: 960px) {
  .profile-layout { grid-template-columns: 1fr; }
  .profile-summary { position: static; }
  .edu-grid { grid-template-columns: 1fr 1fr; }
  .edu-grid .edu-wide { grid-column: span 2; }
}

@media (max-width: 576px) {
  .profile-prompt { flex-wrap: wrap; }
  .profile-prompt .btn { width: 100%; }
  .detail-row { grid-template-columns: 1fr; gap: 2px; }
  .profile-savebar { padding-left: var(--space-4); }
  .profile-savebar .text-sm { display: none; }
  .profile-savebar .btn { width: 100%; }
}

/* Printing a profile (admin): just the content */
@media print {
  .sidenav, .topbar, .toast-container, .btn, .page-progress, .profile-savebar { display: none !important; }
  body.has-sidenav { padding-left: 0; }
  .page-content { margin: 0; padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  .profile-layout { grid-template-columns: 220px 1fr; }
  .profile-summary { position: static; }
}

/* ---------------------------------------------------------------------------
   Lesson progress
   --------------------------------------------------------------------------- */
.course-progress-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 12px 4px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: var(--color-gray-50);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.course-progress-pill .progress { display: block; width: 84px; height: 6px; }
.course-progress-pill .progress-bar { display: block; animation: none; transition: width 600ms var(--ease-out); }

.lesson-status { display: flex; align-items: center; gap: var(--space-2); }
.lesson-done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--color-success-bg);
  color: var(--color-success);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.lesson-done.is-new { animation: scaleIn 420ms var(--ease-out) both; }
.lesson-watch { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.lesson-watch .progress { display: block; width: 110px; height: 6px; }
.lesson-watch .progress-bar { display: block; animation: none; transition: width 600ms var(--ease-out); }

/* "Next lesson" pulses once when the current lesson is done */
.lesson-nav .btn-primary.is-highlighted { animation: nudge 1.2s var(--ease-out) 2; }
@keyframes nudge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 150, 30, 0); }
  40% { box-shadow: 0 0 0 6px rgba(224, 150, 30, 0.35); }
}

/* Sidebar: done / partly watched */
.chapter-header > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-count { flex-shrink: 0; padding: 1px 8px; border-radius: var(--radius-full); background: var(--color-gray-200); font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.chapter-count.is-done { background: var(--color-success-bg); color: var(--color-success); }
.subtopic-state { flex-shrink: 0; }
i.subtopic-state { width: auto; font-size: 13px; color: var(--color-success) !important; animation: scaleIn 320ms var(--ease-out) both; }
.subtopic-partial { font-size: 11px; font-weight: var(--weight-semibold); color: var(--color-accent-dark); font-variant-numeric: tabular-nums; }
.subtopic-item.is-done .subtopic-title { color: var(--text-muted); }
.subtopic-item.is-done.active .subtopic-title { color: var(--color-primary); }

/* Toast with an action button */
.toast > .btn { flex-shrink: 0; }

@media (max-width: 768px) {
  .course-progress-pill .progress { width: 48px; }
  .lesson-status { width: 100%; }
}
@media (max-width: 420px) {
  .course-progress-pill .progress { display: none; }
}

/* ---------------------------------------------------------------------------
   Sidebar navigation (menu items are defined in app/nav.php)
   Desktop: fixed on the left, can collapse to icons ("rail").
   Tablet / phone (<= 960px): hidden behind a top bar, slides in as a drawer.
   --------------------------------------------------------------------------- */
:root {
  --navbar-height: 0px; /* height of the mobile top bar; 0 on desktop */
  --sidenav-w: 264px;
  --sidenav-rail-w: 76px;
}

body.has-sidenav {
  padding-left: var(--sidenav-w);
  transition: padding-left 300ms var(--ease-out);
}

body.has-sidenav.nav-rail { padding-left: var(--sidenav-rail-w); }

.sidenav {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: var(--z-fixed);
  display: flex;
  flex-direction: column;
  width: var(--sidenav-w);
  background: var(--color-primary);
  color: rgba(255, 255, 255, 0.78);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: width 300ms var(--ease-out), transform 320ms var(--ease-out);
  view-transition-name: sidenav;
}

.nav-rail .sidenav { width: var(--sidenav-rail-w); }

/* Head: logo + collapse */
.sidenav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  height: 68px;
  padding: 0 var(--space-3) 0 var(--space-4);
  flex-shrink: 0;
}

.sidenav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  color: #fff;
}

.sidenav-brand:hover { color: #fff; }

.sidenav-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 5px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: #fff;
}

.sidenav-logo img { width: 100%; height: 100%; object-fit: contain; }

.sidenav-brand-text {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.sidenav-brand-text .accent,
.topbar-brand .accent { color: var(--color-accent); }

.sidenav-collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), transform 300ms var(--ease-out);
}

.sidenav-collapse:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* Body: sections + items */
.sidenav-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-2) var(--space-3) var(--space-4);
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.sidenav-section + .sidenav-section { margin-top: var(--space-4); }

.sidenav-section-title {
  padding: 0 var(--space-3) var(--space-2);
  font-size: 10.5px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
  white-space: nowrap;
}

.sidenav-link,
.sidenav-sublink {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidenav-link::-webkit-details-marker { display: none; }

.sidenav-link > i:first-child,
.sidenav-sublink > i:first-child {
  width: 20px;
  flex-shrink: 0;
  text-align: center;
  font-size: 15px;
}

.sidenav-link:hover,
.sidenav-sublink:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }

.sidenav-link.active { color: #fff; }
.sidenav-link.active > i:first-child { color: var(--color-accent-light); }

/* A plain link that is the current page gets the filled pill */
a.sidenav-link.active { background: rgba(255, 255, 255, 0.12); }
a.sidenav-link.active::before,
.sidenav-sublink.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--color-accent);
}

.sidenav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.sidenav-badge {
  min-width: 20px;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: #fff;
  font-size: 11px;
  font-weight: var(--weight-semibold);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Groups with sub-items */
.sidenav-chevron {
  font-size: 10px !important;
  opacity: 0.6;
  transition: transform var(--transition-base);
}

.sidenav-group[open] > summary .sidenav-chevron { transform: rotate(180deg); }

.sidenav-sub {
  position: relative;
  margin: 2px 0 var(--space-2) 21px;
  padding-left: var(--space-3);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.sidenav-group[open] > .sidenav-sub { animation: fadeIn var(--transition-base) both; }

.sidenav-sublink {
  min-height: 34px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.62);
}

.sidenav-sublink > i:first-child { font-size: 12px; opacity: 0.75; }
.sidenav-sublink.active { background: rgba(255, 255, 255, 0.1); color: #fff; }
.sidenav-sublink.active::before { left: -13px; top: 7px; bottom: 7px; }

/* Foot: app tools + user */
.sidenav-foot {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidenav-tool { min-height: 36px; font-size: 13px; color: rgba(255, 255, 255, 0.65); }
.sidenav-tool.is-loading::after { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }

.sidenav-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
}

.sidenav-user-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
  color: #fff;
}

a.sidenav-user-main:hover { color: #fff; }

.sidenav-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.sidenav-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sidenav-user-info { display: flex; flex-direction: column; line-height: 1.25; }
.sidenav-username { font-size: var(--text-sm); font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis; }
.sidenav-role { font-size: 11px; color: rgba(255, 255, 255, 0.55); text-transform: capitalize; }

.sidenav-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidenav-logout:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* ---- Rail (collapsed, desktop): icons only ---- */
@media (min-width: 961px) {
  .nav-rail .sidenav-head { flex-direction: column; justify-content: center; height: auto; padding: var(--space-4) 0 var(--space-2); }
  .nav-rail .sidenav-brand-text,
  .nav-rail .sidenav-label,
  .nav-rail .sidenav-chevron,
  .nav-rail .sidenav-section-title,
  .nav-rail .sidenav-sub { display: none; }
  .nav-rail .sidenav-collapse { transform: rotate(180deg); }
  .nav-rail .sidenav-body { padding-left: var(--space-2); padding-right: var(--space-2); }
  .nav-rail .sidenav-section + .sidenav-section { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid rgba(255, 255, 255, 0.08); }
  .nav-rail .sidenav-link { justify-content: center; padding: 0; min-height: 44px; }
  .nav-rail .sidenav-link > i:first-child { font-size: 17px; }
  .nav-rail .sidenav-link.active { background: rgba(255, 255, 255, 0.12); }
  .nav-rail .sidenav-badge { position: absolute; top: 4px; right: 6px; min-width: 16px; padding: 0 4px; font-size: 9.5px; }
  .nav-rail .sidenav-foot { padding-left: var(--space-2); padding-right: var(--space-2); }
  .nav-rail .sidenav-user { flex-direction: column; padding: var(--space-2) 0; }
  .nav-rail .sidenav-user-main { flex: none; }
  .nav-rail a.sidenav-link.active::before { left: -8px; }
}

/* ---- Mobile / tablet: top bar + slide-in drawer ---- */
.topbar { display: none; }
.sidenav-overlay { display: none; }

@media (max-width: 960px) {
  :root { --navbar-height: 56px; }

  body.has-sidenav,
  body.has-sidenav.nav-rail { padding-left: 0; }

  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: var(--navbar-height);
    padding: 0 var(--space-3);
    background: var(--color-primary);
    box-shadow: 0 6px 20px -12px rgba(0, 20, 32, 0.6);
  }

  .topbar .btn-ghost { color: rgba(255, 255, 255, 0.85); }
  .topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

  .topbar-brand { display: flex; align-items: center; gap: var(--space-2); flex: 1; color: #fff; font-family: var(--font-heading); font-weight: var(--weight-semibold); }
  .topbar-brand:hover { color: #fff; }
  .topbar-brand img { width: 30px; height: 30px; padding: 4px; border-radius: var(--radius-sm); background: #fff; }
  .topbar-avatar { width: 32px; height: 32px; }

  .sidenav,
  .nav-rail .sidenav {
    width: min(86vw, 300px);
    transform: translateX(-105%);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-modal);
  }

  .sidenav.open { transform: translateX(0); }
  .sidenav-collapse { display: none; }

  .sidenav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-modal) - 1);
    background: rgba(10, 18, 30, 0.45);
    animation: fadeOnly var(--transition-base) both;
  }
}

/* ---------------------------------------------------------------------------
   Admin: course list + course form + enrolment validity
   --------------------------------------------------------------------------- */
.admin-page { max-width: var(--max-width); margin: 0 auto; }

.admin-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.admin-kpi { display: flex; flex-direction: column; gap: 2px; padding: var(--space-4) var(--space-5); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-card); box-shadow: var(--shadow-xs); }
.admin-kpi-value { font-family: var(--font-heading); font-size: var(--text-2xl); font-weight: var(--weight-semibold); color: var(--text-primary); font-variant-numeric: tabular-nums; line-height: 1.2; }
.admin-kpi-label { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-muted); }

.course-cell { display: flex; align-items: center; gap: var(--space-3); min-width: 240px; }
.course-cell-thumb { display: flex; align-items: center; justify-content: center; width: 64px; aspect-ratio: 16 / 10; flex-shrink: 0; overflow: hidden; border-radius: var(--radius-sm); background: var(--color-primary); color: rgba(255, 255, 255, 0.4); }
.course-cell-thumb img { width: 100%; height: 100%; object-fit: cover; }
.course-cell-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.course-cell-title { font-weight: var(--weight-semibold); color: var(--text-primary); }
.course-cell-title:hover { color: var(--color-primary); }
.course-cell-meta { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); }
.course-table td .badge { margin-top: 4px; }
.nowrap { white-space: nowrap; }
.justify-end { justify-content: flex-end; }

.code-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-gray-50);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
}

.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }

.modal.modal-lg { max-width: 760px; }
.form-section { margin: 0 0 var(--space-5); padding: 0 0 var(--space-5); border: 0; border-bottom: 1px solid var(--border-subtle); }
.form-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.form-section legend { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); font-family: var(--font-heading); font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-primary); }
.form-section legend i { color: var(--color-accent); }
.form-section .grid .form-group { margin-bottom: var(--space-3); }
.switch-row { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--color-gray-50); font-size: var(--text-sm); cursor: pointer; }
.switch-row input { margin-top: 3px; flex-shrink: 0; }
.course-image-preview { display: block; max-width: 100%; max-height: 150px; margin-bottom: var(--space-2); border-radius: var(--radius-md); }

.validity-edit { margin-top: 4px; }
.validity-edit summary { display: inline; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-primary); cursor: pointer; list-style: none; }
.validity-edit summary::-webkit-details-marker { display: none; }
.validity-form { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
.validity-form .form-input { min-height: 34px; }

/* Students: course ID + validity */
.course-view-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.course-view-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.validity-chip { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-xs); color: var(--text-muted); }
.validity-chip.is-warning { color: var(--color-warning); font-weight: var(--weight-semibold); }

.course-card-code { align-self: flex-start; margin-bottom: var(--space-2); }
.course-card-facts { margin: 0 0 var(--space-4); padding: 0; display: flex; flex-direction: column; gap: 4px; }
.course-card-facts li { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-muted); }
.course-card-facts li.is-warning { color: var(--color-warning); font-weight: var(--weight-semibold); }
.course-card-facts li.is-danger { color: var(--color-danger); font-weight: var(--weight-semibold); }
.course-card.is-locked .course-card-thumbnail img,
.course-card.is-locked .course-card-placeholder { filter: grayscale(1); opacity: 0.6; }

@media (max-width: 960px) {
  .admin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .course-view-meta .validity-chip { display: none; }
}

/* ---------------------------------------------------------------------------
   Lists: toolbar, search, pagination, user rows, bulk bar, empty state
   --------------------------------------------------------------------------- */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  overflow: visible; /* dropdowns must be able to leave the card */
}

.list-search { position: relative; flex: 2 1 260px; min-width: 200px; }
.list-search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--text-muted); pointer-events: none; }
.list-search .form-input { padding-left: 38px; }
.list-filter { flex: 1 1 180px; min-width: 160px; width: auto; }
.list-sort { flex: 0 1 170px; }
.list-toolbar .segmented { min-height: 42px; align-items: stretch; }

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.pager-info strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.pager-links { display: flex; align-items: center; gap: 4px; }
.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
a.pager-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.pager-btn.is-current { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.pager-btn.is-disabled { opacity: 0.4; }
.pager-gap { padding: 0 4px; }
.pager-size label { display: flex; align-items: center; gap: var(--space-2); }
.pager-size .form-select { width: auto; min-height: 36px; padding-top: 0; padding-bottom: 0; }

.col-check { width: 44px; padding-right: 0 !important; }
.table tbody tr.is-selected { background: var(--tint-primary); }

.user-cell { display: flex; align-items: center; gap: var(--space-3); min-width: 220px; color: inherit; }
.user-cell:hover strong { color: var(--color-primary); }
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}
.user-avatar.is-admin { background: var(--color-primary); }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-cell-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.user-cell-text strong { font-weight: var(--weight-semibold); color: var(--text-primary); transition: color var(--transition-fast); }
.user-cell-text span { font-size: var(--text-xs); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.course-count { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-full); background: var(--tint-primary); color: var(--color-primary); font-size: var(--text-xs); font-weight: var(--weight-semibold); cursor: default; }

.table-empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-8) var(--space-4); color: var(--text-muted); text-align: center; }
.table-empty > i { font-size: 1.75rem; color: var(--color-gray-300); }
.table-empty strong { color: var(--text-primary); }

/* Floating bar for bulk actions */
.bulk-bar {
  position: sticky;
  top: calc(var(--navbar-height) + var(--space-3));
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: scaleIn var(--transition-base) both;
}
.bulk-bar .bulk-count { font-size: var(--text-sm); }
.bulk-bar .form-select, .bulk-bar .ts-wrapper { flex: 1 1 260px; min-width: 220px; max-width: 420px; }
.bulk-bar .btn-ghost { color: rgba(255, 255, 255, 0.8); }
.bulk-bar .btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.bulk-bar .btn-primary { background: var(--color-accent); border-color: var(--color-accent); }

/* ---------------------------------------------------------------------------
   Confirm dialog (replaces the browser's confirm())
   --------------------------------------------------------------------------- */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-toast) + 2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(10, 18, 30, 0.45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fadeOnly 160ms var(--ease-out) both;
}
.confirm-backdrop.is-leaving { animation: fadeOnly 160ms var(--ease-in-out) reverse both; }
.confirm-box { width: 100%; max-width: 420px; padding: var(--space-6) var(--space-5) var(--space-5); border-radius: var(--radius-xl); background: #fff; box-shadow: var(--shadow-xl); text-align: center; animation: scaleIn 260ms var(--ease-out) both; }
.confirm-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin-bottom: var(--space-3); border-radius: var(--radius-full); background: var(--tint-primary); color: var(--color-primary); font-size: 1.4rem; }
.confirm-icon.is-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.confirm-msg { margin: 0 0 var(--space-5); color: var(--text-primary); font-size: var(--text-base); line-height: 1.5; }
.confirm-actions { display: flex; gap: var(--space-2); justify-content: center; }
.confirm-actions .btn { min-width: 120px; }

/* ---------------------------------------------------------------------------
   Tom Select (searchable dropdowns) — matched to our inputs
   --------------------------------------------------------------------------- */
.ts-wrapper { min-width: 0; }
.ts-wrapper.single .ts-control,
.ts-wrapper .ts-control {
  min-height: 42px;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--color-white);
  box-shadow: var(--shadow-xs);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.5;
}
.ts-wrapper.single .ts-control::after { border-color: var(--color-gray-500) transparent transparent; right: 14px; }
.ts-wrapper.focus .ts-control { border-color: var(--color-primary); box-shadow: var(--ring); }
.ts-dropdown {
  margin-top: 6px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  overflow: hidden;
  animation: fadeIn 160ms var(--ease-out) both;
}
.ts-dropdown .option { padding: 9px 12px; }
.ts-dropdown .active { background: var(--tint-primary); color: var(--color-primary); }
.ts-dropdown .selected { font-weight: var(--weight-semibold); }
.ts-dropdown .dropdown-input-wrap { padding: 8px; border-bottom: 1px solid var(--border-subtle); }
.ts-dropdown .dropdown-input { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 10px; font-size: var(--text-sm); }
.ts-dropdown .no-results { padding: 10px 12px; color: var(--text-muted); }

/* ---------------------------------------------------------------------------
   Tippy tooltips — "skips" theme
   --------------------------------------------------------------------------- */
.tippy-box[data-theme~='skips'] {
  background: var(--color-gray-900);
  color: #fff;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: var(--weight-medium);
  line-height: 1.4;
  box-shadow: var(--shadow-md);
}
.tippy-box[data-theme~='skips'] .tippy-content { padding: 6px 10px; }
.tippy-box[data-theme~='skips'][data-placement^='top'] > .tippy-arrow::before { border-top-color: var(--color-gray-900); }
.tippy-box[data-theme~='skips'][data-placement^='bottom'] > .tippy-arrow::before { border-bottom-color: var(--color-gray-900); }
.tippy-box[data-theme~='skips'][data-placement^='right'] > .tippy-arrow::before { border-right-color: var(--color-gray-900); }
.tippy-box[data-theme~='skips'][data-placement^='left'] > .tippy-arrow::before { border-left-color: var(--color-gray-900); }

@media (max-width: 768px) {
  .pager { justify-content: center; }
  .pager-info { width: 100%; text-align: center; }
  .user-cell-text span { max-width: 180px; }
  .list-filter, .list-sort { flex: 1 1 100%; }
}

/* ---------------------------------------------------------------------------
   Popups: title block, alerts, choice cards, inputs with icons/actions
   --------------------------------------------------------------------------- */
.modal-title { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.modal-title h3 { margin: 0; font-size: var(--text-lg); }
.modal-title p { margin: 2px 0 0; font-size: var(--text-sm); color: var(--text-muted); }
.modal-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--tint-primary);
  color: var(--color-primary);
  font-size: var(--text-lg);
}

.user-modal { max-width: 620px; }
.user-modal .modal-body { padding-top: var(--space-5); }
.user-modal .grid .form-group { margin-bottom: var(--space-4); }

.form-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid #f5c6c1;
  border-radius: var(--radius-md);
  background: var(--color-danger-bg);
  color: #8e1c1c;
  font-size: var(--text-sm);
  animation: fadeIn var(--transition-base) both;
}
.form-alert i { margin-top: 2px; }

/* Big selectable cards (radio buttons) */
.choice-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.choice-card { position: relative; cursor: pointer; }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card-body {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: #fff;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}
.choice-card-body > i { grid-row: span 2; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-full); background: var(--color-gray-100); color: var(--text-secondary); transition: background-color var(--transition-fast), color var(--transition-fast); }
.choice-card-body strong { font-size: var(--text-sm); color: var(--text-primary); }
.choice-card-body small { font-size: var(--text-xs); color: var(--text-muted); }
.choice-card:hover .choice-card-body { border-color: var(--color-gray-400); }
.choice-card input:checked + .choice-card-body { border-color: var(--color-primary); background: var(--tint-primary); box-shadow: 0 0 0 3px rgba(0, 44, 68, 0.08); }
.choice-card input:checked + .choice-card-body > i { background: var(--color-primary); color: #fff; }
.choice-card input:focus-visible + .choice-card-body { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* Inputs with a leading icon and optional buttons on the right */
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--text-muted); pointer-events: none; }
.input-icon > .form-input { padding-left: 38px; }
.input-with-actions > .form-input { padding-right: 84px; }
.input-actions { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
.input-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.input-action:hover { background: var(--color-gray-100); color: var(--color-primary); }

/* Password strength */
.strength { display: flex; align-items: center; gap: var(--space-2); margin-top: 8px; font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.strength-bar { flex: 1; height: 4px; border-radius: var(--radius-full); background: var(--color-gray-200); overflow: hidden; }
.strength-bar > span { display: block; height: 100%; width: 10%; border-radius: inherit; background: var(--color-danger); transition: width var(--transition-base), background-color var(--transition-base); }
.strength[data-level='1'] .strength-bar > span { width: 40%; background: var(--color-warning); }
.strength[data-level='2'] .strength-bar > span { width: 70%; background: var(--color-info); }
.strength[data-level='3'] .strength-bar > span { width: 100%; background: var(--color-success); }
.strength[data-level='0'] .strength-text { color: var(--color-danger); }
.strength[data-level='1'] .strength-text { color: var(--color-warning); }
.strength[data-level='2'] .strength-text { color: var(--color-info); }
.strength[data-level='3'] .strength-text { color: var(--color-success); }

@media (max-width: 576px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; max-height: 92dvh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; } /* bottom sheet on phones */
  .choice-cards { grid-template-columns: 1fr; }
  .modal-footer .btn { flex: 1; }
}

/* =========================================================================
   Student top navigation bar (admins use the sidebar instead)
   ========================================================================= */
body.has-topnav { --navbar-height: 64px; }

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: var(--color-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: var(--z-fixed);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 6px 20px -12px rgba(0, 20, 32, 0.6);
  view-transition-name: navbar;
}

.navbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  gap: var(--space-4);
}

/* Brand */
.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-white);
  flex-shrink: 0;
}

.navbar-logo {
  width: 36px;
  height: 36px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  color: var(--color-white);
}

.navbar-brand-text {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
}

.navbar-brand-text .accent {
  color: var(--color-accent);
}

/* Links */
.navbar-links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  justify-content: center;
}

.navbar-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 14px;
  color: rgba(255, 255, 255, 0.72);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  transition: color var(--transition-fast), background-color var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.navbar-link:hover {
  color: var(--color-white);
  background-color: rgba(255, 255, 255, 0.08);
}

.navbar-link.active {
  color: var(--color-white);
  background-color: rgba(255, 255, 255, 0.14);
}

.navbar-link i {
  font-size: 13px;
  opacity: 0.9;
}

.navbar-link.active i {
  color: var(--color-accent-light);
  opacity: 1;
}

/* Actions */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.navbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.navbar-user-info {
  display: flex;
  flex-direction: column;
}

.navbar-username {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-white);
  line-height: 1.2;
}

.navbar-role {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.6);
  text-transform: capitalize;
}

.navbar-logout {
  color: rgba(255, 255, 255, 0.7) !important;
}

.navbar-logout:hover {
  color: var(--color-white) !important;
  background-color: rgba(255, 255, 255, 0.1) !important;
}

.navbar-toggle {
  display: none !important;
  color: var(--color-white) !important;
}

.navbar-overlay {
  display: none;
}

/* Mobile */
@media (max-width: 768px) {
  .navbar-toggle {
    display: flex !important;
  }

  .navbar-user-info {
    display: none;
  }

  .navbar-links {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background: var(--color-primary);
    flex-direction: column;
    padding: var(--space-3);
    gap: var(--space-1);
    transform: translateY(-12px);
    opacity: 0;
    visibility: hidden;
    transition: transform var(--transition-base), opacity var(--transition-base), visibility 0s linear 260ms;
    pointer-events: none;
    z-index: var(--z-fixed);
    box-shadow: var(--shadow-lg);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }

  .navbar-links.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    transition: transform var(--transition-base), opacity var(--transition-base);
    pointer-events: auto;
  }

  .navbar-link {
    width: 100%;
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }

  .navbar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(10, 18, 30, 0.35);
    z-index: calc(var(--z-fixed) - 1);
    animation: fadeOnly var(--transition-base) both;
  }
}

.navbar-install { display: inline-flex; align-items: center; gap: 6px; color: #fff; border: 1px solid rgba(255, 255, 255, 0.35); }
.navbar-install:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.navbar-refresh { color: rgba(255, 255, 255, 0.75); }
.navbar-refresh:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); color: #fff; }
.navbar-refresh.is-loading::after { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }
a.navbar-user { padding: 3px 10px 3px 3px; border-radius: var(--radius-full); transition: background-color var(--transition-fast); }
a.navbar-user:hover { background: rgba(255, 255, 255, 0.08); }
.navbar-avatar { overflow: hidden; }
.navbar-avatar img { width: 100%; height: 100%; object-fit: cover; }
::view-transition-group(navbar) { animation: none; }
@media (max-width: 768px) { .navbar-install span { display: none; } }
@media (display-mode: standalone) { .navbar { padding-top: env(safe-area-inset-top); } }
@media print { .navbar { display: none !important; } body.has-topnav { --navbar-height: 0px; } }
