/* =====================================================================
   Assess Master — design system
   ===================================================================== */

:root {
  --qm-primary: #4f46e5;
  --qm-primary-dark: #3730a3;
  --qm-primary-light: #eef2ff;
  --qm-teal: #0d9488;
  --qm-amber: #d97706;
  --qm-rose: #e11d48;
  --qm-ink: #0f172a;
  --qm-slate: #475569;
  --qm-slate-light: #94a3b8;
  --qm-bg: #f6f7fb;
  --qm-card: #ffffff;
  --qm-border: #e6e8f0;
  --qm-sidebar-bg: #111827;
  --qm-sidebar-hover: #1f2937;
  --qm-radius: 14px;
  --qm-radius-sm: 10px;
  --qm-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--qm-bg);
  color: var(--qm-ink);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }
.text-primary-qm { color: var(--qm-primary) !important; }
.fw-semibold { font-weight: 600; }

/* ---------- Buttons ---------- */
.btn-qm-primary {
  background: var(--qm-primary);
  border-color: var(--qm-primary);
  color: #fff;
}
.btn-qm-primary:hover { background: var(--qm-primary-dark); border-color: var(--qm-primary-dark); color: #fff; }
.btn-qm-outline {
  border: 1px solid var(--qm-border);
  color: var(--qm-ink);
  background: #fff;
}
.btn-qm-outline:hover { background: #f8fafc; }

/* =====================================================================
   Public site (landing / auth)
   ===================================================================== */
.qm-public-nav {
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--qm-border);
  position: sticky; top: 0; z-index: 50;
}
.qm-brand {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 800; font-size: 1.15rem; color: var(--qm-ink);
}
.qm-brand .qm-logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--qm-primary), var(--qm-teal));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.05rem;
}

.qm-hero {
  background:
    radial-gradient(1100px 480px at 85% -10%, rgba(79,70,229,.14), transparent 60%),
    radial-gradient(700px 380px at 5% 0%, rgba(13,148,136,.10), transparent 55%);
  padding: 5.5rem 0 4rem;
}
.qm-hero .qm-eyebrow {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--qm-primary-light); color: var(--qm-primary-dark);
  font-weight: 600; font-size: .85rem; padding: .35rem .8rem; border-radius: 999px;
}
.qm-hero h1 { font-size: clamp(2.1rem, 4vw, 3.2rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.qm-hero .qm-tagline {
  font-size: 1.15rem; font-weight: 600; color: var(--qm-slate);
}
.qm-tagline .sep { color: var(--qm-primary); margin: 0 .35rem; }

.qm-section-title { font-weight: 800; letter-spacing: -.01em; }
.qm-section-sub { color: var(--qm-slate); }

.qm-module-card {
  background: var(--qm-card);
  border: 1px solid var(--qm-border);
  border-radius: var(--qm-radius);
  padding: 1.6rem;
  height: 100%;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.qm-module-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--qm-shadow);
  border-color: #dcdfef;
}
.qm-module-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #fff; margin-bottom: 1rem;
}
.qm-module-card h5 { font-weight: 700; margin-bottom: .4rem; }
.qm-module-card p { color: var(--qm-slate); font-size: .92rem; margin-bottom: 0; }

.qm-portal-card {
  border-radius: var(--qm-radius);
  padding: 2rem;
  color: #fff;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.qm-portal-card.admin        { background: linear-gradient(135deg, #1e293b, #0f172a); }
.qm-portal-card.teacher      { background: linear-gradient(135deg, #0d9488, #0f766e); }
.qm-portal-card.student      { background: linear-gradient(135deg, #4f46e5, #4338ca); }
.qm-portal-card.professional { background: linear-gradient(135deg, #b45309, #92400e); }
.qm-portal-card h4 { font-weight: 800; }
.qm-portal-card p { opacity: .9; flex-grow: 1; }
.qm-portal-card .btn { align-self: flex-start; margin-top: auto; }

.qm-auth-shell {
  min-height: calc(100vh - 66px);
  display: flex; align-items: center; justify-content: center;
  padding: 2.5rem 1rem;
}
.qm-auth-card {
  width: 100%; max-width: 440px;
  background: #fff; border: 1px solid var(--qm-border);
  border-radius: var(--qm-radius); box-shadow: var(--qm-shadow);
  padding: 2.2rem;
}
.qm-demo-box {
  background: var(--qm-primary-light); border-radius: var(--qm-radius-sm);
  padding: .9rem 1rem; font-size: .82rem; color: var(--qm-primary-dark);
}

footer.qm-footer {
  border-top: 1px solid var(--qm-border);
  padding: 2.2rem 0; color: var(--qm-slate-light); font-size: .88rem;
}

/* =====================================================================
   App shell (Admin / Teacher / Student dashboards)
   ===================================================================== */
.qm-app { display: flex; min-height: 100vh; }

.qm-sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--qm-sidebar-bg);
  color: #cbd5e1;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.qm-sidebar .qm-brand { color: #fff; padding: 1.35rem 1.3rem 1rem; }
.qm-sidebar-section {
  text-transform: uppercase; font-size: .68rem; letter-spacing: .08em;
  color: #64748b; padding: 1rem 1.3rem .35rem; font-weight: 700;
}
.qm-nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem 1.3rem; color: #cbd5e1; font-size: .92rem; font-weight: 500;
  border-left: 3px solid transparent;
}
.qm-nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.qm-nav-link:hover { background: var(--qm-sidebar-hover); color: #fff; }
.qm-nav-link.active {
  background: var(--qm-sidebar-hover); color: #fff;
  border-left-color: var(--qm-teal);
}
.qm-sidebar-footer { margin-top: auto; padding: 1rem 1.3rem; border-top: 1px solid #1f2937; }
.qm-nav-link.qm-signout { color: #fca5a5; } /* readable red-400 on the dark sidebar, unlike Bootstrap's light-tuned text-danger-emphasis */
.qm-nav-link.qm-signout:hover { color: #fecaca; background: rgba(248, 113, 113, .12); }
.qm-sidebar-credit { margin-top: .85rem; padding-top: .75rem; border-top: 1px solid #1f2937; font-size: .68rem; line-height: 1.6; color: #64748b; }
.qm-sidebar-credit a { color: #94a3b8; text-decoration: underline; }
.qm-sidebar-credit a:hover { color: #cbd5e1; }

/* Collapsible sidebar (desktop) — toggled via the topbar button, state
   persisted in localStorage. Only the label text hides; icons stay put so
   the collapsed rail is still a usable icon-only nav (hover for a tooltip,
   via each link's title attribute). */
.qm-sidebar { transition: width .18s ease; }
@media (min-width: 992px) {
  body.qm-sidebar-collapsed .qm-sidebar { width: 68px; }
  body.qm-sidebar-collapsed .qm-label { display: none; }
  body.qm-sidebar-collapsed .qm-brand { justify-content: center; padding: 1.35rem .5rem 1rem; }
  body.qm-sidebar-collapsed .qm-nav-link { justify-content: center; padding: .6rem 0; border-left-width: 0; }
  body.qm-sidebar-collapsed .qm-nav-link.active { border-left-width: 0; box-shadow: inset 3px 0 0 var(--qm-teal); }
  body.qm-sidebar-collapsed .qm-sidebar-section { padding: .8rem 0 .3rem; }
  body.qm-sidebar-collapsed .qm-sidebar-section::before {
    content: ''; display: block; width: 22px; height: 1px; background: #334155; margin: 0 auto;
  }
  body.qm-sidebar-collapsed .qm-sidebar-footer { padding: 1rem .5rem; }
}

.qm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.qm-topbar {
  background: #fff; border-bottom: 1px solid var(--qm-border);
  padding: .85rem 1.5rem; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.qm-content { padding: 1.6rem; flex: 1; }

.qm-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.qm-avatar-sm { width: 30px; height: 30px; font-size: .72rem; }

.qm-role-badge {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .2rem .55rem; border-radius: 999px;
}
.qm-role-badge.admin        { background: #e2e8f0; color: #1e293b; }
.qm-role-badge.teacher      { background: #ccfbf1; color: #0f766e; }
.qm-role-badge.student      { background: #e0e7ff; color: #4338ca; }
.qm-role-badge.professional { background: #fde68a; color: #92400e; }

/* ---------- Cards / stat tiles ---------- */
.qm-card {
  background: var(--qm-card); border: 1px solid var(--qm-border);
  border-radius: var(--qm-radius); box-shadow: var(--qm-shadow);
}
.qm-card-header {
  padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--qm-border);
  display: flex; align-items: center; justify-content: space-between;
}
.qm-card-body { padding: 1.4rem; }

.qm-stat {
  background: var(--qm-card); border: 1px solid var(--qm-border);
  border-radius: var(--qm-radius); padding: 1.25rem 1.4rem;
  display: flex; align-items: center; gap: 1rem;
}
.qm-stat-icon {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.2rem;
}
.qm-stat .qm-stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.qm-stat .qm-stat-label { color: var(--qm-slate); font-size: .82rem; }

.qm-progress-thin { height: 8px; border-radius: 999px; background: #eef0f6; }
.qm-progress-thin .progress-bar { border-radius: 999px; }

/* ---------- Tables ---------- */
.qm-table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--qm-slate-light); border-bottom: 1px solid var(--qm-border); font-weight: 700;
}
.qm-table td { vertical-align: middle; }
.qm-table tbody tr:hover { background: #fafbfe; }

/* ---------- Quiz taking ---------- */
.qm-quiz-shell { max-width: 820px; margin: 0 auto; }
.qm-timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem;
  background: #fff; border: 1px solid var(--qm-border); border-radius: 999px;
  padding: .4rem 1rem; display: inline-flex; align-items: center; gap: .5rem;
}
.qm-timer.low { color: var(--qm-rose); border-color: #fecdd3; background: #fff1f2; }
.qm-option {
  display: block; border: 1px solid var(--qm-border); border-radius: var(--qm-radius-sm);
  padding: .85rem 1rem; margin-bottom: .65rem; cursor: pointer; background: #fff;
  transition: border-color .12s ease, background .12s ease;
}
.qm-option:hover { border-color: #c7cbf5; background: #fbfbff; }
.qm-option input { margin-right: .7rem; }
.qm-option.selected { border-color: var(--qm-primary); background: var(--qm-primary-light); }
.qm-option.correct { border-color: #16a34a; background: #f0fdf4; }
.qm-option.incorrect { border-color: var(--qm-rose); background: #fff1f2; }

.qm-qnav-btn {
  width: 38px; height: 38px; border-radius: 8px; font-size: .82rem; font-weight: 700;
  border: 1px solid var(--qm-border); background: #fff; color: var(--qm-slate);
}
.qm-qnav-btn.answered { background: var(--qm-primary-light); border-color: #c7cbf5; color: var(--qm-primary-dark); }
.qm-qnav-btn.current { background: var(--qm-primary); border-color: var(--qm-primary); color: #fff; }
.qm-qnav-btn.current.answered { background: var(--qm-primary-dark); border-color: var(--qm-primary-dark); }

/* One-question-at-a-time quiz slides (see student/quiz_take.php + main.js) */
.qm-qslide { display: none; }
.qm-qslide.qm-active { display: block; }

/* ---------- Leaderboard ---------- */
.qm-rank {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem; background: #eef0f6; color: var(--qm-slate);
}
.qm-rank.gold   { background: #fef3c7; color: #92400e; }
.qm-rank.silver { background: #e2e8f0; color: #334155; }
.qm-rank.bronze { background: #fed7aa; color: #9a3412; }

/* ---------- Reviewer content ---------- */
.qm-reviewer-content h4 { font-weight: 700; margin-top: 1.4rem; }
.qm-reviewer-content h4:first-child { margin-top: 0; }
.qm-reviewer-content ul, .qm-reviewer-content ol { padding-left: 1.2rem; }
.qm-reviewer-content p, .qm-reviewer-content li { color: #334155; }

/* ---------- Misc ---------- */
.qm-empty { text-align: center; padding: 3rem 1.5rem; color: var(--qm-slate); }
.qm-empty i { font-size: 2.4rem; color: var(--qm-slate-light); margin-bottom: .75rem; display: block; }

@media (max-width: 991px) {
  .qm-sidebar { position: fixed; left: -260px; z-index: 1050; transition: left .2s ease; box-shadow: 20px 0 40px rgba(0,0,0,.2); }
  .qm-sidebar.open { left: 0; }
  .qm-sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1040; }
  .qm-sidebar-backdrop.open { display: block; }
}
