/* =====================================================================
   study-plus.css — styles for study-plus.js (lately list, ratings, quiz,
   certificates, teacher insights). Load it AFTER notifications.css.
   Dark by default, `.light-theme` overrides at the bottom. Only transform /
   opacity are animated; no blur; honours prefers-reduced-motion.
   ===================================================================== */
:root {
    --sp-bg: rgba(14, 18, 36, .58);
    --sp-line: rgba(255, 255, 255, .09);
    --sp-text: #e5e7eb;
    --sp-muted: #a3aec2;
    --sp-accent: #7c6cff;
    --sp-accent-2: #a78bfa;
    --sp-good: #34d399;
    --sp-bad: #fb7185;
    --sp-gold: #fbbf24;
}
.sp-hidden { display: none !important; }
.sp-muted { color: var(--sp-muted); font-size: 11px; line-height: 1.5; }
.sp-ok { color: var(--sp-good); }
.sp-bad { color: var(--sp-bad); }

/* ---------- Buttons / chips ---------- */
.sp-btn {
    cursor: pointer; border: 0; border-radius: 10px; padding: 7px 14px; min-height: 34px;
    font: 700 12px/1 'Plus Jakarta Sans', system-ui, sans-serif; color: #fff;
    background: linear-gradient(135deg, #6366f1, #7c6cff 55%, #9b7bff);
    box-shadow: 0 8px 18px -10px rgba(99, 102, 241, .8);
}
.sp-btn:hover { filter: brightness(1.1); }
.sp-btn.sp-ghost { background: transparent; color: var(--sp-accent-2); box-shadow: none; border: 1px solid rgba(167, 139, 250, .35); }
.sp-chip {
    cursor: pointer; border-radius: 999px; padding: 6px 12px; min-height: 30px; white-space: nowrap;
    font: 700 11px/1 'Plus Jakarta Sans', system-ui, sans-serif; color: #c4b5fd;
    background: rgba(124, 108, 255, .12); border: 1px solid rgba(167, 139, 250, .3);
}
.sp-chip:hover { background: rgba(124, 108, 255, .24); }

/* ---------- Dashboard / admin card ---------- */
.sp-card {
    border: 1px solid var(--sp-line); border-radius: 18px; padding: 18px; color: var(--sp-text);
    background: linear-gradient(135deg, rgba(49, 46, 129, .16), rgba(15, 23, 42, .4));
}
.sp-card h3 { margin: 0; font-size: 14px; font-weight: 800; color: #fff; letter-spacing: -.005em; }
.sp-card h4 { margin: 0 0 8px; font-size: 12px; font-weight: 800; color: #fff; }
.sp-card h4 small { color: var(--sp-muted); font-weight: 600; }
.sp-card header { margin-bottom: 10px; }
.sp-grid2 { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 900px) { .sp-grid2 { grid-template-columns: 1.25fr 1fr; } }
.sp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sp-item, .sp-list > li:not(.sp-empty) {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px;
    background: rgba(2, 6, 23, .38); border: 1px solid var(--sp-line);
}
.sp-item-main { flex: 1; min-width: 0; }
.sp-item-title { font-size: 12px; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-item-meta { font-size: 10px; color: var(--sp-muted); margin-top: 2px; }
.sp-empty { padding: 14px; font-size: 12px; color: var(--sp-muted); text-align: center; border: 1px dashed var(--sp-line); border-radius: 14px; }
.sp-tag {
    flex: none; min-width: 64px; text-align: center; font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    padding: 4px 8px; border-radius: 999px; background: rgba(124, 108, 255, .16); color: #c4b5fd;
}
.sp-tag-resume { background: rgba(251, 191, 36, .14); color: #fcd34d; }
.sp-tag-revise { background: rgba(56, 189, 248, .14); color: #7dd3fc; }
.sp-tag-start, .sp-tag-next { background: rgba(52, 211, 153, .14); color: #6ee7b7; }
.sp-tag-cert, .sp-tag-lock { min-width: 34px; font-size: 14px; letter-spacing: 0; padding: 3px 6px; }
.sp-locked { opacity: .8; }
.sp-bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; margin: 6px 0 2px; }
.sp-bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6366f1, #a855f7, #06b6d4); }
.sp-bar-lg { height: 10px; margin: 10px 0 12px; }
.sp-pill { flex: none; font-size: 10px; font-weight: 800; color: var(--sp-gold); background: rgba(251, 191, 36, .1); padding: 3px 9px; border-radius: 999px; }
.sp-admin-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sp-admin-grid { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 900px) { .sp-admin-grid { grid-template-columns: 1fr 1fr; } }
.sp-select {
    width: 100%; margin-bottom: 10px; padding: 9px 12px; border-radius: 12px; font-size: 12px; color: var(--sp-text);
    background: rgba(2, 6, 23, .5); border: 1px solid var(--sp-line);
}

/* ---------- Rating ---------- */
.sp-rate { padding: 10px 12px; border-radius: 14px; background: rgba(2, 6, 23, .32); border: 1px solid var(--sp-line); }
.sp-rate-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sp-rate-label { font-size: 11px; font-weight: 800; color: #fff; text-transform: uppercase; letter-spacing: .05em; }
.sp-stars { display: inline-flex; gap: 2px; }
.sp-star { cursor: pointer; border: 0; background: transparent; padding: 3px; line-height: 0; color: #475569; min-height: 32px; min-width: 32px; display: inline-flex; align-items: center; justify-content: center; }
.sp-star svg { fill: currentColor; transition: transform .15s ease; }
.sp-star.on { color: var(--sp-gold); }
.sp-star:hover svg { transform: scale(1.18); }
.sp-rate-avg { font-size: 11px; color: var(--sp-muted); font-weight: 600; }
.sp-rate-extra { display: flex; gap: 8px; margin-top: 8px; }
.sp-rate-extra input {
    flex: 1; min-width: 0; padding: 8px 12px; font-size: 12px; border-radius: 10px; color: var(--sp-text);
    background: rgba(2, 6, 23, .5); border: 1px solid var(--sp-line);
}
.sp-rate.sp-staff .sp-stars, .sp-rate.sp-staff .sp-rate-extra { display: none; }

/* ---------- Teacher insights / heat ---------- */
.sp-insights { padding: 12px; border-radius: 14px; background: rgba(2, 6, 23, .32); border: 1px solid rgba(251, 191, 36, .25); }
.sp-insights-head { font-size: 11px; font-weight: 800; color: var(--sp-gold); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.sp-insight-line { margin: 0 0 8px; font-size: 12px; color: var(--sp-text); }
.sp-heat { display: flex; align-items: flex-end; gap: 2px; height: 76px; padding: 4px; border-radius: 10px; background: rgba(2, 6, 23, .45); }
.sp-heat-bar { flex: 1; min-width: 2px; border-radius: 3px 3px 0 0; background: #6366f1; display: block; }
.sp-heat-bar.hot { background: #f43f5e; }
.sp-heat-axis { display: flex; justify-content: space-between; font: 500 9px/1.6 'JetBrains Mono', monospace; color: var(--sp-muted); }
.sp-hot { list-style: none; margin: 0; padding: 0; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.sp-hot li { color: var(--sp-text); }
.sp-hot li span { color: var(--sp-muted); }

/* ---------- Modals (quiz, certificate, verify) ---------- */
.sp-modal {
    position: fixed; inset: 0; z-index: 100010; display: flex; align-items: center; justify-content: center;
    padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
    background: rgba(3, 5, 16, .78); overflow-y: auto;
}
.sp-modal-card {
    width: min(560px, 100%); max-height: 100%; overflow-y: auto; padding: 18px; border-radius: 20px; color: var(--sp-text);
    background: linear-gradient(180deg, rgba(24, 28, 54, .99), rgba(10, 13, 28, .99)); border: 1px solid rgba(167, 139, 250, .25);
    box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .8); animation: spPop .28s cubic-bezier(.22, 1, .36, 1) both;
}
.sp-modal-card.sp-wide { width: min(940px, 100%); }
.sp-modal-card.sp-narrow { width: min(520px, 100%); }
@keyframes spPop { from { opacity: 0; transform: translate3d(0, 14px, 0) scale(.98); } to { opacity: 1; transform: none; } }
.sp-modal-card h3 { margin: 0 0 6px; font-size: 16px; font-weight: 800; color: #fff; }
.sp-modal-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; color: #fff; }
.sp-verify-name { font-size: 20px; font-weight: 800; color: #fff; margin: 4px 0; }

/* quiz */
.sp-q { font-size: 15px; font-weight: 700; line-height: 1.5; color: #fff; margin: 14px 0; word-break: break-word; }
.sp-opts { display: flex; flex-direction: column; gap: 8px; }
.sp-opt {
    display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; padding: 11px 12px; min-height: 46px; border-radius: 12px;
    font-size: 13px; line-height: 1.4; color: var(--sp-text); background: rgba(2, 6, 23, .45); border: 1px solid var(--sp-line);
    transition: border-color .15s ease, background-color .15s ease;
}
.sp-opt span { flex: none; width: 24px; height: 24px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; background: rgba(124, 108, 255, .2); color: #c4b5fd; }
.sp-opt:hover:not(:disabled) { border-color: rgba(167, 139, 250, .6); }
.sp-opt:disabled { cursor: default; opacity: 1; }
.sp-opt.right { border-color: var(--sp-good); background: rgba(52, 211, 153, .12); }
.sp-opt.wrong { border-color: var(--sp-bad); background: rgba(251, 113, 133, .12); }
#sp-quiz-fb { margin-top: 12px; font-size: 12px; line-height: 1.6; }
.sp-missed { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 12px; line-height: 1.55; }
.sp-missed li { padding: 10px 12px; border-radius: 12px; background: rgba(2, 6, 23, .45); border: 1px solid var(--sp-line); }
.sp-quiz-loading { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 8px; text-align: center; font-size: 14px; color: #fff; }
.sp-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(167, 139, 250, .25); border-top-color: #a78bfa; animation: spSpin .8s linear infinite; }
@keyframes spSpin { to { transform: rotate(360deg); } }

/* ---------- Certificate (always light paper, whatever the theme) ---------- */
.sp-cert {
    container-type: inline-size; position: relative; width: 100%; aspect-ratio: 297 / 210; overflow: hidden; border-radius: 6px;
    background: radial-gradient(circle at 50% 0%, #fffef9, #fff7e1 90%); color: #2b1a5e;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.sp-cert::before { content: ''; position: absolute; inset: 2.2cqw; border: .55cqw solid #b8860b; border-radius: .8cqw; pointer-events: none; }
.sp-cert::after { content: ''; position: absolute; inset: 3.5cqw; border: .16cqw solid #7c3aed; border-radius: .4cqw; pointer-events: none; }
.sp-cert-in { position: absolute; inset: 6cqw 7cqw; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; }
.sp-cert-top { display: flex; align-items: center; gap: 1.4cqw; }
.sp-cert-top img { height: 6cqw; width: 6cqw; object-fit: contain; }
.sp-cert-academy { font-size: 1.9cqw; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #5b21b6; }
.sp-cert-kicker { font-family: Georgia, 'Times New Roman', serif; font-size: 5.2cqw; font-weight: 700; letter-spacing: .06em; color: #7c3aed; }
.sp-cert-presented { font-size: 1.8cqw; letter-spacing: .08em; color: #6b5b95; }
.sp-cert-name { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 6.4cqw; line-height: 1.15; color: #1e1b4b; max-width: 100%; overflow-wrap: anywhere; border-bottom: .2cqw solid #b8860b; padding: 0 3cqw .8cqw; }
.sp-cert-line { font-size: 2cqw; color: #4c3f7a; max-width: 80%; line-height: 1.5; }
.sp-cert-title { font-size: 3.6cqw; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; color: #b8860b; }
.sp-cert-foot { width: 100%; display: flex; align-items: flex-end; justify-content: space-between; gap: 3cqw; }
.sp-cert-sig { display: flex; flex-direction: column; align-items: center; font-family: Georgia, serif; font-style: italic; font-size: 2cqw; color: #2b1a5e; min-width: 22cqw; }
.sp-cert-sigline { display: block; width: 100%; height: 0; border-top: .16cqw solid #2b1a5e; margin-bottom: .6cqw; }
.sp-cert-meta { text-align: right; font-size: 1.45cqw; line-height: 1.6; color: #4c3f7a; }
.sp-cert-meta b { font-family: 'JetBrains Mono', monospace; letter-spacing: .06em; color: #1e1b4b; }
.sp-cert-meta small { font-size: 1.15cqw; color: #7a6da8; word-break: break-all; }

/* ---------- Print: only the certificate, one landscape A4 page ---------- */
@media print {
    @page { size: A4 landscape; margin: 0; }
    html, body { background: #fff !important; }
    body > *:not(#sp-cert-modal) { display: none !important; }
    #sp-cert-modal { position: static !important; display: block !important; padding: 0 !important; background: none !important; overflow: visible !important; }
    #sp-cert-modal .sp-modal-card { width: auto !important; max-width: none !important; padding: 0 !important; border: 0 !important; background: none !important; box-shadow: none !important; animation: none !important; overflow: visible !important; }
    #sp-cert-modal .sp-no-print { display: none !important; }
    #sp-cert-modal .sp-cert { width: 297mm !important; height: 210mm !important; aspect-ratio: auto; border-radius: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; page-break-inside: avoid; }
}

/* ---------- Light theme ---------- */
.light-theme .sp-card { color: #1e1b4b; background: rgba(255, 255, 255, .88); border-color: rgba(109, 94, 252, .16); }
.light-theme .sp-card h3, .light-theme .sp-card h4, .light-theme .sp-item-title, .light-theme .sp-rate-label,
.light-theme .sp-modal-card h3, .light-theme .sp-modal-bar, .light-theme .sp-q, .light-theme .sp-verify-name, .light-theme .sp-quiz-loading { color: #1e1b4b; }
.light-theme .sp-muted, .light-theme .sp-item-meta, .light-theme .sp-rate-avg, .light-theme .sp-empty { color: #5b5f87; }
.light-theme .sp-item, .light-theme .sp-list > li:not(.sp-empty), .light-theme .sp-rate, .light-theme .sp-opt, .light-theme .sp-missed li {
    background: #fff; border-color: rgba(109, 94, 252, .16); color: #1e1b4b;
}
.light-theme .sp-insights { background: #fffbeb; }
.light-theme .sp-heat { background: #f1f0ff; }
.light-theme .sp-hot li { color: #1e1b4b; }
.light-theme .sp-chip { color: #6d5efc; background: rgba(109, 94, 252, .1); border-color: rgba(109, 94, 252, .3); }
.light-theme .sp-btn.sp-ghost { color: #6d5efc; border-color: rgba(109, 94, 252, .4); }
.light-theme .sp-bar { background: rgba(109, 94, 252, .14); }
.light-theme .sp-star { color: #cbd5e1; }
.light-theme .sp-star.on { color: #f59e0b; }
.light-theme .sp-rate-extra input, .light-theme .sp-select { background: #fff; color: #1e1b4b; border-color: rgba(109, 94, 252, .25); }
.light-theme .sp-modal { background: rgba(30, 27, 75, .5); }
.light-theme .sp-modal-card { color: #1e1b4b; background: #fff; border-color: rgba(109, 94, 252, .2); }
.light-theme .sp-ok { color: #047857; }
.light-theme .sp-bad { color: #be123c; }

@media (max-width: 767px) {
    .sp-card { padding: 14px; }
    .sp-item { flex-wrap: wrap; }
    .sp-tag { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .sp-modal-card, .sp-spin { animation: none !important; }
    .sp-star svg { transition: none; }
}