/*
 * Josoor design system — learning dashboards (teacher / student / parent).
 * Only what components.css lacks; everything reads tokens.css, so light/dark and the brand
 * colour come for free. Loaded by inc/design-system.php on those three templates only.
 * Class prefix `lrn-` (learning) keeps it clear of components.css and the admin sections.
 */

/* ── Shell touch-ups on top of the legacy bridge ─────────────────────────────── */
.ds-legacy .sidebar-nav-icon.icon { width: 18px; height: 18px; font-size: inherit; }
.ds-legacy .header-btn { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.ds-legacy .header-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.ds-legacy .header-btn .badge { background: var(--bad); color: var(--brand-ink); border: 2px solid var(--surface); width: 20px; height: 20px; }
.ds-legacy .header-avatar { border-color: var(--border-strong); }
.ds-legacy .classera-content { padding: var(--sp-8); max-width: 1320px; }
.ds-btn:disabled { opacity: .55; cursor: not-allowed; }
a.ds-btn { text-decoration: none; }
.ds-btn-sm .icon { width: 16px; height: 16px; }

/* Header: points pill + avatar menu */
.lrn-points { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--radius-pill);
  background: var(--warn-soft); color: var(--warn); font-size: var(--fs-sm); font-weight: var(--fw-semibold); white-space: nowrap; }
.lrn-points .icon { width: 16px; height: 16px; }
.lrn-menu { position: absolute; top: calc(100% + 10px); inset-inline-end: 0; min-width: 210px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.lrn-menu .who { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.lrn-menu .who b { display: block; font-size: var(--fs-md); }
.lrn-menu .who span { font-size: var(--fs-xs); color: var(--text-3); }
.lrn-menu a { display: flex; align-items: center; gap: var(--sp-2); padding: 10px var(--sp-4); color: var(--text); text-decoration: none; font-size: var(--fs-md); }
.lrn-menu a:hover { background: var(--surface-2); }
.lrn-menu a.danger { color: var(--bad); border-top: 1px solid var(--border); }

/* Notification panel */
.lrn-panel-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.lrn-panel-head h3 { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.ds-legacy .notification-panel { background: var(--surface); border-color: var(--border); }

/* header tools that hold only buttons/links stay on the title's row on phones (components.css stacks them) */
.ds-tablehead .tools.lrn-inline, .ds-tablehead .tools.lrn-filters { margin-inline-start: auto; width: auto; }
.ds-stat .hint.lrn-ok { color: var(--ok); } .ds-stat .hint.lrn-bad { color: var(--bad); }
@media (max-width: 640px) { .ds-legacy .ds-pagehead h1 { font-size: var(--fs-xl); } }

/* ── Tones (text colours from status tokens) ─────────────────────────────────── */
.lrn-ok { color: var(--ok); } .lrn-warn { color: var(--warn); } .lrn-bad { color: var(--bad); }
.lrn-info { color: var(--info); } .lrn-brand { color: var(--brand); } .lrn-muted { color: var(--text-3); }
.lrn-strong { font-weight: var(--fw-semibold); }
.lrn-link { color: var(--brand); text-decoration: none; font-weight: var(--fw-semibold); }
.lrn-link:hover { text-decoration: underline; }
.lrn-ltr { direction: ltr; text-align: start; }
.lrn-skel { height: 56px; margin: var(--sp-3) var(--sp-5); border-radius: var(--radius); }
.lrn-skel.lg { height: 200px; } .lrn-skel.sm { height: 40px; }
.lrn-pad { padding: var(--sp-4) var(--sp-5); }
.lrn-gap-top { margin-top: var(--sp-5); }

/* ── Icon tile (rows, covers) ────────────────────────────────────────────────── */
.lrn-ico { width: 38px; height: 38px; border-radius: var(--radius); display: grid; place-items: center; flex: none;
  background: var(--brand-soft); color: var(--brand); font-size: var(--fs-lg); }
.lrn-ico.ok { background: var(--ok-soft); color: var(--ok); } .lrn-ico.warn { background: var(--warn-soft); color: var(--warn); }
.lrn-ico.bad { background: var(--bad-soft); color: var(--bad); } .lrn-ico.info { background: var(--info-soft); color: var(--info); }
.lrn-ico.muted { background: var(--muted-soft); color: var(--text-2); }

.ds-list-row.wrap { flex-wrap: wrap; }
.ds-list-row.wrap > .grow { min-width: 160px; }
.ds-list-row.wrap > .end { margin-inline-start: auto; }
.ds-list-row .end { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; flex: none; }
.ds-list-row .title.ellip, .ds-list-row .sub.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-list > .overdue { background: var(--bad-soft); }
.ds-list > .current { background: var(--brand-soft); }
.ds-list > .dim { opacity: .6; }

/* tables inside cards scroll inside their wrapper rather than widening the page */
.ds-legacy .classera-content .ds-table-wrap { contain: inline-size; }
.ds-table td.center, .ds-table th.center { text-align: center; }

/* ── Progress (components.css ships the track; tones live here) ──────────────── */
.ds-progress > span { transition: width .4s ease; }
.ds-progress.ok > span { background: var(--ok); } .ds-progress.warn > span { background: var(--warn); }
.ds-progress.bad > span { background: var(--bad); } .ds-progress.info > span { background: var(--info); }
.ds-progress.lg { height: 10px; border-radius: 5px; }
.lrn-plabel { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-3); margin: 0 0 var(--sp-1); }
.lrn-pcell { display: flex; align-items: center; gap: var(--sp-2); }
.lrn-pcell .ds-progress { width: 80px; flex: none; }

/* ── Card sections & grids ───────────────────────────────────────────────────── */
.lrn-chart { position: relative; height: 280px; padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.lrn-chart.sm { height: 200px; }
.lrn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.lrn-grid.wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.lrn-grid > .ds-empty { grid-column: 1 / -1; }
.lrn-tile { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); box-shadow: none; background: var(--surface); }
.lrn-cover { height: 84px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.lrn-cover .icon { width: 34px; height: 34px; stroke-width: 1.5; }
.lrn-course { padding: 0; overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: border-color .15s ease, box-shadow .15s ease; }
.lrn-course:hover { border-color: var(--border-strong); }
/* Card grids inside a panel (2026-11-01): a tray in the page tone (same rule as .crs-grid). */
.ds-card .lrn-grid { background: var(--bg); border-radius: 0 0 calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px); }
.lrn-course .body { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); flex: 1; }
.lrn-course .name { font-weight: var(--fw-semibold); font-size: var(--fs-base); line-height: 1.4; }
.lrn-course .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.lrn-hdr-sub { font-size: var(--fs-sm); color: var(--text-3); margin: 2px 0 0; font-weight: var(--fw-regular); }
.lrn-tablehead-title { display: flex; flex-direction: column; }
.lrn-bar { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; padding: var(--sp-4) var(--sp-5) 0; }
.lrn-bar .ds-select, .lrn-bar .ds-input { max-width: 420px; }
.lrn-note-wrap { padding: var(--sp-4) var(--sp-5) 0; }
.lrn-body { padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.lrn-form { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5) var(--sp-2); }
.lrn-form .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .lrn-form { grid-template-columns: 1fr; } }

/* ── Big figure / profile ────────────────────────────────────────────────────── */
.lrn-figure { font-size: var(--fs-2xl); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; line-height: 1.2; }
.lrn-figure.xl { font-size: 2.5rem; }
.lrn-center { text-align: center; }
.lrn-avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: var(--fw-bold); font-size: var(--fs-lg); flex: none; }
.lrn-avatar.lg { width: 56px; height: 56px; font-size: var(--fs-xl); }
.lrn-profile { padding: var(--sp-6); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.lrn-profile img { width: 112px; height: 112px; border-radius: 50%; border: 3px solid var(--border); object-fit: cover; }
.lrn-profile h2 { margin: var(--sp-2) 0 0; font-size: var(--fs-lg); }
.lrn-profile p { margin: 0; color: var(--text-3); font-size: var(--fs-sm); }
.lrn-metrics { display: flex; gap: var(--sp-6); flex-wrap: wrap; justify-content: center; margin-top: var(--sp-3); }
.lrn-metrics .v { font-size: var(--fs-lg); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.lrn-metrics .k { font-size: var(--fs-xs); color: var(--text-3); }

/* ── Children (parent) ───────────────────────────────────────────────────────── */
.lrn-children { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.lrn-children > .ds-empty { grid-column: 1 / -1; }
.lrn-child { padding: var(--sp-4); cursor: pointer; border-width: 2px; display: flex; flex-direction: column; gap: var(--sp-3); }
.lrn-child:hover { border-color: var(--border-strong); }
.lrn-child[aria-current="true"] { border-color: var(--brand); }
.lrn-child .head { display: flex; align-items: center; gap: var(--sp-3); }
.lrn-child .nm { font-weight: var(--fw-semibold); }
.lrn-child .gr { font-size: var(--fs-xs); color: var(--text-3); }

/* ── Chat (student AI assistant) ─────────────────────────────────────────────── */
.lrn-chat { height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--sp-4); }
.lrn-bubble { max-width: 80%; align-self: flex-start; padding: 10px var(--sp-4); border-radius: var(--radius); line-height: 1.7;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.lrn-bubble.me { align-self: flex-end; background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.lrn-chatbar { display: flex; gap: var(--sp-2); }

/* ── Badges & leaderboard (student) ──────────────────────────────────────────── */
.lrn-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--sp-3); padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.lrn-badges.sm { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.lrn-badge { text-align: center; padding: var(--sp-3) var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.lrn-badge .ic { font-size: 1.6rem; line-height: 1.3; }
.lrn-badge .nm { font-size: var(--fs-xs); color: var(--text-2); margin-top: 2px; }
.lrn-badge.locked { opacity: .45; filter: grayscale(1); }
.lrn-rank { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: var(--fw-bold);
  font-size: var(--fs-sm); background: var(--muted-soft); color: var(--text-2); }
.lrn-rank.gold { background: var(--warn-soft); color: var(--warn); }
.lrn-rank.silver { background: var(--info-soft); color: var(--info); }
.lrn-rank.bronze { background: var(--brand-soft); color: var(--brand); }
.lrn-now { color: var(--ok); font-size: var(--fs-xs); font-weight: var(--fw-semibold); white-space: nowrap; }
.lrn-time { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--brand); min-width: 64px; font-variant-numeric: tabular-nums; }

/* assignment filter chips (JS toggles .active) */
.lrn-filters { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }
.lrn-filters .assign-filter.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* payment plan card */
.lrn-plan { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-4); margin-bottom: var(--sp-4); background: var(--surface); }
.lrn-plan .top { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.lrn-plan .next { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-3); background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); margin-top: var(--sp-3); }
.lrn-plan details { margin-top: var(--sp-3); }
.lrn-plan summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); }
.lrn-inst { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 6px var(--sp-3); border-radius: var(--radius-sm); background: var(--surface-2); font-size: var(--fs-sm); margin-top: var(--sp-1); }

/* referral link box */
.lrn-linkbox { display: flex; gap: var(--sp-3); align-items: flex-end; flex-wrap: wrap; padding: var(--sp-4); border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-2); margin-bottom: var(--sp-4); }
.lrn-linkbox .ds-field { flex: 1; min-width: 220px; }

/* ── Messaging centre partial: keep it on tokens (it ships its own inline colours) ── */
.ds-legacy #section-messages .btn { border-radius: var(--radius); }
.ds-legacy #cmsgList { padding: 0; }

@media (max-width: 860px) {
  .ds-legacy .classera-content { padding: var(--sp-5) var(--sp-4); }
  .lrn-chart { height: 240px; }
  .ds-list-row .end { width: 100%; }
}

/* ── Public course catalog (templates/page-courses.php) ──────────────────────── */
.lrn-catgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-4); }
.lrn-catgrid > .ds-card.ds-empty { grid-column: 1 / -1; }
.lrn-catgrid > .lrn-skel { margin: 0; height: 280px; }
/* three KPIs stay on one row, even on a phone (icon tile drops out there) */
.ds-stats.lrn-cat-stats { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) {
  .ds-stats.lrn-cat-stats { gap: var(--sp-2); }
  .lrn-cat-stats .ds-stat { padding: var(--sp-3); }
  .lrn-cat-stats .ds-stat .ico { display: none; }
  .lrn-cat-stats .ds-stat .value { font-size: var(--fs-lg); }
}
.lrn-empty-ico { width: 36px; height: 36px; margin-bottom: var(--sp-2); }
.lrn-empty-ico-wrap { margin-bottom: var(--sp-2); }
.lrn-empty-ico-wrap .icon { width: 32px; height: 32px; }
.lrn-cover.info { background: var(--info-soft); color: var(--info); }
.lrn-cover.ok { background: var(--ok-soft); color: var(--ok); }
.lrn-cover.warn { background: var(--warn-soft); color: var(--warn); }
.lrn-course .lrn-cover { position: relative; height: 120px; border-bottom: 1px solid var(--border); }
.lrn-cover-tags { position: absolute; inset-block-start: var(--sp-2); inset-inline: var(--sp-2);
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-2); }
.lrn-cover-tags .icon { width: 14px; height: 14px; stroke-width: 1.75; }
.lrn-cover-cat { max-width: 70%; overflow: hidden; text-overflow: ellipsis; background: var(--surface); color: var(--text-2); }
.lrn-summary { margin: 0; line-height: 1.6; }
.lrn-actionrow { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.lrn-course .name .lrn-course-link { color: inherit; text-decoration: none; }
.lrn-course .name .lrn-course-link:hover, .lrn-course .name .lrn-course-link:focus-visible { color: var(--brand); text-decoration: underline; }
.lrn-course .course-action { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.lrn-count { display: inline-flex; align-items: center; gap: 6px; }
.lrn-count .icon { width: 16px; height: 16px; }
/* A module's meta row on a course card (card_meta items: plain text or a pill) */
.lrn-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); min-width: 0; }
.lrn-meta > span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; font-size: var(--fs-xs); }
.lrn-meta > .ds-sub .icon { width: 15px; height: 15px; color: var(--text-3); flex: none; }
.lrn-meta > .ds-pill .icon { width: 13px; height: 13px; flex: none; }
.lrn-buy { display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-1); }
.lrn-price { color: var(--brand); font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.lrn-price-old { color: var(--text-3); font-weight: var(--fw-regular, 400); }
.lrn-price-sub { color: var(--text-2); font-weight: var(--fw-regular, 400); font-size: var(--fs-xs); }
.lrn-course .foot { padding-top: var(--sp-2); border-top: 1px solid var(--border); }
/* Course cards with their facts (2026-11-01): cover image, teacher, «أكملت X من Y», the next lesson */
.lrn-mycourse .lrn-cover { text-decoration: none; }
.lrn-cover.has-img { background: var(--brand-soft) center/cover no-repeat; }
.lrn-mycourse .lrn-cover-tags { justify-content: flex-start; flex-wrap: wrap; }
.lrn-mycourse .lrn-cover-tags .ds-pill { box-shadow: var(--shadow-sm); }
.lrn-mycourse .name { display: block; font-weight: var(--fw-semibold); font-size: var(--fs-base); line-height: 1.45; }
.lrn-mycourse .name:hover { color: var(--brand); }
.lrn-teacher, .lrn-next { display: flex; align-items: center; gap: 6px; }
.lrn-teacher .icon, .lrn-next .icon { width: 15px; height: 15px; color: var(--text-3); flex: none; }
.lrn-next span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrn-prog .lrn-plabel { font-size: var(--fs-xs); }
.lrn-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.lrn-stat { background: var(--surface-2); border-radius: var(--radius); padding: var(--sp-2) var(--sp-3); }
.lrn-stat .k { display: block; font-size: var(--fs-xs); color: var(--text-3); }
.lrn-stat .v { display: block; font-size: var(--fs-md); font-weight: var(--fw-bold); }
.lrn-mycourse .foot .ds-chips, .lrn-mycourse .foot .lrn-acts { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.lrn-mycourse .foot .lrn-foot-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
/* category chips (JS toggles .active on .cat-btn) */
.lrn-chips .cat-btn.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.lrn-chips .cnt { opacity: .7; font-weight: var(--fw-regular); font-size: var(--fs-xs); }
/* ratings */
.lrn-rating { display: inline-flex; align-items: center; gap: 6px; appearance: none; background: none; border: 0; padding: 0;
  font: inherit; font-size: var(--fs-sm); color: var(--text); cursor: pointer; }
.lrn-rating.lrn-muted { font-size: var(--fs-xs); color: var(--text-3); }
.lrn-rating .icon { width: 14px; height: 14px; }
.lrn-stars { color: var(--warn); letter-spacing: 1px; white-space: nowrap; }
.lrn-stars-lg { font-size: var(--fs-lg); }
/* reviews modal */
.lrn-modal { position: fixed; inset: 0; z-index: var(--z-modal, 500); align-items: center; justify-content: center;
  padding: var(--sp-4); background: color-mix(in srgb, var(--bg) 72%, transparent); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.lrn-modal-card { position: relative; width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto; padding: var(--sp-6);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.lrn-modal-close { position: absolute; inset-block-start: var(--sp-3); inset-inline-end: var(--sp-3); width: 32px; padding: 0; }
.lrn-modal-title { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-1); padding-inline-end: 40px;
  font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.lrn-modal-title .icon { color: var(--warn); }
.lrn-modal-avg { margin-bottom: var(--sp-4); }
.lrn-review-form { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4); margin-bottom: var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.lrn-starpick { display: flex; gap: 6px; direction: ltr; justify-content: flex-end; }
.lrn-star { appearance: none; background: none; border: 0; padding: 0 2px; font: inherit; font-size: 1.6rem; line-height: 1; color: var(--warn); cursor: pointer; }
.lrn-review { padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.lrn-review:last-child { border-bottom: 0; }
.lrn-review .head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); }
.lrn-review-text { margin: var(--sp-2) 0 var(--sp-1); font-size: var(--fs-md); color: var(--text-2); line-height: 1.6; overflow-wrap: anywhere; }
