/* WAEC Exam — school engagement layer (public school profile, invite landing,
   dashboard "My School" panel, leaderboard grade chips).
   Tokens mirror leaderboard.css so the pages read as one brand:
   navy #1E3A8A family, canvas #F4F7FE, white cards, hairline borders. */

.school-page {
  --bg-canvas: #F4F7FE;
  --surface-card: #FFFFFF;
  --surface-subtle: #F8FAFC;
  --brand-navy: #1E3A8A;
  --brand-blue: #1E40AF;
  --brand-indigo-grad: linear-gradient(135deg, #1E1B4B 0%, #312E81 55%, #1E3A8A 100%);
  --cta-orange-grad: linear-gradient(135deg, #FF7A18 0%, #F97316 100%);
  --text-strong: #0F172A;
  --text-body: #475569;
  --text-muted: #94A3B8;
  --border-hairline: #E2E8F0;
  background: var(--bg-canvas);
  color: var(--text-strong);
}

.school-page .app-container { max-height: none; overflow: visible; background: var(--bg-canvas); }
.school-page [hidden] { display: none !important; }
.sp-main { width: 100%; max-width: 1160px; margin: 0 auto; padding: 32px 24px 48px; box-sizing: border-box; }
.sp-main *, .sp-main *::before, .sp-main *::after { box-sizing: border-box; }

.sp-eyebrow { display: block; font-size: 10px; font-weight: 800; letter-spacing: 0.08em; color: var(--text-body); text-transform: uppercase; margin-bottom: 6px; }

/* ---------- hero ---------- */
.sp-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 28px 32px;
  border-radius: 20px;
  color: #FFFFFF;
  background: var(--brand-indigo-grad);
  box-shadow: 0 10px 28px rgba(30, 27, 75, 0.16);
  margin-bottom: 20px;
}
.sp-hero .sp-eyebrow { color: #FBBF24; }
.sp-hero h1 { margin: 0; font-size: 30px; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; color: #FFFFFF; }
.sp-hero-place { margin: 8px 0 0; font-size: 13px; color: #CBD5E1; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.sp-hero-place i { color: #93C5FD; margin-right: 5px; }
.sp-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.sp-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border: 0; border-radius: 10px;
  font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: filter 150ms ease, background 150ms ease;
}
.sp-btn:disabled { cursor: not-allowed; opacity: 0.55; }
.sp-btn-orange { background: var(--cta-orange-grad); color: #FFFFFF; }
.sp-btn-orange:hover { filter: brightness(1.06); }
.sp-btn-ghost { background: rgba(255, 255, 255, 0.12); color: #FFFFFF; border: 1px solid rgba(255, 255, 255, 0.28); }
.sp-btn-ghost:hover { background: rgba(255, 255, 255, 0.2); }
.sp-btn-navy { background: var(--brand-navy); color: #FFFFFF; }
.sp-btn-navy:hover { background: var(--brand-blue); }
.sp-btn-outline { background: #FFFFFF; color: var(--brand-navy); border: 1px solid var(--border-hairline); }
.sp-btn-outline:hover { border-color: #BFDBFE; background: #EFF6FF; }

/* ---------- grade badge ---------- */
.sp-grade-badge {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 132px; height: 132px; border-radius: 20px; text-align: center;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 10px;
}
.sp-grade-letter { font-size: 52px; font-weight: 800; line-height: 1; }
.sp-grade-score { font-size: 12px; font-weight: 700; color: #BFDBFE; margin-top: 6px; }
.sp-grade-rank { font-size: 11px; font-weight: 700; color: #FBBF24; margin-top: 3px; }
.sp-grade-pending { font-size: 13px; font-weight: 700; line-height: 1.45; color: #E0E7FF; }
.sp-grade-progress { width: 100%; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); margin-top: 10px; overflow: hidden; }
.sp-grade-progress > span { display: block; height: 100%; border-radius: 999px; background: #F59E0B; }

/* ---------- stat cards ---------- */
.sp-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.sp-stat {
  background: var(--surface-card); border: 1px solid var(--border-hairline); border-radius: 16px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.sp-stat-value { font-size: 22px; font-weight: 800; color: var(--brand-navy); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sp-stat-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }

/* ---------- panels & student lists ---------- */
.sp-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.sp-panel { background: var(--surface-card); border: 1px solid var(--border-hairline); border-radius: 20px; padding: 22px 24px; }
.sp-panel h2 { margin: 0 0 4px; font-size: 17px; font-weight: 800; color: var(--brand-navy); }
.sp-panel-sub { margin: 0 0 14px; font-size: 12px; color: var(--text-body); }
.sp-student-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sp-student {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border-hairline); min-width: 0;
}
.sp-student:last-child { border-bottom: 0; }
.sp-student-rank { width: 26px; flex-shrink: 0; text-align: center; font-size: 12px; font-weight: 800; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sp-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3B82F6, #1E3A8A); color: #FFFFFF; font-weight: 800; font-size: 15px;
}
.sp-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-student-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.sp-student-name { font-size: 14px; font-weight: 700; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-student-sub { font-size: 11px; color: var(--text-muted); }
.sp-student-score { text-align: right; flex-shrink: 0; }
.sp-student-score strong { display: block; font-size: 15px; font-weight: 800; color: var(--brand-navy); font-variant-numeric: tabular-nums; }
.sp-student-score small { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.sp-empty { padding: 18px 0 6px; font-size: 13px; color: var(--text-body); }
.sp-panel-actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; }
.sp-status { font-size: 13px; margin: 14px 0 0; min-height: 18px; }
.sp-status.is-error { color: #DC2626; }
.sp-status.is-success { color: #059669; }

/* ---------- invite landing ---------- */
.sp-invite-wrap { max-width: 640px; margin: 0 auto; }
.sp-invite-card { background: var(--surface-card); border: 1px solid var(--border-hairline); border-radius: 20px; padding: 28px; text-align: center; }
.sp-invite-card .sp-hero { margin: -28px -28px 22px; border-radius: 20px 20px 0 0; grid-template-columns: minmax(0, 1fr); text-align: center; justify-items: center; }
.sp-invite-card .sp-hero-place { color: #CBD5E1; }
.sp-invite-card .sp-hero-place { justify-content: center; }
.sp-invite-card h2 { margin: 0 0 8px; font-size: 19px; font-weight: 800; color: var(--brand-navy); }
.sp-invite-card p { margin: 0 auto 18px; max-width: 46ch; font-size: 13.5px; line-height: 1.6; color: var(--text-body); }
.sp-invite-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.sp-invite-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; margin-bottom: 18px; font-size: 12px; font-weight: 700; color: var(--text-body); }
.sp-invite-meta i { color: var(--brand-blue); margin-right: 5px; }

/* ---------- loading / error states ---------- */
.sp-state { background: var(--surface-card); border: 1px solid var(--border-hairline); border-radius: 20px; padding: 40px 28px; text-align: center; }
.sp-state h2 { margin: 0 0 8px; font-size: 19px; font-weight: 800; color: var(--brand-navy); }
.sp-state p { margin: 0 auto 18px; max-width: 52ch; font-size: 13.5px; line-height: 1.6; color: var(--text-body); }
.sp-spinner { width: 34px; height: 34px; margin: 0 auto 16px; border-radius: 50%; border: 4px solid #DBEAFE; border-top-color: var(--brand-blue); animation: sp-spin 0.8s linear infinite; }
@keyframes sp-spin { to { transform: rotate(360deg); } }

/* ---------- leaderboard grade chip ---------- */
.lb-grade-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 7px;
  font-size: 12px; font-weight: 800; line-height: 1; vertical-align: middle;
}
.lb-grade-a { background: rgba(16, 185, 129, 0.16); color: #047857; }
.lb-grade-b { background: rgba(59, 130, 246, 0.16); color: #1D4ED8; }
.lb-grade-c { background: rgba(245, 158, 11, 0.18); color: #B45309; }
.lb-grade-d { background: rgba(249, 115, 22, 0.16); color: #C2410C; }
.lb-grade-e, .lb-grade-f { background: rgba(239, 68, 68, 0.14); color: #B91C1C; }
a.lb-school-link { text-decoration: none; }
a.lb-school-link:hover .lb-school-name { text-decoration: underline; }

/* ---------- dashboard "My School" panel ---------- */
.my-school-panel { margin-top: 16px; border-top: 1px solid #E2E8F0; padding-top: 16px; }
.my-school-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.my-school-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px;
  background: #EFF6FF; color: #1E3A8A; font-size: 12px; font-weight: 700;
}
.my-school-chip i { color: #2563EB; }
.my-school-chip.is-grade { background: #1E3A8A; color: #FFFFFF; }
.my-school-chip.is-grade i { color: #FBBF24; }
.my-school-chip.is-pending { background: #FEF3C7; color: #92400E; }
.my-school-chip.is-pending i { color: #D97706; }
.my-school-mates { display: flex; flex-wrap: wrap; gap: 10px 14px; margin: 4px 0 14px; padding: 0; list-style: none; }
.my-school-mate { display: flex; align-items: center; gap: 8px; min-width: 0; }
.my-school-mate .sp-avatar { width: 30px; height: 30px; font-size: 12px; }
.my-school-mate-name { font-size: 12.5px; font-weight: 700; color: #0F172A; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-school-mate-score { font-size: 11px; font-weight: 700; color: #64748B; }
.my-school-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.my-school-empty { font-size: 13px; color: #475569; margin: 0 0 12px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .sp-grid { grid-template-columns: minmax(0, 1fr); }
  .sp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .sp-main { padding: 20px 14px 36px; }
  .sp-hero { grid-template-columns: minmax(0, 1fr); padding: 22px 20px; justify-items: start; }
  .sp-hero h1 { font-size: 24px; }
  .sp-grade-badge { width: 100%; height: auto; flex-direction: row; gap: 12px; justify-content: flex-start; text-align: left; }
  .sp-grade-letter { font-size: 40px; }
  .sp-invite-card { padding: 22px 18px; }
  .sp-invite-card .sp-hero { margin: -22px -18px 18px; }
}
