/* ============ DigiMind UI ============ */
:root {
  --dm-primary: #2563eb;
  --dm-primary-soft: #eff6ff;
  --dm-accent: #f59e0b;
  --dm-bg: #f5f7fb;
  --dm-surface: #ffffff;
  --dm-text: #1e293b;
  --dm-muted: #64748b;
  --dm-border: #e2e8f0;
  --dm-sidebar: #0f172a;
  --dm-sidebar-text: #cbd5e1;
  --dm-radius: 14px;
  --bs-primary: var(--dm-primary);
  --bs-link-color: var(--dm-primary);
}
/* Role themes: the same layout re-colours itself for each role */
body.role-admin   { --dm-primary: #7c3aed; --dm-primary-soft: #f5f3ff; --dm-sidebar: #1e1b4b; }
body.role-teacher { --dm-primary: #0d9488; --dm-primary-soft: #f0fdfa; --dm-sidebar: #042f2e; }
body.role-student { --dm-primary: #2563eb; --dm-primary-soft: #eff6ff; --dm-sidebar: #0f172a; }

html, body { font-family: "Hind Siliguri", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; }
body { background: var(--dm-bg); color: var(--dm-text); }
a { color: var(--dm-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.btn-primary { --bs-btn-bg: var(--dm-primary); --bs-btn-border-color: var(--dm-primary);
  --bs-btn-hover-bg: color-mix(in srgb, var(--dm-primary) 85%, black); --bs-btn-hover-border-color: color-mix(in srgb, var(--dm-primary) 85%, black);
  --bs-btn-active-bg: color-mix(in srgb, var(--dm-primary) 75%, black); }
.btn-outline-primary { --bs-btn-color: var(--dm-primary); --bs-btn-border-color: var(--dm-primary);
  --bs-btn-hover-bg: var(--dm-primary); --bs-btn-hover-border-color: var(--dm-primary); --bs-btn-active-bg: var(--dm-primary); }
.text-primary { color: var(--dm-primary) !important; }
.bg-primary-soft { background: var(--dm-primary-soft) !important; }
.text-muted-2 { color: var(--dm-muted); }
.form-control:focus, .form-select:focus { border-color: var(--dm-primary); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--dm-primary) 20%, transparent); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { width: 260px; background: var(--dm-sidebar) !important; color: var(--dm-sidebar-text); flex-shrink: 0; }
/* Bootstrap's .offcanvas-lg makes the background transparent on desktop; keep our dark sidebar and pin it */
@media (min-width: 992px) {
  .app-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.app-sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: #fff; font-weight: 700; font-size: 1.25rem; }
.app-sidebar .brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--dm-primary); display: grid; place-items: center; color: #fff; }
.app-sidebar .role-chip { margin: 0 1.25rem 1rem; font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; padding: .25rem .6rem; border-radius: 999px; background: rgba(255,255,255,.1); display: inline-block; }
.side-nav { list-style: none; padding: 0 .75rem 1rem; margin: 0; }
.side-nav .section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 1rem .75rem .4rem; }
.side-nav a { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: 10px; color: var(--dm-sidebar-text); font-weight: 500; }
.side-nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side-nav a.active { background: var(--dm-primary); color: #fff; }
.side-nav a .bi { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.side-nav .badge { margin-left: auto; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 1020; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--dm-border); padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem; }
.app-content { padding: 1.5rem; flex: 1; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--dm-primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; }
.points-pill { background: #fef3c7; color: #92400e; border-radius: 999px; padding: .25rem .7rem; font-weight: 600; font-size: .85rem; }

@media (max-width: 991.98px) {
  .app-sidebar.offcanvas-lg { width: 280px; }
  .app-content { padding: 1rem .9rem 5.5rem; }
}
/* Mobile bottom navigation (students) */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; background: #fff; border-top: 1px solid var(--dm-border);
  display: flex; justify-content: space-around; padding: .35rem 0 calc(.35rem + env(safe-area-inset-bottom)); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; font-size: .7rem; color: var(--dm-muted); padding: .2rem .5rem; }
.bottom-nav a .bi { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--dm-primary); }
.bottom-nav a:hover { text-decoration: none; }

/* ---------- Cards & widgets ---------- */
.card { border: 1px solid var(--dm-border); border-radius: var(--dm-radius); box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--dm-border); font-weight: 600; }
.stat-card { padding: 1.1rem 1.2rem; display: flex; align-items: center; gap: 1rem; }
.stat-card .icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; background: var(--dm-primary-soft); color: var(--dm-primary); flex-shrink: 0; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-card .label { color: var(--dm-muted); font-size: .85rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.course-card { transition: transform .15s, box-shadow .15s; height: 100%; }
.course-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15,23,42,.08); }
.course-card .cover { height: 92px; border-radius: var(--dm-radius) var(--dm-radius) 0 0; display: flex; align-items: center; padding: 0 1.2rem; color: #fff; font-size: 2rem; }
.progress { height: 8px; border-radius: 99px; }
.progress-bar { background: var(--dm-primary); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--dm-muted); }
.empty-state .bi { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .6; }
.table > :not(caption) > * > * { padding: .7rem .75rem; }
.table-card { overflow-x: auto; }

/* ---------- Lesson reader ---------- */
.lesson-body { font-size: 1.08rem; line-height: 1.85; }
.lesson-body h3 { font-size: 1.2rem; font-weight: 700; margin-top: 1.5rem; }
.lesson-body pre { background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: 10px; overflow-x: auto; font-size: .9rem; line-height: 1.5; }
.lesson-body code { font-size: .92em; }
.lesson-body table { width: 100%; margin: 1rem 0; border-collapse: collapse; }
.lesson-body th, .lesson-body td { border: 1px solid var(--dm-border); padding: .5rem .7rem; }
.lesson-body img { max-width: 100%; height: auto; border-radius: 10px; }
.lesson-body .callout { background: var(--dm-primary-soft); border-left: 4px solid var(--dm-primary); padding: .8rem 1rem; border-radius: 8px; margin: 1rem 0; }
.chapter-list .lesson-link { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: 8px; color: var(--dm-text); }
.chapter-list .lesson-link:hover { background: var(--dm-primary-soft); text-decoration: none; }
.chapter-list .lesson-link.current { background: var(--dm-primary-soft); font-weight: 600; color: var(--dm-primary); }
.ratio iframe { border-radius: 12px; }
.note-text { white-space: pre-wrap; word-break: break-word; line-height: 1.75; }

/* ---------- Exams ---------- */
.q-card .opt { display: flex; align-items: center; gap: .75rem; border: 1px solid var(--dm-border); border-radius: 10px; padding: .7rem .9rem; margin-bottom: .5rem; cursor: pointer; }
.q-card .opt:hover { background: var(--dm-primary-soft); }
.q-card input[type=radio] { display: none; }
.q-card input[type=radio]:checked + .opt { border-color: var(--dm-primary); background: var(--dm-primary-soft); }
.q-card .opt .key { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--dm-border); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.q-card input[type=radio]:checked + .opt .key { background: var(--dm-primary); color: #fff; border-color: var(--dm-primary); }
.opt.correct { border-color: #16a34a !important; background: #f0fdf4 !important; }
.opt.wrong { border-color: #dc2626 !important; background: #fef2f2 !important; }
.exam-timer { position: sticky; top: 64px; z-index: 5; }
.timer-box { font-variant-numeric: tabular-nums; font-size: 1.3rem; font-weight: 700; }
.timer-box.danger { color: #dc2626; }
.score-ring { width: 140px; height: 140px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto;
  background: conic-gradient(var(--dm-primary) calc(var(--p) * 1%), #e2e8f0 0); }
.score-ring > div { width: 112px; height: 112px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 1.8rem; font-weight: 700; }

/* ---------- Public site ---------- */
.public-nav { background: #fff; border-bottom: 1px solid var(--dm-border); }
.hero { background: radial-gradient(1200px 400px at 10% -10%, #dbeafe, transparent), radial-gradient(900px 400px at 90% 0%, #fef3c7, transparent), #fff; padding: 4.5rem 0 3.5rem; }
.hero h1 { font-weight: 800; font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.2; }
.hero .lead { font-size: 1.2rem; color: var(--dm-muted); }
.feature { padding: 1.5rem; height: 100%; }
.feature .icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; background: var(--dm-primary-soft); color: var(--dm-primary); margin-bottom: 1rem; }
.auth-wrap { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 460px; }
.auth-card.wide { max-width: 640px; }
footer.site-footer { background: #0f172a; color: #94a3b8; padding: 2rem 0; }
footer.site-footer a { color: #cbd5e1; }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; background: var(--dm-primary); color: #fff; display: inline-grid; place-items: center; }
