/* ============================================================
   Student Learning & MCQ Practice Portal
   Student Portal Theme — animated, colorful, child-friendly
   All animations use transform/opacity only (GPU-accelerated),
   never layout-triggering properties, so the site stays fast.
   ============================================================ */

:root {
  --p-purple: #8b5cf6;
  --p-pink: #ec4899;
  --p-blue: #3b82f6;
  --p-teal: #14b8a6;
  --p-amber: #f59e0b;
  --p-green: #22c55e;
  --p-red: #ef4444;
  --p-ink: #1e1b3a;
  --p-card: #ffffff;
  --p-bg-1: #f5f3ff;
  --p-bg-2: #fdf4ff;
  --shadow-soft: 0 2px 8px rgba(30,27,58,.04), 0 8px 24px rgba(139, 92, 246, 0.10);
  --shadow-lift: 0 6px 16px rgba(30,27,58,.06), 0 20px 44px rgba(139, 92, 246, 0.20);
  --shadow-modal: 0 24px 64px rgba(30,27,58,.28);
  /* macOS-style spring/ease curves - snappy but smooth, never linear */
  --ease-mac: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --radius-mac: 14px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

* { box-sizing: border-box; }

body.student-theme {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--p-ink);
  background: linear-gradient(135deg, var(--p-bg-1) 0%, var(--p-bg-2) 100%);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Floating decorative blobs behind content - purely cosmetic, aria-hidden */
.blob-field { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.35;
  animation: float 10s ease-in-out infinite;
}
.blob.b1 { width: 260px; height: 260px; background: var(--p-purple); top: -60px; left: -60px; animation-duration: 12s; }
.blob.b2 { width: 200px; height: 200px; background: var(--p-pink); top: 40%; right: -80px; animation-duration: 9s; animation-delay: 1s; }
.blob.b3 { width: 180px; height: 180px; background: var(--p-amber); bottom: -60px; left: 20%; animation-duration: 11s; animation-delay: 2s; }
.blob.b4 { width: 150px; height: 150px; background: var(--p-teal); bottom: 10%; right: 15%; animation-duration: 8s; animation-delay: .5s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -30px) scale(1.08); }
}

.wrap { position: relative; z-index: 1; max-width: 960px; margin: 0; padding: 24px 28px 60px; flex: 1; min-width: 0; animation: spPageIn .35s var(--ease-mac) both; }
@keyframes spPageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.wrap.narrow { max-width: 520px; margin: 0 auto; }

/* Shell: sidebar + main content, side by side */
.sp-shell { position: relative; z-index: 1; display: flex; align-items: flex-start; min-height: 100vh; }

/* Left sidebar nav */
.s-nav {
  width: 220px; flex-shrink: 0; min-height: 100vh;
  background: rgba(255,255,255,0.72); backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: 22px 16px; box-shadow: var(--shadow-soft);
  border-right: 1px solid rgba(139,92,246,.08);
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0;
}
.s-nav .brand { font-weight: 800; font-size: 17px; color: var(--p-purple); text-decoration: none; margin-bottom: 18px; display: block; transition: transform .2s var(--ease-spring); }
.s-nav .brand:hover { transform: scale(1.03); }
.s-nav .links { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.s-nav a.link {
  color: var(--p-ink); text-decoration: none; font-size: 13.5px; font-weight: 600;
  padding: 10px 14px; border-radius: 12px;
  transition: transform .18s var(--ease-spring), background .18s var(--ease-mac), box-shadow .18s var(--ease-mac);
  transform-origin: left center; will-change: transform;
}
.s-nav a.link:hover { background: var(--p-bg-1); transform: translateX(4px) scale(1.035); box-shadow: 0 4px 12px rgba(139,92,246,.10); }
.s-nav a.link:active { transform: translateX(2px) scale(.98); }
.s-nav a.link.active { background: var(--p-purple); color: #fff; box-shadow: 0 4px 14px rgba(139,92,246,.35); }
.s-nav a.link.active:hover { transform: translateX(4px) scale(1.035); }
.s-nav form.logout-form { display: block; margin-top: 12px; }
.s-nav button.logout {
  background: none !important; border: none !important; color: var(--p-red); font-weight: 600; font-size: 13.5px; cursor: pointer;
  padding: 10px 14px; border-radius: 12px; width: 100%; text-align: left;
  transition: background .18s var(--ease-mac), transform .15s var(--ease-spring);
}
.s-nav button.logout:hover { background: #fef2f2; transform: translateX(2px); }
.s-nav button.logout:active { transform: scale(.97); }

/* Headings */
h1.s-title { font-size: 26px; font-weight: 800; margin: 6px 0 4px; }
p.s-sub { color: #6b6485; margin: 0 0 20px; font-size: 14px; }

/* Cards */
.s-card {
  background: var(--p-card); border-radius: var(--radius-mac); padding: 22px;
  box-shadow: var(--shadow-soft); border: 1px solid rgba(30,27,58,.04);
  animation: fadeInUp .5s var(--ease-out) both;
  transition: transform .25s var(--ease-mac), box-shadow .25s var(--ease-mac);
}
.s-card.hoverable:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.grid.tight { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
/* Staggered entrance for grids of cards - each one animates slightly after the previous */
.grid > * { animation: fadeInUp .5s var(--ease-out) both; }
.grid > *:nth-child(1) { animation-delay: .02s; }
.grid > *:nth-child(2) { animation-delay: .06s; }
.grid > *:nth-child(3) { animation-delay: .10s; }
.grid > *:nth-child(4) { animation-delay: .14s; }
.grid > *:nth-child(5) { animation-delay: .18s; }
.grid > *:nth-child(6) { animation-delay: .22s; }
.grid > *:nth-child(n+7) { animation-delay: .26s; }

/* Nav cards (dashboard tiles) */
a.nav-card {
  display: block; text-decoration: none; color: var(--p-ink);
  background: var(--p-card); border-radius: var(--radius-mac); padding: 24px 20px;
  box-shadow: var(--shadow-soft); text-align: center; border: 1px solid rgba(30,27,58,.04);
  transition: transform .25s var(--ease-spring), box-shadow .25s var(--ease-mac);
  animation: fadeInUp .5s var(--ease-out) both;
  cursor: pointer; outline-offset: 3px;
}
a.nav-card:hover { transform: translateY(-6px) scale(1.03); box-shadow: var(--shadow-lift); }
a.nav-card:active { transform: translateY(-2px) scale(.99); }
a.nav-card:focus-visible { outline: 2px solid var(--p-purple); }
a.nav-card .icon { font-size: 34px; display: inline-block; animation: bob 3s ease-in-out infinite; transition: transform .2s var(--ease-spring); }
a.nav-card:hover .icon { transform: scale(1.12) rotate(-4deg); }
a.nav-card h3 { margin: 10px 0 4px; font-size: 15px; }
a.nav-card p { margin: 0; font-size: 12px; color: #6b6485; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Stat pills */
.stat-pill {
  background: var(--p-card); border-radius: 18px; padding: 18px; text-align: center;
  box-shadow: var(--shadow-soft); animation: fadeInUp .5s ease both;
}
.stat-pill .num { font-size: 28px; font-weight: 800; }
.stat-pill .label { font-size: 12px; color: #6b6485; margin-top: 2px; }
.stat-pill.purple .num { color: var(--p-purple); }
.stat-pill.pink .num { color: var(--p-pink); }
.stat-pill.teal .num { color: var(--p-teal); }
.stat-pill.amber .num { color: var(--p-amber); }

/* Animated progress bar */
.progress-track { background: #ede9fe; border-radius: 99px; height: 12px; overflow: hidden; margin-top: 8px; }
.progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--p-purple), var(--p-pink));
  width: 0%; animation: fillBar 1s ease forwards;
  animation-delay: .15s;
}
@keyframes fillBar { to { width: var(--target-width, 0%); } }

/* Animated progress ring */
.ring { width: 96px; height: 96px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .bg { stroke: #ede9fe; }
.ring .fg {
  stroke: var(--p-purple); stroke-linecap: round;
  stroke-dasharray: 264; stroke-dashoffset: 264;
  animation: ringFill 1.2s ease forwards; animation-delay: .2s;
}
@keyframes ringFill { to { stroke-dashoffset: var(--ring-offset, 264); } }
.ring .ring-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
}

/* Buttons */
.btn {
  display: inline-block; border: none; border-radius: 12px; padding: 12px 22px;
  font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none;
  background: linear-gradient(135deg, var(--p-purple), var(--p-pink)); color: #fff;
  box-shadow: 0 6px 18px rgba(139,92,246,.35);
  transition: transform .18s var(--ease-spring), box-shadow .18s var(--ease-mac);
  position: relative; outline-offset: 3px;
}
.btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 10px 26px rgba(139,92,246,.45); }
.btn:active { transform: translateY(0) scale(.97); box-shadow: 0 4px 12px rgba(139,92,246,.35); }
.btn:focus-visible { outline: 2px solid var(--p-purple); }
.btn.secondary { background: #f1f5f9; color: var(--p-ink); box-shadow: none; }
.btn.secondary:hover { background: #e2e8f0; }
.btn.block { display: block; width: 100%; text-align: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px;
  margin: -8px 0 0 -8px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff;
  animation: spSpin .6s linear infinite;
}
@keyframes spSpin { to { transform: rotate(360deg); } }

/* Option buttons (practice/test) */
.option-btn {
  display: block; width: 100%; text-align: left; padding: 14px 18px; margin-bottom: 10px;
  border-radius: 14px; background: #fff; border: 2px solid #ede9fe; color: var(--p-ink);
  cursor: pointer; font-size: 14px; font-weight: 600;
  transition: transform .15s var(--ease-spring), border-color .15s var(--ease-mac), background .15s var(--ease-mac);
}
.option-btn:hover { border-color: var(--p-purple); background: var(--p-bg-1); transform: translateX(4px); }
.option-btn:active { transform: translateX(2px) scale(.99); }
.option-btn:focus-visible { outline: 2px solid var(--p-purple); outline-offset: 2px; }
.option-btn.correct { border-color: var(--p-green); background: #f0fdf4; }
.option-btn.wrong { border-color: var(--p-red); background: #fef2f2; }

/* Badges */
.badge { display: inline-block; padding: 4px 12px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.badge.active, .badge.approved, .badge.correct, .badge.published { background: #dcfce7; color: #166534; }
.badge.inactive, .badge.draft { background: #f1f5f9; color: #64748b; }
.badge.wrong, .badge.rejected { background: #fee2e2; color: #991b1b; }

/* Feedback banners */
.result-banner {
  border-radius: 18px; padding: 20px; text-align: center; font-size: 20px; font-weight: 800;
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1) both;
}
.result-banner.correct { background: #dcfce7; color: #166534; }
.result-banner.wrong { background: #fee2e2; color: #991b1b; }
@keyframes popIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }

/* Celebration for completion screens */
.celebrate { font-size: 56px; animation: celebrateBounce 1s ease infinite; display: inline-block; }
@keyframes celebrateBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-10px) rotate(-6deg); }
  75% { transform: translateY(-4px) rotate(6deg); }
}

/* Forms */
.s-card label, .login-card label { display: block; margin: 12px 0 6px; font-size: 13px; font-weight: 600; color: #6b6485; }
.s-card input[type=text], .s-card input[type=password], .s-card input[type=email],
.s-card select, .s-card textarea,
.login-card input[type=text], .login-card input[type=password], .login-card input[type=email] {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid #ede9fe;
  background: #fff; color: var(--p-ink); font-size: 14px; box-sizing: border-box; font-family: inherit;
  transition: border-color .18s var(--ease-mac), box-shadow .18s var(--ease-mac);
}
.s-card input:focus, .s-card select:focus, .s-card textarea:focus,
.login-card input:focus { outline: none; border-color: var(--p-purple); box-shadow: 0 0 0 4px rgba(139,92,246,.12); }
.s-card input[type=checkbox] { width: auto; margin-right: 8px; accent-color: var(--p-purple); }

/* Password show/hide toggle (structure injected by student.js) */
.sp-pw-wrap { position: relative !important; }
.sp-pw-wrap input { padding-right: 58px !important; }
.sp-pw-toggle {
  position: absolute !important; right: 6px !important; top: 50% !important; transform: translateY(-50%) !important;
  background: none !important; border: none !important; padding: 7px 10px !important; color: var(--p-purple); cursor: pointer;
  border-radius: 8px; line-height: 1; font-size: 12px !important; font-weight: 700;
  width: auto !important; height: auto !important; min-width: 0 !important; margin: 0 !important;
  display: inline-block !important;
  transition: color .15s var(--ease-mac), background .15s var(--ease-mac);
}
.sp-pw-toggle:hover { background: var(--p-bg-1); }

.alert { border-radius: 14px; padding: 12px 16px; margin-bottom: 14px; font-size: 13px; font-weight: 600; animation: fadeInUp .3s var(--ease-out) both; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.success { background: #dcfce7; color: #166534; }

.muted { color: #6b6485; font-size: 13px; }
.center { text-align: center; }

/* Empty state */
.sp-empty-state { text-align: center; padding: 40px 20px; color: #a89fcf; }
.sp-empty-state .icon { font-size: 40px; display: block; margin-bottom: 10px; opacity: .7; }

/* Modal (confirm dialogs, enhanced by student.js) */
.sp-modal-backdrop {
  position: fixed; inset: 0; background: rgba(30,27,58,.35); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 9998;
  opacity: 0; animation: spFade .18s var(--ease-mac) forwards;
}
@keyframes spFade { to { opacity: 1; } }
.sp-modal {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow-modal);
  padding: 28px; max-width: 380px; width: 90%; transform: scale(.94) translateY(10px);
  animation: spModalIn .25s var(--ease-spring) forwards;
}
@keyframes spModalIn { to { transform: scale(1) translateY(0); } }
.sp-modal h3 { margin: 0 0 10px; font-size: 17px; color: var(--p-ink); }
.sp-modal p { font-size: 13.5px; color: #6b6485; margin: 0 0 20px; }
.sp-modal .sp-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

@media (max-width: 640px) {
  .sp-shell { flex-direction: column; }
  .s-nav { width: 100%; min-height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 14px 16px; }
  .s-nav .brand { margin-bottom: 0; margin-right: auto; }
  .s-nav .links { flex-direction: row; flex-wrap: wrap; flex: none; }
  .s-nav form.logout-form { margin-top: 0; }
  .wrap { padding: 20px 16px 40px; }
  h1.s-title { font-size: 22px; }
}
