/* ═══════════════════════════════════════════════════════════════════════
   PRAXIS LEGACY BRIDGE — restyles pre-Phase-N component classes
   (.btn, .otp-form, .auth-panel, tables, etc.) in the Praxis design
   language WITHOUT touching their markup or the JS wired to their IDs.
   Load order: base.css → components.css → praxis.css → praxis-legacy.css
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Buttons ────────────────────────────────────────────────────────── */
.px-app .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.7rem 1.5rem;
  border-radius: var(--px-radius-md);
  border: 1px solid transparent;
  font-family: var(--px-font-body);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.px-app .btn:active { transform: scale(0.97); }
.px-app .btn:disabled { opacity: 0.45; cursor: not-allowed; }

.px-app .btn--primary {
  background: var(--px-primary);
  color: var(--px-on-primary);
}
.px-app .btn--primary:hover,
.px-app .btn--primary:focus-visible {
  background: var(--px-primary-hover);
  box-shadow: var(--px-shadow-2);
}
.px-app .btn--loading { position: relative; color: transparent; animation: none; }
.px-app .btn--loading::after {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  border: 3px solid var(--px-on-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: px-spin 0.7s linear infinite;
}
@keyframes px-spin { to { transform: rotate(360deg); } }

/* ── Auth panel (sign-in card) ──────────────────────────────────────── */
.px-app .auth-panel {
  background: var(--px-surface);
  -webkit-backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  border: 1px solid var(--px-glass-border);
  border-radius: var(--px-radius-lg);
  box-shadow: var(--px-shadow-2);
  padding: 2.25rem 2rem;
  width: min(430px, 100%);
  margin-inline: auto;
}
@media (max-width: 480px) { .px-app .auth-panel { padding: 1.75rem 1.25rem; } }

.px-app .auth-panel__logo {
  display: block;
  width: min(240px, 70%);
  height: auto;
  margin: 0 auto 1.25rem;
}
.px-app .auth-panel__heading {
  font-family: var(--px-font-display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--px-text);
  text-align: center;
  margin: 0 0 0.25rem;
}
.px-app .auth-panel__sub {
  color: var(--px-text-muted);
  text-align: center;
  font-size: 0.95rem;
  margin: 0 0 1.25rem;
}
.px-app .auth-panel__powered {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.4rem 0 0;
  padding-top: 1.1rem;
  border-top: 1px solid var(--px-border);
  font-size: 0.78rem;
  color: var(--px-text-faint);
  letter-spacing: 0.04em;
}
.px-app .auth-panel__powered img { height: 26px; width: auto; }

/* Alerts */
.px-app .auth-panel__alert {
  border-radius: var(--px-radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 1rem;
}
.px-app .auth-panel__alert:empty { display: none; padding: 0; }
.px-app .auth-panel__alert--error {
  background: var(--px-danger-soft);
  color: var(--px-danger);
  border: 1px solid var(--px-danger);
  padding: 0.85rem 1.1rem;
}
.px-app .auth-panel__alert--success,
.px-app .auth-panel__alert--info {
  background: var(--px-primary-soft);
  color: var(--px-primary);
  border: 1px solid var(--px-primary);
  padding: 0.85rem 1.1rem;
}

/* ── OTP / auth forms ───────────────────────────────────────────────── */
.px-app .otp-form__step { display: flex; flex-direction: column; gap: 0.45rem; }
.px-app .otp-form label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--px-text);
  margin-top: 0.5rem;
}
.px-app .otp-form input[type="text"],
.px-app .otp-form input[type="password"] {
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--px-border);
  border-radius: var(--px-radius-sm);
  background: var(--px-surface-input);
  color: var(--px-text);
  font-family: var(--px-font-body);
  font-size: 1rem;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.px-app .otp-form input:focus {
  outline: none;
  border-color: var(--px-primary);
  box-shadow: 0 0 0 3px var(--px-primary-soft);
}
.px-app .otp-form .btn { margin-top: 0.9rem; width: 100%; }
.px-app .otp-form__back {
  background: none;
  border: none;
  color: var(--px-primary);
  font-family: var(--px-font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem;
  min-height: 44px;
  border-radius: var(--px-radius-sm);
  transition: background-color 0.2s;
}
.px-app .otp-form__back:hover { background: var(--px-primary-soft); }
.px-app .otp-form__hint {
  font-size: 0.85rem;
  color: var(--px-text-muted);
  line-height: 1.55;
  margin: 0.35rem 0;
}
.px-app .otp-form code {
  background: var(--px-primary-soft);
  color: var(--px-text);
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  font-size: 0.85rem;
}
.px-app #enrol-qr svg, .px-app #enrol-qr canvas {
  display: block;
  margin: 0.5rem auto;
  background: #fff;
  padding: 10px;
  border-radius: var(--px-radius-sm);
  border: 1px solid var(--px-border);
  max-width: 200px;
  height: auto;
}
.px-app #enrol-codes {
  background: var(--px-surface-input);
  border: 1px solid var(--px-border);
  border-radius: var(--px-radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  line-height: 1.8;
}

/* ── Hero section (login backdrop) ──────────────────────────────────── */
.px-app .hero-section {
  min-height: calc(100dvh - var(--px-nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.25rem;
  position: relative;
  background: none;
}
.px-app .hero-section::before { display: none; }
.px-app .hero__content { width: 100%; }

/* ═══════════════════════════════════════════════════════════════════════
   PORTAL SHELL — glass re-skin of .portal-* classes (all four portals)
   ═══════════════════════════════════════════════════════════════════════ */

.px-app .portal-layout { background: transparent; }

/* Sidebar: frosted panel, light-first */
.px-app .portal-sidebar {
  background: var(--px-surface-strong);
  -webkit-backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  border-right: 1px solid var(--px-glass-border);
}
.px-app .portal-sidebar__logo {
  border-bottom: 1px solid var(--px-border);
  padding: 0 20px 16px;
}
.px-app .portal-sidebar__logo img { height: 34px; }
.px-app .portal-sidebar__role-badge {
  color: var(--px-primary);
  border: 1px solid var(--px-primary);
  background: var(--px-primary-soft);
  border-radius: 999px;
  font-family: var(--px-font-display);
  letter-spacing: 0.12em;
  padding: 3px 10px;
}
.px-app .portal-nav__section-label {
  font-family: var(--px-font-display);
  color: var(--px-text-faint);
}
.px-app .portal-nav__link {
  color: var(--px-text-muted);
  font-family: var(--px-font-body);
  border-radius: var(--px-radius-sm);
  padding: 10px 12px;
  min-height: 44px;
  background: none;
  border: none;
  width: 100%;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.px-app .portal-nav__link:hover {
  background: var(--px-primary-soft);
  color: var(--px-primary);
}
.px-app .portal-nav__link.is-active {
  background: var(--px-primary-soft);
  color: var(--px-primary);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--px-primary);
}
.px-app .portal-nav__link svg { width: 18px; height: 18px; flex: none; }

/* Topbar */
.px-app .portal-topbar {
  background: var(--px-surface-strong);
  -webkit-backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  border-bottom: 1px solid var(--px-glass-border);
  height: 64px;
  gap: 12px;
}
.px-app .portal-topbar__title {
  font-family: var(--px-font-display);
  color: var(--px-text);
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-transform: none;
}
.px-app .portal-topbar__user { color: var(--px-text-muted); }
.px-app .portal-topbar__logout {
  color: var(--px-danger);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--px-radius-sm);
  padding: 8px 12px;
  min-height: 40px;
  cursor: pointer;
  font-family: var(--px-font-body);
  font-weight: 500;
}
.px-app .portal-topbar__logout:hover { background: var(--px-danger-soft); }

/* Mobile sidebar toggle + scrim */
.px-app .portal-menu-btn {
  display: none;
  width: 44px; height: 44px;
  border: 1px solid var(--px-border);
  border-radius: var(--px-radius-sm);
  background: transparent;
  color: var(--px-text);
  cursor: pointer;
  align-items: center; justify-content: center;
  flex: none;
}
.px-app .portal-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(6, 8, 26, 0.5);
  z-index: 150;
}
@media (max-width: 768px) {
  .px-app .portal-menu-btn { display: inline-flex; }
  .px-app .portal-scrim.is-open { display: block; }
  .px-app .portal-sidebar { box-shadow: var(--px-shadow-2); }
}

/* Content + cards */
.px-app .portal-content { padding: 32px 28px; }
@media (max-width: 768px) { .px-app .portal-content { padding: 20px 16px; } }

.px-app .programme-card {
  background: var(--px-surface);
  -webkit-backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  border: 1px solid var(--px-glass-border);
  border-radius: var(--px-radius-lg);
  box-shadow: var(--px-shadow-1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.px-app .programme-card__title {
  font-family: var(--px-font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--px-text);
  margin: 0 0 1rem;
}
.px-app .programme-card--expired { opacity: 0.85; }

/* Module list with progress units */
.px-app .module-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.px-app .module-list__item { border-radius: var(--px-radius-md); }
.px-app .module-list__link,
.px-app .module-list__row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--px-radius-md);
  border: 1px solid var(--px-border);
  background: var(--px-surface-input);
  text-decoration: none;
  color: var(--px-text);
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  min-height: 60px;
}
.px-app a.module-list__link:hover {
  border-color: var(--px-primary);
  transform: translateX(4px);
  box-shadow: var(--px-shadow-1);
}
.px-app .module-list__item--locked .module-list__row { opacity: 0.65; }
.px-app .module-list__name { flex: 1; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* Status badges */
.px-app .status-badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  flex: none;
}
.px-app .status-badge--locked   { background: var(--px-primary-soft); color: var(--px-text-faint); }
.px-app .status-badge--active,
.px-app .status-badge--unlocked,
.px-app .status-badge--in_progress { background: var(--px-primary-soft); color: var(--px-primary); }
.px-app .status-badge--completed,
.px-app .status-badge--complete,
.px-app .status-badge--passed   { background: var(--px-success-soft); color: var(--px-success); }

/* Access banners */
.px-app .access-banner {
  border-radius: var(--px-radius-sm);
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 1rem;
  border: 1px solid transparent;
}
.px-app .access-banner--warning { background: var(--px-warning-soft); color: var(--px-warning); border-color: var(--px-warning); }
.px-app .access-banner--urgent,
.px-app .access-banner--expired { background: var(--px-danger-soft); color: var(--px-danger); border-color: var(--px-danger); }

/* Empty / loading / error states */
.px-app .portal-empty-state__heading { font-family: var(--px-font-display); color: var(--px-text); }
.px-app .portal-empty-state__body { color: var(--px-text-muted); font-size: 1rem; }
.px-app .portal-empty-state__icon svg { width: 56px; height: 56px; color: var(--px-primary); opacity: 0.4; }
.px-app .portal-loading-text, .px-app .portal-error-text { color: var(--px-text-muted); }
.px-app .portal-error-text { color: var(--px-danger); }

/* Modal (consent gate etc.) */
.px-app .lock-modal__backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(6, 8, 26, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
}
.px-app .lock-modal__box {
  background: var(--px-surface-strong);
  -webkit-backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  border: 1px solid var(--px-glass-border);
  border-radius: var(--px-radius-lg);
  box-shadow: var(--px-shadow-2);
  color: var(--px-text);
  width: min(520px, 100%);
  padding: 1.75rem;
}
.px-app .lock-modal__title { font-family: var(--px-font-display); margin: 0 0 0.75rem; }
.px-app .lock-modal__body { color: var(--px-text-muted); }
.px-app .lock-modal__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.75rem; margin-top: 1.25rem; }

/* Data tables */
.px-app .data-table { color: var(--px-text); }
.px-app .data-table th {
  color: var(--px-text-faint);
  background: var(--px-primary-soft);
  border-bottom: 2px solid var(--px-border);
  font-family: var(--px-font-display);
}
.px-app .data-table td { border-bottom: 1px solid var(--px-border); }

/* ── Fixes from first preview pass ──────────────────────────────────── */

/* Old dark-theme text colours bleeding through */
.px-app .section-heading {
  font-family: var(--px-font-display);
  color: var(--px-text);
  text-transform: none;
  letter-spacing: -0.01em;
  font-size: 1.2rem;
  font-weight: 700;
  border-bottom: none;
}
.px-app .programme-card__title { text-transform: none; letter-spacing: -0.01em; }
.px-app .module-list__name { color: var(--px-text); font-size: 0.95rem; }
.px-app .module-list__item--locked .module-list__name { color: var(--px-text-faint); }

/* Locked items: the old combined selector padded/flexed the <li> itself —
   neutralise it; .module-list__row carries the layout now */
.px-app .module-list__item--locked {
  padding: 0;
  background: none;
  border: none;
  display: block;
}

/* Profile card (old gold/dark theme) */
.px-app .profile-card {
  background: var(--px-surface);
  -webkit-backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  border: 1px solid var(--px-glass-border);
  border-radius: var(--px-radius-lg);
  box-shadow: var(--px-shadow-1);
  padding: 1.75rem 2rem;
}
.px-app .profile-card__heading {
  font-family: var(--px-font-display);
  color: var(--px-primary);
  text-transform: none;
  letter-spacing: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.px-app .profile-field__label {
  color: var(--px-text-faint);
  font-family: var(--px-font-display);
  font-weight: 600;
}
.px-app .profile-field__value { color: var(--px-text); font-size: 1rem; }
.px-app .profile-field__value--muted { color: var(--px-text-faint); }
.px-app .profile-field__input {
  background: var(--px-surface-input);
  border: 1px solid var(--px-border);
  border-radius: var(--px-radius-sm);
  color: var(--px-text);
  min-height: 44px;
  padding: 0.5rem 0.85rem;
}
.px-app .profile-field__input:focus {
  border-color: var(--px-primary);
  box-shadow: 0 0 0 3px var(--px-primary-soft);
}
.px-app .profile-field__save-btn {
  background: var(--px-primary);
  color: var(--px-on-primary);
  border-radius: var(--px-radius-sm);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--px-font-body);
  font-size: 0.9rem;
  min-height: 44px;
  padding: 0.5rem 1.1rem;
}
.px-app .profile-field__save-btn:hover { background: var(--px-primary-hover); }
.px-app .profile-field__edit-btn {
  border: 1px solid var(--px-border);
  color: var(--px-text-muted);
  border-radius: var(--px-radius-sm);
  min-height: 40px;
  padding: 0.35rem 0.9rem;
}
.px-app .profile-field__edit-btn:hover { border-color: var(--px-primary); color: var(--px-primary); }
.px-app .profile-field__error { color: var(--px-danger); }

/* ID card: let content set the height (aspect-ratio clipped the body),
   and pin the QR svg against the vendor's inline 200px sizing */
.px-app .px-idcard { aspect-ratio: auto; min-height: 250px; }
.px-app .px-idcard__qr svg {
  width: 100% !important;
  height: 100% !important;
}

/* Small phones: drop the username text from the topbar (still in sidebar/profile) */
@media (max-width: 520px) {
  .px-app .portal-topbar__user > span:first-child { display: none; }
}

/* ── Legacy token remap ─────────────────────────────────────────────
   Old components/base.css rules AND inline styles reference the
   pre-Phase-N variables; remap them to Praxis tokens so anything not
   explicitly restyled above still lands on-brand in both themes.     */
.px-app {
  --color-text: var(--px-text);
  --color-text-muted: var(--px-text-muted);
  --color-bg: var(--px-bg);
  --color-surface: var(--px-surface);
  --color-border: var(--px-border);
  --gold-bright: var(--px-primary);
  --gold-light: var(--px-primary-hover);
  --text-primary: var(--px-text);
  --text-secondary: var(--px-text-muted);
  --font-heading: var(--px-font-display);
  --font-heading-cond: var(--px-font-display);
  --font-body: var(--px-font-body);
}

/* The old combined selector also padded/flexed the locked name span */
.px-app .module-list__item--locked .module-list__name {
  padding: 0;
  background: none;
  border: none;
  display: inline;
  flex: 1;
}

/* ── Course player + expired page (custom layouts) ──────────────────── */
.px-app {
  /* hardcoded fallbacks in the old course CSS */
  --navy-deep: var(--px-bg);
  --navy-dark: var(--px-bg);
  --gold-muted: var(--px-primary);
}
.px-app .course-layout { background: var(--px-bg); }
.px-app .course-nav {
  background: var(--px-surface-strong);
  -webkit-backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  border-right: 1px solid var(--px-glass-border);
}
.px-app .course-nav__header { border-bottom: 1px solid var(--px-border); }
.px-app .course-nav__back { color: var(--px-primary); font-size: 0.85rem; }
.px-app .course-nav__back:hover { color: var(--px-primary-hover); }
.px-app .course-nav__module-title { font-family: var(--px-font-display); color: var(--px-text); }
.px-app .course-topbar {
  background: var(--px-surface-strong);
  -webkit-backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  border-bottom: 1px solid var(--px-glass-border);
}
.px-app .course-topbar__title { font-family: var(--px-font-display); color: var(--px-text); }
.px-app .course-topbar__logout {
  color: var(--px-danger);
  background: none; border: none; cursor: pointer;
  border-radius: var(--px-radius-sm);
  padding: 8px 12px; min-height: 40px;
  font-family: var(--px-font-body); font-weight: 500;
}
.px-app .course-topbar__logout:hover { background: var(--px-danger-soft); }
.px-app .course-footer {
  background: var(--px-surface-strong);
  -webkit-backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  border-top: 1px solid var(--px-glass-border);
}
.px-app .btn--secondary {
  background: transparent;
  color: var(--px-primary);
  border: 1px solid var(--px-primary);
}
.px-app .btn--secondary:hover { background: var(--px-primary-soft); }
.px-app .btn--secondary:disabled { border-color: var(--px-border); color: var(--px-text-faint); }

.px-app .expired-page {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.px-app .expired-page__card {
  background: var(--px-surface);
  -webkit-backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  backdrop-filter: blur(var(--px-blur)) saturate(1.5);
  border: 1px solid var(--px-glass-border);
  border-radius: var(--px-radius-lg);
  box-shadow: var(--px-shadow-2);
  padding: 2.5rem 2rem;
  width: min(480px, 100%);
  text-align: center;
}
.px-app .expired-page__icon svg { width: 52px; height: 52px; color: var(--px-warning); margin-bottom: 0.75rem; }
.px-app .expired-page__heading { font-family: var(--px-font-display); color: var(--px-text); }
.px-app .expired-page__programme { color: var(--px-primary); font-weight: 600; }
.px-app .expired-page__message { color: var(--px-text-muted); }
.px-app .expired-page__back { display: inline-block; margin-top: 1rem; color: var(--px-primary); text-decoration: none; }
.px-app .expired-page__back:hover { text-decoration: underline; }

/* ── Native selects (examiner/lecturer filter bars, any page) ───────── */
.px-app select {
  min-height: 44px;
  padding: 0.5rem 2.2rem 0.5rem 0.85rem;
  border: 1px solid var(--px-border);
  border-radius: var(--px-radius-sm);
  background-color: var(--px-surface-input);
  color: var(--px-text);
  font-family: var(--px-font-body);
  font-size: 0.95rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A6088' stroke-width='2' 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 0.7rem center;
  background-size: 16px;
  cursor: pointer;
}
.px-app select:focus {
  outline: none;
  border-color: var(--px-primary);
  box-shadow: 0 0 0 3px var(--px-primary-soft);
}
.px-app select:disabled { opacity: 0.5; cursor: not-allowed; }
