/* =====================================================================
   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: #74829a;
  --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);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
p { line-height: 1.6; }

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; }
.btn-qm-teal {
  background: #0d9488;
  border-color: #0d9488;
  color: #fff;
}
.btn-qm-teal:hover { background: #0b7c72; border-color: #0b7c72; color: #fff; }

/* =====================================================================
   Custom file chooser — replaces the bare browser <input type="file">
   with a styled "Choose File" button + filename, matching the design
   system. Markup: label.qm-file-input > input[type=file].d-none +
   span.qm-file-btn + span.qm-file-name. JS wiring lives in main.js.
   ===================================================================== */
.qm-file-input {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .4rem .5rem .4rem .4rem;
  border: 1px solid var(--qm-border);
  border-radius: var(--qm-radius-sm);
  background: #fafbfe;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.qm-file-input:hover { border-color: var(--qm-primary); background: var(--qm-primary-light); }
.qm-file-input.qm-file-has-file { border-color: var(--qm-primary); background: var(--qm-primary-light); }
.qm-file-input .qm-file-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--qm-border);
  border-radius: 8px;
  padding: .32rem .75rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--qm-ink);
}
.qm-file-input:hover .qm-file-btn { border-color: var(--qm-primary); color: var(--qm-primary); }
.qm-file-input .qm-file-name {
  font-size: .82rem;
  color: var(--qm-slate-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qm-file-input.qm-file-has-file .qm-file-name { color: var(--qm-ink); font-weight: 500; }
.qm-file-input.form-control-sm { padding: .3rem .4rem .3rem .35rem; gap: .5rem; }
.qm-file-input.form-control-sm .qm-file-btn { padding: .2rem .6rem; font-size: .75rem; }
.qm-file-input.form-control-sm .qm-file-name { font-size: .76rem; }

/* =====================================================================
   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: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--qm-primary), var(--qm-teal));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.15rem;
  overflow: hidden;
}

.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: 1.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 .qm-eyebrow-lg {
  font-size: 1.25rem; padding: .65rem 1.4rem; gap: .6rem; font-weight: 700;
  box-shadow: var(--qm-shadow);
}
.qm-hero .qm-eyebrow-lg i { font-size: 1.1rem; }
/* Announcement carousel media: if the image is smaller than the panel,
   the empty space is filled by tiling the same image as a backdrop
   instead of leaving bare background, with the real image centered
   on top at its natural (uncropped) size. */
.qm-ann-media {
  position: relative;
  width: 100%;
  height: 600px;
  background-repeat: repeat;
  background-position: center;
  background-color: #f6f7fb;
  overflow: hidden;
}
.qm-ann-media img {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  display: block;
}
.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: 4.75rem 2.2rem 2.2rem;
  position: relative;
  overflow: visible;
}
.qm-auth-logo {
  position: absolute;
  top: 0; left: 50%;
  transform: translate(-50%, -55%);
  width: 130px; height: 130px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 10px 28px -10px rgba(15, 23, 42, .3);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  color: var(--qm-primary);
  font-size: 3rem;
}
.qm-auth-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.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.principal    { background: #fce7f3; color: #9d174d; }
.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; }

/* ---------- Questionnaire taking ---------- */
.qm-questionnaire-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-question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--qm-ink);
}
.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;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--qm-ink);
}
.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 questionnaire slides (see student/questionnaire_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; font-size: 1.03rem; line-height: 1.65; }

/* ---------- Reading Practice ---------- */
.qm-reading-passage {
  font-size: 1.25rem; line-height: 2.1; color: var(--qm-ink);
}
.qm-reading-passage p { margin-bottom: 1.1rem; }
.qm-word-unit { display: inline-block; text-align: center; vertical-align: top; margin: 0 .2em .4em; }
.qm-word-emoji { display: block; font-size: 1.7em; line-height: 1.15; }
.qm-word { display: inline-block; border-radius: 5px; padding: 0 2px; transition: background-color .15s ease, color .15s ease; }
.qm-word-clickable { cursor: pointer; }
.qm-word-clickable:hover, .qm-word-clickable:focus-visible { background: var(--qm-primary-light); outline: none; }
.qm-word-speaking { box-shadow: 0 0 0 2px var(--qm-primary); }
.qm-word-correct { background: #d1fae5; color: #065f46; }
.qm-word-incorrect { background: #fee2e2; color: #991b1b; text-decoration: line-through; text-decoration-thickness: 1.5px; }
.qm-word-current { background: var(--qm-primary-light); color: var(--qm-primary-dark); box-shadow: 0 0 0 2px var(--qm-primary-light); }
#qmListeningBadge { animation: qm-pulse 1.4s ease-in-out infinite; }
@keyframes qm-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- 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; }

/* ---------- Sortable tables ---------- */
.qm-table th.qm-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.qm-table th.qm-sortable:hover { background: rgba(0, 0, 0, .035); }
.qm-table th.qm-sortable:focus-visible { outline: 2px solid var(--qm-primary); outline-offset: -2px; }
.qm-sort-indicator { margin-left: .35rem; font-size: .7rem; opacity: .3; }
.qm-table th.qm-sort-asc .qm-sort-indicator, .qm-table th.qm-sort-desc .qm-sort-indicator { opacity: 1; color: var(--qm-primary); }

/* ---------- Draggable modals ---------- */
.modal-header { cursor: move; user-select: none; }
.modal-header .btn-close { cursor: pointer; }
.modal.qm-dragging .modal-dialog { transition: none; }

@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; }
}

/* ---------- Small phones — tighten padding so content/text/tap targets
   have more room, and let the reading/question text scale down a touch. ---------- */
@media (max-width: 576px) {
  .qm-content { padding: 1rem; }
  .qm-card-body { padding: 1.1rem; }
  .qm-card-header { padding: .9rem 1.1rem; }
  .qm-topbar { padding: .7rem 1rem; }

  .qm-reading-passage { font-size: 1.1rem; line-height: 1.9; }
  .qm-question-text { font-size: 1.05rem; }
  .qm-option { padding: .75rem .9rem; font-size: .98rem; }

  #qmVoiceSelect, #qmWordDelay { max-width: none !important; flex: 1 1 140px; }

  .qm-qnav-btn { width: 34px; height: 34px; }
}
