/* =============================
   STUDENT PORTAL — Premium Dark Mode (Stitch Blueprint)
   ============================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sp-primary: #4F46E5;
  /* Indigo */
  --sp-primary-d: #4338ca;
  --sp-secondary: #14B8A6;
  /* Teal */
  --sp-accent: #F59E0B;
  /* Amber */
  --sp-danger: #EF4444;
  /* Danger */
  --sp-success: #10B981;
  /* Success */
  --sp-bg: #0F172A;
  /* Dark BG */
  --sp-card: #111827;
  /* Card BG */
  --sp-text: #F8FAFC;
  --sp-muted: #94A3B8;
  --sp-border: #1E293B;
  /* Subtle dark border */
  --sp-nav-h: 72px;
  --sp-radius: 18px;
  --sp-radius-sm: 14px;
}

/* ── Voice to Text Animations ── */
@keyframes sp-pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.animate-pulse {
  animation: sp-pulse 1.5s infinite ease-in-out;
  display: inline-block;
}

.icon-btn.recording {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.icon-btn.recording i {
  color: #ef4444 !important;
}

html,
body {
  height: 100%;
  font-family: 'Poppins', 'Inter', sans-serif;
  background: var(--sp-bg);
  color: var(--sp-text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell (sidebar + topbar + main), one DOM for all widths ── */
.sp-shell {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.sp-shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sp-sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--sp-card);
  border-right: 1px solid var(--sp-border);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 300;
  transition: transform 0.25s ease;
}

.sp-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  border-bottom: 1px solid var(--sp-border);
  margin-bottom: 16px;
  flex-shrink: 0;
}

/* ── Sidebar nav scroll area — scrollbar hidden, up/down arrows instead
   (matches the admin dashboard's sidebar-scroll convention) ── */
.sp-sidebar-nav-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.sp-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 24px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sp-sidebar-nav::-webkit-scrollbar {
  display: none;
}

.sp-nav-scroll-arrow {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  background: var(--sp-card);
  border: 1px solid var(--sp-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  color: var(--sp-primary);
  z-index: 10;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sp-nav-scroll-arrow.sp-nav-scroll-up {
  top: 4px;
}

.sp-nav-scroll-arrow.sp-nav-scroll-down {
  bottom: 4px;
}

.sp-sidebar-brand i {
  font-size: 1.6rem;
  color: var(--sp-primary);
}

.sp-sidebar-group {
  margin-bottom: 18px;
  padding: 0 12px;
}

.sp-sidebar-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sp-muted);
  padding: 0 12px 8px;
  font-family: 'Inter', sans-serif;
}

.sp-sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--sp-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  transition: all .15s;
  margin-bottom: 2px;
}

.sp-sidebar-link i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sp-sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.sp-sidebar-link.active {
  background: rgba(79, 70, 229, 0.15);
  color: #fff;
}

.sp-sidebar-link.active i {
  color: var(--sp-primary);
}

.sp-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 290;
}

/* ── Topbar (Glassmorphism) ── */
.sp-topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 64px;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.sp-hamburger {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--sp-border);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
}

.sp-topbar-search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  padding: 9px 14px;
  color: var(--sp-muted);
}

.sp-topbar-search input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.88rem;
  width: 100%;
  font-family: 'Inter', sans-serif;
}

.sp-topbar-search input::placeholder {
  color: var(--sp-muted);
}

.sp-topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.sp-topbar .sp-logo {
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

.sp-topbar .sp-logo i {
  font-size: 1.5rem;
  color: var(--sp-primary);
}

.sp-topbar .sp-user-name {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--sp-muted);
}

.sp-bell {
  position: relative;
  color: var(--sp-muted);
  font-size: 1.3rem;
  line-height: 1;
  text-decoration: none;
}

.sp-badge-dot {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--sp-danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  line-height: 1;
}

/* ── Main content ── */
.sp-main {
  padding: 24px 24px 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ── Dashboard two-column layout (home.php only) ── */
.sp-dashboard-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.sp-dashboard-content {
  flex: 1;
  min-width: 0;
}

.sp-right-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sp-panel-title {
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 12px;
}

/* ── Stat tiles (right-panel Quick Stats) ── */
.sp-stat-tile {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--sp-border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sp-stat-tile .sp-stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(79, 70, 229, 0.15);
  color: var(--sp-primary);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sp-stat-tile .sp-stat-value {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  line-height: 1.3;
}

.sp-stat-tile .sp-stat-label {
  font-size: 0.72rem;
  color: var(--sp-muted);
  font-family: 'Inter', sans-serif;
}

/* ── Progress ring (pure CSS conic-gradient, no chart lib) ── */
.sp-progress-ring {
  --ring-pct: 0;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--sp-primary) calc(var(--ring-pct) * 1%), var(--sp-border) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.sp-progress-ring-inner {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: var(--sp-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.sp-progress-ring-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
}

.sp-progress-ring-label {
  font-size: 0.68rem;
  color: var(--sp-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'Inter', sans-serif;
}

.sp-progress-substats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.sp-progress-substat {
  text-align: center;
}

.sp-progress-substat .val {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.sp-progress-substat .lbl {
  font-size: 0.7rem;
  color: var(--sp-muted);
  font-family: 'Inter', sans-serif;
}

/* ── Course progress bar ── */
.sp-progress-bar-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 8px;
}

.sp-progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--sp-primary), var(--sp-secondary));
}

/* ── Timeline rows (Upcoming Schedule / Recent Activity) ── */
.sp-timeline-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--sp-border);
}

.sp-timeline-item:last-child {
  border-bottom: none;
}

.sp-timeline-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  background: rgba(79, 70, 229, 0.12);
  color: var(--sp-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.sp-timeline-text {
  font-size: 0.85rem;
  color: #e2e8f0;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}

.sp-timeline-time {
  font-size: 0.72rem;
  color: var(--sp-muted);
  margin-top: 2px;
  font-family: 'Inter', sans-serif;
}

/* ── Quick-actions grid ── */
.sp-quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.sp-quick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px;
  border-radius: 16px;
  background: var(--sp-card);
  border: 1px solid var(--sp-border);
  text-decoration: none;
  color: #e2e8f0;
  text-align: center;
  transition: all .15s;
}

.sp-quick-item:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

.sp-quick-item .sp-quick-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: rgba(79, 70, 229, 0.15);
  color: var(--sp-primary);
}

.sp-quick-item span {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
}

/* ── Bottom-nav center FAB (raised, Home shortcut) ── */
.sp-nav-fab {
  position: relative;
  top: -18px;
}

.sp-nav-fab .sp-nav-fab-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sp-primary), var(--sp-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.5);
  border: 4px solid var(--sp-bg);
  margin-bottom: 2px;
}

/* ── Responsive breakpoints: sidebar <-> bottom-nav swap at 900px,
   matching the admin dashboard's existing sidebar-collapse convention ── */
/* ── Generic 2-column grid (mobile stat tiles / task tiles) ── */
.sp-grid-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* ── Mobile/desktop visibility toggles (Teacher Module dashboard widgets that
   only make sense at one width, as opposed to .sp-right-panel's hide-only use) ── */
.sp-mobile-only {
  display: none;
}

.sp-desktop-only {
  display: block;
}

@media (max-width: 900px) {
  .sp-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }

  .sp-sidebar.sp-open {
    transform: translateX(0);
  }

  .sp-sidebar-backdrop.sp-open {
    display: block;
  }

  .sp-hamburger {
    display: flex;
  }

  .sp-topbar-search {
    display: none;
  }

  .sp-right-panel {
    display: none;
  }

  .sp-dashboard-layout {
    display: block;
  }

  .sp-main {
    padding: 16px 16px calc(var(--sp-nav-h) + 24px);
    max-width: 768px;
  }

  .sp-mobile-only {
    display: block;
  }

  .sp-desktop-only {
    display: none;
  }
}

@media (max-width: 600px) {
  .sp-quick-grid {
    gap: 10px;
  }

  .sp-sidebar {
    width: 84%;
    max-width: 300px;
  }
}

/* ── Typography ── */
.sp-section-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #fff;
  letter-spacing: -0.01em;
}

.sp-section-sub {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--sp-muted);
  margin-bottom: 24px;
}

/* ── Cards ── */
.sp-card {
  background: var(--sp-card);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  margin-bottom: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sp-card:active {
  transform: scale(0.98);
}

.sp-card-body {
  padding: 20px;
}

.sp-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--sp-primary) 0%, var(--sp-secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 3.5rem;
  position: relative;
}

/* Taller course banner on large screens, where the card has room to breathe */
@media (min-width: 901px) {
  .sp-card-img {
    height: 280px;
  }
}

.sp-card-img::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to top, var(--sp-card), transparent);
}

.sp-card-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 6px;
  color: #fff;
}

.sp-card-sub {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--sp-muted);
}

/* ── Badges / Chips ── */
.sp-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sp-badge-primary {
  background: rgba(79, 70, 229, 0.2);
  color: #818cf8;
  border: 1px solid rgba(79, 70, 229, 0.3);
}

.sp-badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.sp-badge-warn {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.sp-badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Buttons ── */
.sp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--sp-radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.sp-btn-primary {
  background: linear-gradient(135deg, var(--sp-primary) 0%, #6366f1 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.sp-btn-primary:hover {
  background: linear-gradient(135deg, var(--sp-primary-d) 0%, var(--sp-primary) 100%);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6);
  transform: translateY(-1px);
}

.sp-btn-outline {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 1px solid var(--sp-border);
}

.sp-btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--sp-muted);
}

.sp-btn-sm {
  padding: 15px 16px;
  font-size: 0.85rem;
  border-radius: 12px;
}

.sp-btn-full {
  width: 100%;
}

/* ── Bottom Nav (Glassmorphism) ── */
.sp-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--sp-nav-h);
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--sp-border);
  display: flex;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Sidebar takes over at 901px+ - must come after the base rule above so it
   actually wins the cascade instead of being silently overridden by it. */
@media (min-width: 901px) {
  .sp-bottom-nav {
    display: none;
  }
}

.sp-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--sp-muted);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 8px 0;
  gap: 4px;
  transition: all .2s;
  font-family: 'Inter', sans-serif;
}

.sp-nav-item i {
  font-size: 1.4rem;
  transition: transform 0.2s;
}

.sp-nav-item:hover {
  color: #fff;
}

.sp-nav-item.active {
  color: var(--sp-primary);
}

.sp-nav-item.active i {
  text-shadow: 0 0 16px rgba(79, 70, 229, 0.5);
  transform: translateY(-2px);
}

/* ── Video player card ── */
.sp-video-wrap {
  position: relative;
  margin-bottom: 16px;
}

.sp-video-embed {
  position: relative;
  padding-top: 56.25%;
  /* 16:9 */
  background: #000;
  border-radius: var(--sp-radius);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  border: 1px solid var(--sp-border);
}

.sp-video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Fullscreen button overlay */
.sp-fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.sp-fullscreen-btn:hover {
  background: var(--sp-primary);
  transform: scale(1.1);
}

.sp-fullscreen-btn:active {
  transform: scale(0.95);
}

/* Fullscreen state */
.sp-video-wrap.sp-fs-active .sp-video-embed {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  padding-top: 0;
  border-radius: 0;
  z-index: 9999;
  border: none;
}

.sp-video-wrap.sp-fs-active .sp-fullscreen-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.7);
}

/* On mobile stretch video edge-to-edge within its card */
@media (max-width: 600px) {
  .sp-video-embed {
    border-radius: 10px;
  }
}

/* ── Video protection overlays ── */

/* Suppress iOS Safari long-press callout on the entire video area */
.sp-video-wrap {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* iOS: disables long-press "Save / Copy / Open" popup */
}

/* Top shield — covers Vimeo top bar / YouTube share button row */
.sp-video-shield {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: 4;
  background: transparent;
  pointer-events: all;
  cursor: default;
  -webkit-touch-callout: none;
  touch-action: none;
}

/* Right-edge blocker for YouTube share/watch-later icons */
.sp-video-embed::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 56px;
  height: 100%;
  z-index: 4;
  pointer-events: all;
  touch-action: none;
}

/*
 * Full-cover mobile shield — transparent overlay over the entire iframe.
 * On mobile: intercepts long-press → no browser context menu.
 * On desktop: pointer-events:none so clicks pass through to the player.
 * Controlled via JS: desktop gets class 'sp-desktop' on the wrap.
 */
.sp-video-cover {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: transparent;
  /* Mobile default — block all touch events */
  pointer-events: all;
  touch-action: none;
  -webkit-touch-callout: none;
  cursor: default;
}

/* On larger screens let clicks reach the player */
@media (hover: hover) and (pointer: fine) {
  .sp-video-cover {
    pointer-events: none;
    /* desktop/mouse: pass through */
  }

  /* Still block the top bar and right edge on desktop */
  .sp-video-shield,
  .sp-video-embed::after {
    pointer-events: all;
  }
}

/* ── Material row ── */
.sp-mat-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--sp-border);
  transition: background 0.2s;
}

.sp-mat-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.sp-mat-row:last-child {
  border-bottom: none;
}

.sp-mat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  flex-shrink: 0;
  background: rgba(79, 70, 229, 0.15);
  color: var(--sp-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.sp-mat-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
}

.sp-mat-meta {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--sp-muted);
  margin-top: 2px;
}

/* ── MCQ Test ── */
.sp-question-card {
  background: var(--sp-card);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.sp-question-text {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 20px;
  line-height: 1.5;
  color: #fff;
}

.sp-option {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  padding: 14px 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all .2s;
  font-family: 'Inter', sans-serif;
  color: #e2e8f0;
}

.sp-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sp-option:has(input:checked) {
  border-color: var(--sp-primary);
  background: rgba(79, 70, 229, 0.1);
  color: #fff;
}

.sp-option input {
  margin-right: 14px;
  accent-color: var(--sp-primary);
  width: 18px;
  height: 18px;
}

/* ── Result ── */
.sp-result-header {
  background: linear-gradient(135deg, var(--sp-primary) 0%, var(--sp-secondary) 100%);
  color: #fff;
  border-radius: var(--sp-radius);
  padding: 32px 20px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(79, 70, 229, 0.3);
}

.sp-result-score {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
}

.sp-result-label {
  font-size: 1rem;
  opacity: .9;
  font-family: 'Inter', sans-serif;
}

.sp-answer-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid var(--sp-border);
}

.sp-answer-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.sp-answer-icon.correct {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.sp-answer-icon.wrong {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* ── Chat ── */
.sp-chat-messages {
  height: 100%;
  overflow-y: auto;
  padding: 16px 0;
  scrollbar-width: none;
}

.sp-chat-messages::-webkit-scrollbar {
  display: none;
}

.sp-chat-bubble {
  display: flex;
  margin-bottom: 16px;
}

.sp-chat-bubble.me {
  justify-content: flex-end;
}

.sp-bubble-inner {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  font-family: 'Inter', sans-serif;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  word-break: break-word;
  overflow-wrap: break-word;
}

.sp-bubble-inner.them {
  background: #ffffff;
  color: #1e293b;
  border-top-left-radius: 0;
  margin-left: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
  border: 1px solid rgba(0,0,0,0.06);
}

.sp-bubble-inner.me {
  background: #1865ff;
  color: #e9edef;
  border-top-right-radius: 0;
  margin-right: 8px;
}

/* Tails */
.sp-bubble-inner.them::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 0px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 10px solid #ffffff;
}

.sp-bubble-inner.me::before {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 0;
  height: 0;
  border-top: 0px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 10px solid #1865ff;
}

.sp-bubble-name {
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 2px;
  color: #1d6fa4;
}

.sp-bubble-inner.me .sp-bubble-name {
  color: rgba(255,255,255,0.85);
}

.sp-bubble-time {
  font-size: 0.65rem;
  margin-top: 4px;
  opacity: .6;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

/* Replied message inside bubble */
.sp-replied-box {
  background: rgba(0, 0, 0, 0.2);
  border-left: 4px solid var(--sp-primary);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 0.82rem;
  cursor: pointer;
}

.sp-replied-box .replied-user {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--sp-primary);
  margin-bottom: 2px;
}

.sp-replied-box .replied-text {
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Reply Preview above input */
.sp-reply-preview {
  background: rgba(32, 44, 51, 0.95);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: none;
  align-items: center;
  gap: 12px;
}

.sp-reply-preview .preview-content {
  flex: 1;
  border-left: 4px solid var(--sp-primary);
  padding-left: 10px;
  overflow: hidden;
}

.sp-reply-preview .preview-user {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--sp-primary);
}

.sp-reply-preview .preview-text {
  font-size: 0.85rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Highlight animation */
@keyframes messageHighlight {
  0% {
    background: rgba(79, 70, 229, 0.4);
  }

  100% {
    background: transparent;
  }
}

.highlight-msg {
  animation: messageHighlight 2s ease-out;
}

/* Typing animation */
.typing-indicator-text {
  font-size: 0.8rem;
  color: var(--sp-secondary);
  margin-bottom: 8px;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sp-pinned-bar {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  color: #fbbf24;
}

.sp-chat-input-bar {
  position: fixed;
  bottom: var(--sp-nav-h);
  left: 0;
  right: 0;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--sp-border);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--sp-border);
  border-radius: 24px;
  padding: 8px 10px;
  width: 100%;
  gap: 8px;
}

.chat-input-wrapper .icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--sp-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: 0.2s;
}

.chat-input-wrapper .icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.chat-input-wrapper .send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--sp-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: 0.2s;
}

.chat-input-wrapper .send-btn:hover {
  background: var(--sp-primary-d);
}

.auto-resize-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 10px 4px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  line-height: 1.4;
  min-height: 24px;
  max-height: 120px;
  overflow-y: hidden;
  color: #fff;
  margin: 0;
}

.auto-resize-textarea::placeholder {
  color: var(--sp-muted);
}

.auto-resize-textarea::-webkit-scrollbar {
  width: 4px;
}

.auto-resize-textarea::-webkit-scrollbar-thumb {
  background: var(--sp-border);
  border-radius: 4px;
}

.sp-chat-input {
  flex: 1;
  border: 1px solid var(--sp-border);
  border-radius: 99px;
  padding: 12px 20px;
  font-size: 0.95rem;
  outline: none;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-family: 'Inter', sans-serif;
  transition: .2s;
}

.sp-chat-input:focus {
  border-color: var(--sp-primary);
  background: rgba(255, 255, 255, 0.08);
}

.sp-chat-input::placeholder {
  color: var(--sp-muted);
}

.sp-chat-send {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--sp-primary);
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.sp-chat-send:active {
  transform: scale(0.95);
}

/* ── Login page ── */
.sp-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, rgba(79, 70, 229, 0.2), transparent 40%),
    radial-gradient(circle at bottom left, rgba(20, 184, 166, 0.15), transparent 40%),
    var(--sp-bg);
  padding: 24px;
}

.sp-login-card {
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.sp-login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.sp-login-logo i {
  font-size: 3rem;
  color: var(--sp-primary);
  background: rgba(79, 70, 229, 0.15);
  width: 80px;
  height: 80px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  margin-bottom: 16px;
}

.sp-login-logo h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}

.sp-login-logo p {
  font-size: 0.9rem;
  color: var(--sp-muted);
  margin-top: 4px;
  font-family: 'Inter', sans-serif;
}

.sp-form-group {
  margin-bottom: 20px;
}

.sp-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #e2e8f0;
}

.sp-input {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  outline: none;
  transition: .2s;
}

.sp-input:focus {
  border-color: var(--sp-primary);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.sp-input::placeholder {
  color: #64748b;
}

.sp-input.error {
  border-color: var(--sp-danger);
}

/* (video embed styles consolidated above) */

.sp-err {
  font-size: 0.8rem;
  color: #f87171;
  margin-top: 6px;
}

/* ── Profile ── */
.sp-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sp-primary), var(--sp-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 auto 16px;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
  border: 4px solid var(--sp-card);
}

.sp-profile-name {
  text-align: center;
  font-weight: 700;
  font-size: 1.4rem;
  color: #fff;
}

.sp-profile-sub {
  text-align: center;
  color: var(--sp-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
  font-family: 'Inter', sans-serif;
}

.sp-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--sp-border);
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
}

.sp-info-row:last-child {
  border-bottom: none;
}

.sp-info-label {
  color: var(--sp-muted);
  font-weight: 500;
}

.sp-info-value {
  color: #fff;
  font-weight: 600;
}

/* --- Custom Date Picker (Flatpickr) --- */
.flatpickr-calendar {
  background: var(--sp-card) !important;
  border: 1px solid var(--sp-border) !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6) !important;
  border-radius: 24px !important;
  font-family: 'Poppins', sans-serif !important;
  padding: 16px 12px !important;
  width: 335px !important;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  color: var(--sp-text) !important;
  box-sizing: border-box !important;
}

.flatpickr-innerContainer {
  width: 100% !important;
}

.flatpickr-days {
  width: 100% !important;
}

.dayContainer {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
}


.flatpickr-day {
  border-radius: 14px !important;
  color: var(--sp-text) !important;
  transition: all 0.2s ease;
  height: 40px !important;
  line-height: 40px !important;
  font-weight: 500;
  margin: 2px 0 !important;
}

/* Fade colors for dates other than current month */
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: var(--sp-muted) !important;
  opacity: 0.4;
}

.flatpickr-day:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--sp-primary) !important;
  transform: translateY(-1px);
}

.flatpickr-day.today {
  border-color: var(--sp-primary) !important;
  color: var(--sp-primary) !important;
  background: rgba(79, 70, 229, 0.1) !important;
}

.flatpickr-day.selected {
  background: var(--sp-primary) !important;
  color: #fff !important;
  border-color: var(--sp-primary) !important;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.5) !important;
}

.flatpickr-months {
  padding: 0 8px 12px 8px !important;
}

.flatpickr-months .flatpickr-month {
  color: var(--sp-text) !important;
  fill: var(--sp-text) !important;
  height: 48px !important;
}

.flatpickr-current-month {
  font-weight: 700 !important;
  font-size: 1.1rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 4px !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  font-weight: 700 !important;
  padding: 4px 10px !important;
  border-radius: 10px !important;
}

.flatpickr-weekday {
  color: var(--sp-muted) !important;
  font-weight: 700 !important;
  font-size: 0.75rem !important;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding-bottom: 8px !important;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  background: rgba(255, 255, 255, 0.05) !important;
  border-radius: 12px !important;
  width: 36px !important;
  height: 36px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  transition: all 0.2s ease !important;
}

.flatpickr-months .flatpickr-prev-month {
  left: 12px !important;
}

.flatpickr-months .flatpickr-next-month {
  right: 12px !important;
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
  background: var(--sp-primary) !important;
}

.flatpickr-time {
  border-top: 1px solid var(--sp-border) !important;
}

.flatpickr-time input {
  color: var(--sp-text) !important;
}

.flatpickr-am-pm {
  color: var(--sp-text) !important;
}

/* Input styles for date picker icon on the left */
.flatpickr-custom-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%234F46E5' class='bi bi-calendar3' viewBox='0 0 16 16'%3E%3Cpath d='M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z'/%3E%3Cpath d='M6.5 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: left 1rem center !important;
  background-size: 1.1rem !important;
  padding-left: 3rem !important;
  cursor: pointer !important;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  display: none !important;
}

/* ═══════════════════════════════════════════════
   In-App PDF Viewer Modal
   ═══════════════════════════════════════════════ */

/* Backdrop */
.sp-pdf-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
}

/* Modal container */
.sp-pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  background: #0a0f1e;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Header bar */
.sp-pdf-header {
  height: 52px;
  flex-shrink: 0;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sp-border, #1E293B);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 5;
}

.sp-pdf-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  padding-right: 16px;
}

.sp-pdf-close {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.sp-pdf-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* The actual PDF iframe */
.sp-pdf-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #525659;
  /* matches PDF.js default bg */
  display: block;
}

/* Shield: covers browser PDF toolbar at TOP (download/print buttons) */
.sp-pdf-shield-top {
  position: absolute;
  top: 52px;
  /* below our header */
  left: 0;
  right: 0;
  height: 40px;
  /* browser PDF toolbar height */
  z-index: 4;
  background: transparent;
  /* transparent — just blocks pointer events */
  pointer-events: all;
}

/* Shield: covers browser PDF toolbar at BOTTOM (page counter etc.) */
.sp-pdf-shield-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  z-index: 4;
  background: transparent;
  /* transparent — just blocks pointer events */
  pointer-events: all;
}

/* Intercepts right-click on PDF; scrollbar left exposed on desktop; touch passthrough on mobile */
.sp-pdf-cover {
  position: absolute;
  top: 52px;
  bottom: 0;
  left: 0;
  right: 18px;
  /* expose PDF's own scrollbar so user can scroll */
  z-index: 3;
  pointer-events: all;
  /* desktop: blocks right-click */
  background: transparent;
  -webkit-touch-callout: none;
  cursor: default;
}

/* Mobile / touch devices: let touch scroll pass through to iframe */
@media (hover: none),
(pointer: coarse) {
  .sp-pdf-cover {
    pointer-events: none;
    /* touch scroll works via iframe directly */
    right: 0;
  }
}

/* Prevent iOS long-press save/share on the iframe itself */
.sp-pdf-frame {
  -webkit-touch-callout: none;
}
/* ── Portal footer (copyright + vendor mark), sits above the mobile bottom nav ── */
.sp-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
  margin-top: auto;
  border-top: 1px solid var(--sp-border);
  font-family: 'Inter', sans-serif;
  font-size: 0.76rem;
  color: var(--sp-muted);
}

.sp-footer strong { color: #cbd5e1; font-weight: 600; }

@media (max-width: 900px) {
  .sp-footer {
    justify-content: center;
    text-align: center;
    padding-bottom: calc(var(--sp-nav-h) + 20px);
  }
}
