/* Course Portal — LearnLoop LMS. Namespaced .cp */
* { box-sizing: border-box; }
body { margin: 0; }
.cp {
    --bg: #faf7ff; --panel: #ffffff; --line: #ece4f6; --ink: #1e1b2e; --muted: #6b7280;
    --brand: #7c3aed; --brand-ink: #6d28d9; --accent: #f59e0b;
    --ok: #16a34a; --warn: #f59e0b; --danger: #dc2626; --info: #2563eb;
    --shadow: 0 12px 32px -18px rgba(124,58,237,.32);
    min-height: calc(100vh - 44px);
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
    background: radial-gradient(1000px 420px at 88% -10%, rgba(124,58,237,.08), transparent), var(--bg);
    color: var(--ink);
}
.cp-btn { border: 0; cursor: pointer; border-radius: .6rem; padding: .6rem 1rem; font: 600 .88rem inherit; background: var(--brand); color: #fff; transition: transform .1s, background .15s; white-space: nowrap; }
.cp-btn:hover { transform: translateY(-1px); }
.cp-btn.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.cp-btn.ghost:hover { border-color: var(--brand); color: var(--brand-ink); }
.cp-btn.sm { padding: .42rem .75rem; font-size: .8rem; }
.cp-btn:disabled { opacity: .45; cursor: not-allowed; }
.cp-h2 { margin: 0 0 1.1rem; font-size: 1.25rem; }

/* Topbar */
.cp-topbar { display: flex; align-items: center; gap: 1rem; padding: .8rem 1.5rem; background: var(--panel); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; flex-wrap: wrap; }
.cp-brand { display: flex; align-items: center; gap: .6rem; }
.cp-logo { font-size: 1.6rem; }
.cp-brand b { display: block; font-size: 1.05rem; }
.cp-brand small { color: var(--muted); font-size: .72rem; }
.cp-nav { display: flex; gap: .25rem; margin: 0 auto; flex-wrap: wrap; }
.cp-navbtn { border: 0; background: transparent; color: var(--muted); padding: .5rem .8rem; border-radius: .6rem; font: 600 .85rem inherit; cursor: pointer; }
.cp-navbtn:hover { color: var(--ink); background: #f3edfc; }
.cp-navbtn.active { background: var(--brand); color: #fff; }
.cp-top-actions { display: flex; align-items: center; gap: .6rem; }
.cp-xp { font-size: .78rem; font-weight: 700; color: var(--brand-ink); background: #f3edfc; padding: .25rem .6rem; border-radius: 999px; }
.cp-streak { font-size: .8rem; font-weight: 700; }

.cp-view { max-width: 1240px; margin: 0 auto; padding: 1.5rem; }
.cp-view[hidden] { display: none !important; }
.cp-card { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: 1.3rem; box-shadow: var(--shadow); }
.cp-card h3 { margin: 0 0 1rem; font-size: .95rem; }

/* Stats */
.cp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.cp-stat { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.cp-stat b { font-size: 1.6rem; font-weight: 800; display: block; }
.cp-stat small { color: var(--muted); font-size: .76rem; }

/* Continue banner */
.cp-continue { background: linear-gradient(135deg, #4c1d95, #7c3aed, #a855f7); color: #fff; border-radius: 1.2rem; padding: 1.5rem; display: flex; align-items: center; gap: 1.5rem; margin-bottom: 2rem; box-shadow: var(--shadow); flex-wrap: wrap; }
.cp-continue .ring { width: 68px; height: 68px; flex: none; }
.cp-continue .ct { flex: 1; min-width: 12rem; }
.cp-continue .ct small { opacity: .85; font-size: .78rem; }
.cp-continue .ct b { display: block; font-size: 1.15rem; margin: .2rem 0; }
.cp-continue .ct .nxt { opacity: .9; font-size: .85rem; }
.cp-continue .cp-btn { background: var(--panel); color: var(--brand-ink); }

/* Course grid */
.cp-course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.2rem; }
.cp-course { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.cp-course .thumb { height: 120px; display: grid; place-items: center; font-size: 3rem; color: #fff; }
.cp-course .body { padding: 1rem 1.1rem 1.2rem; flex: 1; display: flex; flex-direction: column; }
.cp-course .cat { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-ink); font-weight: 800; }
.cp-course h3 { margin: .25rem 0 .3rem; font-size: 1rem; }
.cp-course .inst { color: var(--muted); font-size: .8rem; }
.cp-course .meta { display: flex; gap: .8rem; font-size: .76rem; color: var(--muted); margin: .5rem 0; }
.cp-course .meta .r { color: var(--accent); font-weight: 700; }
.cp-course .desc { font-size: .82rem; color: var(--muted); line-height: 1.5; flex: 1; }
.cp-course .cbar { height: 7px; background: #ede9fe; border-radius: 999px; overflow: hidden; margin: .8rem 0 .5rem; }
.cp-course .cbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #a855f7); }
.cp-course .cfoot { display: flex; justify-content: space-between; align-items: center; margin-top: .6rem; }
.cp-course .price { font-weight: 800; }

/* Browse filters */
.cp-browse-filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.cp-fbtn { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: .4rem .9rem; font: 600 .8rem inherit; cursor: pointer; }
.cp-fbtn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* PLAYER */
.cp-player-view { display: grid; grid-template-columns: 320px 1fr; gap: 1.5rem; align-items: start; max-width: 1400px; }
@media (max-width: 900px) { .cp-player-view { grid-template-columns: 1fr; } }
.cp-curriculum { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); overflow: hidden; position: sticky; top: 76px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; }
@media (max-width: 900px) { .cp-curriculum { position: static; max-height: none; } }
.cp-curr-head { padding: 1.1rem 1.2rem; border-bottom: 1px solid var(--line); }
.cp-curr-head b { display: block; font-size: .95rem; margin-bottom: .6rem; }
.cp-curr-progress { display: flex; align-items: center; gap: .6rem; }
.cp-curr-bar { flex: 1; height: 7px; background: #ede9fe; border-radius: 999px; overflow: hidden; }
.cp-curr-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #a855f7); width: 0; transition: width .4s; }
.cp-curr-progress span { font-size: .78rem; font-weight: 700; color: var(--brand-ink); }
.cp-sections { overflow: auto; padding: .5rem; }
.cp-section-title { font-size: .78rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: .7rem .6rem .4rem; }
.cp-lrow { display: flex; align-items: center; gap: .6rem; padding: .55rem .6rem; border-radius: .5rem; cursor: pointer; font-size: .85rem; }
.cp-lrow:hover { background: #f3edfc; }
.cp-lrow.active { background: #ede9fe; font-weight: 600; }
.cp-lrow .tick { width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 2px solid #ddd6fe; display: grid; place-items: center; font-size: .65rem; color: #fff; flex: none; }
.cp-lrow.done .tick { background: var(--ok); border-color: var(--ok); }
.cp-lrow .licon { font-size: .9rem; flex: none; }
.cp-lrow .lt { flex: 1; min-width: 0; }
.cp-lrow .ld { color: var(--muted); font-size: .72rem; flex: none; }

.cp-lesson { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); overflow: hidden; }
.cp-video { position: relative; aspect-ratio: 16/9; background: linear-gradient(135deg, #2e1065, #6d28d9, #a21caf); display: grid; place-items: center; }
.cp-play { width: 4.5rem; height: 4.5rem; border-radius: 50%; border: 0; cursor: pointer; font-size: 1.4rem; color: var(--brand-ink); background: rgba(255,255,255,.92); box-shadow: 0 10px 30px rgba(0,0,0,.35); transition: transform .15s; }
.cp-play:hover { transform: scale(1.08); }
.cp-video-meta { position: absolute; left: 1rem; bottom: 1rem; right: 1rem; color: #fff; display: flex; justify-content: space-between; align-items: flex-end; }
.cp-video-meta b { font-size: .95rem; text-shadow: 0 1px 4px rgba(0,0,0,.4); }
.cp-video-scrub { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.25); }
.cp-video-scrub i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s linear; }
.cp-lesson-body { padding: 1.5rem; }
.cp-lesson-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.cp-lesson-h h2 { margin: 0 0 .2rem; font-size: 1.2rem; }
.cp-lesson-h .l { color: var(--muted); font-size: .82rem; }
.cp-tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin: 1.2rem 0; }
.cp-tab { border: 0; background: transparent; padding: .6rem .9rem; font: 600 .82rem inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.cp-tab.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.cp-tabpane { font-size: .9rem; line-height: 1.65; color: #33303f; }
.cp-chapter-list { list-style: none; padding: 0; margin: 0; }
.cp-chapter-list li { display: flex; gap: .6rem; padding: .5rem .2rem; border-bottom: 1px dashed var(--line); font-size: .86rem; }
.cp-chapter-list li .num { color: var(--brand-ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.cp-reading { font-size: .92rem; line-height: 1.7; }
.cp-resources { display: flex; flex-direction: column; gap: .5rem; }
.cp-resource { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: .6rem; font-size: .85rem; background: #faf7ff; }
.cp-resource .ic { font-size: 1.1rem; }
.cp-resource .s { margin-left: auto; color: var(--muted); font-size: .76rem; }
.cp-resource button { border: 0; background: var(--brand); color: #fff; border-radius: .4rem; padding: .3rem .7rem; font: 600 .74rem inherit; cursor: pointer; }
.cp-notes-area { width: 100%; min-height: 130px; font: inherit; padding: .8rem; border: 1px solid var(--line); border-radius: .6rem; resize: vertical; }
.cp-qa { display: flex; flex-direction: column; gap: .7rem; }
.cp-qa-item { border: 1px solid var(--line); border-radius: .7rem; padding: .7rem .9rem; font-size: .85rem; background: #faf7ff; }
.cp-qa-item .u { font-weight: 700; }
.cp-qa-item.staff { border-color: #ddd6fe; background: #f3edfc; }
.cp-qa-item .u .tag { font-size: .64rem; background: var(--brand); color: #fff; border-radius: 999px; padding: .05rem .4rem; margin-left: .3rem; }
.cp-qa-item .ago { color: var(--muted); font-size: .72rem; }
.cp-qa-form { display: flex; gap: .5rem; margin-top: .3rem; }
.cp-qa-form input { flex: 1; font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: .6rem; }

.cp-lesson-nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.2rem 1.5rem; border-top: 1px solid var(--line); background: #faf7ff; flex-wrap: wrap; }

/* Quiz */
.cp-quiz { padding: 1.5rem; }
.cp-quiz .qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; flex-wrap: wrap; gap: .6rem; }
.cp-quiz .qhead .prog { color: var(--muted); font-size: .82rem; }
.cp-q { margin-bottom: 1.5rem; }
.cp-q .qt { font-weight: 600; margin-bottom: .7rem; }
.cp-q .qtype { font-size: .7rem; color: var(--muted); font-weight: 600; margin-left: .4rem; }
.cp-opt { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border: 1.5px solid var(--line); border-radius: .6rem; margin-bottom: .45rem; cursor: pointer; font-size: .88rem; }
.cp-opt:hover { border-color: #c4b5fd; }
.cp-opt.sel { border-color: var(--brand); background: #f3edfc; }
.cp-opt.correct { border-color: var(--ok); background: #f0fdf4; }
.cp-opt.wrong { border-color: var(--danger); background: #fef2f2; }
.cp-opt input { accent-color: var(--brand); }
.cp-quiz-result { border-radius: .8rem; padding: 1.2rem; margin-bottom: 1rem; }
.cp-quiz-result.pass { background: #f0fdf4; border: 1px solid #bbf7d0; }
.cp-quiz-result.fail { background: #fef2f2; border: 1px solid #fecaca; }
.cp-quiz-result b { font-size: 1.3rem; }

/* ACHIEVEMENTS */
.cp-ach-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.cp-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.cp-badge { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: 1.2rem; text-align: center; box-shadow: var(--shadow); }
.cp-badge.locked { opacity: .5; filter: grayscale(1); }
.cp-badge .bi { font-size: 2rem; }
.cp-badge b { display: block; margin: .4rem 0 .2rem; font-size: .9rem; }
.cp-badge small { color: var(--muted); font-size: .74rem; }
.cp-gradebook { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; overflow: hidden; box-shadow: var(--shadow); margin-bottom: 2rem; }
.cp-gb-row { display: grid; grid-template-columns: 1fr auto auto; gap: 1rem; padding: .8rem 1.2rem; border-bottom: 1px solid var(--line); font-size: .88rem; align-items: center; }
.cp-gb-row.head { background: #faf7ff; font-weight: 700; color: var(--muted); font-size: .76rem; text-transform: uppercase; }
.cp-gb-row:last-child { border-bottom: 0; }
.cp-gb-score { font-weight: 700; }
.cp-gb-score.pass { color: var(--ok); }
.cp-gb-score.fail { color: var(--danger); }
.cp-gb-score.pending { color: var(--muted); }
.cp-cert-wrap { }
.cp-certificate { max-width: 620px; margin: 0 auto; text-align: center; border: 4px double #c4b5fd; border-radius: 1rem; padding: 2.5rem 2rem; background: radial-gradient(140% 140% at 50% 0%, #faf7ff, #fff); box-shadow: var(--shadow); }
.cp-certificate .seal { width: 3.5rem; height: 3.5rem; margin: 0 auto .6rem; border-radius: 50%; background: linear-gradient(135deg, var(--brand), #c026d3); color: #fff; display: grid; place-items: center; font-size: 1.5rem; }
.cp-certificate .kick { text-transform: uppercase; letter-spacing: .22em; color: var(--brand-ink); font-size: .74rem; font-weight: 800; }
.cp-certificate h2 { margin: .4rem 0; font-size: 1.5rem; }
.cp-certificate .awarded { color: var(--muted); font-size: .86rem; margin: .6rem 0 .1rem; }
.cp-certificate .name { font-family: Georgia, "Times New Roman", serif; font-size: 1.8rem; font-weight: 800; color: #4c1d95; margin: .2rem 0; }
.cp-certificate .meta { color: var(--muted); font-size: .84rem; margin: .5rem 0 1.2rem; }
.cp-cert-locked { text-align: center; color: var(--muted); padding: 2.5rem 1rem; border: 1px dashed var(--line); border-radius: 1rem; }

/* ANALYTICS */
.cp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.cp-kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: 1.2rem; box-shadow: var(--shadow); }
.cp-kpi b { font-size: 1.7rem; font-weight: 800; display: block; }
.cp-kpi small { color: var(--muted); font-size: .78rem; }
.cp-kpi .delta { color: var(--ok); font-size: .74rem; font-weight: 600; }
.cp-analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 860px) { .cp-analytics-grid { grid-template-columns: 1fr; } }
.cp-card-wide { grid-column: 1 / -1; }
#cp-enrolchart, #cp-scorechart { width: 100%; height: 200px; }
.cp-funnel-row { display: flex; align-items: center; gap: .8rem; padding: .35rem 0; font-size: .82rem; }
.cp-funnel-row .fn { width: 12rem; color: var(--muted); flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-funnel-row .fbar { flex: 1; height: 16px; background: var(--line); border-radius: 4px; overflow: hidden; }
.cp-funnel-row .fbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #a855f7); }
.cp-funnel-row .fp { width: 3rem; text-align: right; color: var(--muted); flex: none; }

/* Toast */
.cp-toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: #1e1b2e; color: #fff; padding: .7rem 1.1rem; border-radius: .7rem; font-size: .88rem; z-index: 200; box-shadow: 0 15px 40px -12px rgba(0,0,0,.4); max-width: 90vw; }
.cp-toast[hidden] { display: none; }

@media print {
    .demo-chrome, .cp-topbar, .cp-nav, .cp-h2, .cp-ach-top, .cp-badges, .cp-gradebook { display: none !important; }
    .cp { background: var(--panel); }
    .cp-certificate { box-shadow: none; }
}
