/* LMS Cô Nguyễn Thị Bích Thuận — giao diện */
:root {
  --bg: #f3f7fa;
  --card: #ffffff;
  --line: #dde5eb;
  --ink: #17212b;
  --muted: #64717e;
  --teal: #1a8a8a;
  --teal-dark: #146f6f;
  --teal-soft: #e3f3f2;
  --blue: #1e78dc;
  --blue-dark: #1762b8;
  --danger: #c93a3a;
  --danger-soft: #fdeceb;
  --warn: #b7791f;
  --warn-soft: #fff6e0;
  --ok: #1f8a4c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 33, 43, .04), 0 6px 20px rgba(23, 33, 43, .05);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink);
  background: var(--bg);
}
body.modal-open { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 20px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.35; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(30, 120, 220, .45); outline-offset: 2px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
code { background: #eef3f6; padding: 1px 6px; border-radius: 6px; }
pre { background: #10202b; color: #e6f1f6; padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 6px 0; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.spacer { flex: 1 1 auto; }
.grow { flex: 1 1 200px; min-width: 0; }
.pad { padding: 16px; }

/* ---------- Thành phần chung ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f4f8fa; border-color: #c8d3db; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-primary, .btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover, .btn-teal:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-ghost { background: transparent; }
.btn-outline { background: #fff; }
.btn-soft { background: var(--teal-soft); border-color: transparent; color: var(--teal-dark); border-radius: 999px; }
.btn-soft:hover, .btn-soft.active { background: #cfeae8; border-color: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a92e2e; border-color: #a92e2e; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); border-color: #f0c4c1; }

.link-btn { background: none; border: 0; padding: 0; color: var(--teal-dark); font-weight: 600; cursor: pointer; text-decoration: none; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 16px; line-height: 1; padding: 0;
}
.icon-btn:hover { background: #f1f6f8; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field-label { font-weight: 600; font-size: 14px; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
textarea { resize: vertical; min-height: 60px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--teal); }
select { appearance: auto; }
.form-error { color: var(--danger); font-size: 14px; min-height: 0; margin-bottom: 8px; }
.form-error:empty { display: none; }
.notice-err { background: var(--danger-soft); color: #8f2626; border: 1px solid #f0c4c1; padding: 12px 14px; border-radius: 10px; margin: 8px 0; }
.notice-err ul { margin: 6px 0 0; padding-left: 20px; }

.chip { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: #eef3f6; color: #44525f; }
.chip-0 { background: #eef3f6; color: #5b6976; }
.chip-1 { background: var(--warn-soft); color: var(--warn); }
.chip-2 { background: #e2f5ea; color: var(--ok); }
.chip-score { background: var(--teal-soft); color: var(--teal-dark); }

.bar { height: 8px; background: #e6edf2; border-radius: 999px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--teal); border-radius: inherit; transition: width .3s; }

.loading { display: flex; align-items: center; gap: 10px; padding: 20px; color: var(--muted); }
.spin { width: 18px; height: 18px; border: 3px solid #d5e0e7; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toasts { position: fixed; z-index: 100; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 460px); pointer-events: none; }
.toast { pointer-events: auto; background: #14232e; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: rise .2s ease-out; }
.toast-err { background: #a92e2e; }
.toast.out { opacity: 0; transition: opacity .4s; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(16, 32, 43, .5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; }
.dialog { width: min(480px, 100%); background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.dialog-wide { width: min(880px, 100%); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 18px 20px 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.confirm-text { margin-bottom: 12px; }
.form .muted { margin-bottom: 12px; }

/* ---------- Đăng nhập ---------- */
.login-page { max-width: 1100px; margin: 0 auto; padding: 28px 16px 48px; }
.login-shell { padding: 32px 32px 36px; border-radius: 18px; box-shadow: var(--shadow); }
.login-shell h1 { font-size: clamp(26px, 5vw, 46px); line-height: 1.15; letter-spacing: -.01em; font-weight: 700; }
.lead { font-size: 18px; margin: 6px 0 24px; }
.login-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.login-card { padding: 22px; }
.login-card h2 { font-size: 22px; }
.login-card > .muted { margin: 4px 0 18px; }
.btn-block { min-height: 46px; font-size: 16px; }

/* ---------- Khung trang ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.brand { color: var(--teal); font-weight: 700; font-size: 20px; text-decoration: none; letter-spacing: .01em; white-space: nowrap; }
.course-tabs { display: flex; gap: 8px; margin-left: auto; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.course-tabs::-webkit-scrollbar { display: none; }
.course-tab {
  min-height: 44px; padding: 8px 18px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer;
  font-weight: 700; white-space: nowrap;
}
.course-tab:hover { background: #f1f6f8; }
.course-tab.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.course-tab.hidden-course { border-style: dashed; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.user-btn { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.user-name { overflow: hidden; text-overflow: ellipsis; }
.view { min-height: calc(100vh - 66px); }

.learn { display: grid; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(280px, 340px); min-height: calc(100vh - 66px); }
.col-left, .col-right { padding: 16px; background: #f8fbfc; }
.col-left { border-right: 1px solid var(--line); }
.col-right { border-left: 1px solid var(--line); }
.col-main { padding: 18px 20px 32px; min-width: 0; }

/* Cột trái */
.side-title { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.side-label { display: block; font-weight: 700; margin: 10px 0 6px; }
.chapter-card { margin: 14px 0; padding: 12px; }
.chapter-card h3 { color: var(--teal-dark); margin-bottom: 10px; }
.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson-btn { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.lesson-btn:hover { border-color: #b9ccd6; }
.lesson-btn.active { background: var(--teal-soft); border-color: #b3dcd9; }
.lesson-btn-title { display: block; font-weight: 700; line-height: 1.35; }
.lesson-btn-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.lesson-btn-meta b { color: var(--teal-dark); }
.lesson-btn-meta b.done { color: var(--ok); }
.kind-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.kind-btn { display: flex; align-items: center; gap: 6px; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 700; font-size: 16px; }
.kind-btn:hover { border-color: #b9ccd6; }
.kind-btn.active { background: var(--teal-soft); border-color: #b3dcd9; color: var(--teal-dark); }
.kind-pct { font-weight: 700; }

/* Cột giữa */
.main-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.main-head h1 { font-size: 32px; line-height: 1.15; font-weight: 700; }
.pill { display: inline-flex; padding: 8px 18px; border: 1px solid #b3dcd9; background: var(--teal-soft); color: var(--teal-dark); border-radius: 999px; font-weight: 700; white-space: nowrap; }
.scope-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: var(--warn-soft); border: 1px solid #f1dfae; color: #7a5410; padding: 8px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }
.panel { display: flex; flex-direction: column; gap: 14px; background: #eef5f8; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.lesson-card h2 { font-size: 22px; }
.lesson-card .muted { margin-top: 2px; }
.stage { padding: 0; overflow: hidden; min-height: 320px; display: grid; }
.stage.has-frame { background: #fff; }
.stage iframe { width: 100%; height: clamp(440px, 72vh, 900px); border: 0; display: block; background: #fff; }
.stage-empty { align-self: center; text-align: center; padding: 60px 24px; }
.stage-empty h3 { font-size: 18px; margin-bottom: 8px; }
.stage-empty p { color: var(--muted); max-width: 720px; margin: 0 auto; }

.actions { display: flex; flex-direction: column; gap: 10px; }
.action-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.action-row.wrap input { min-width: 220px; }
.action-title { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 10px; flex-wrap: wrap; }
.teacher-note { background: var(--warn-soft); border: 1px solid #f1dfae; border-radius: 10px; padding: 10px 14px; margin-top: 10px; }
.help { margin-top: 12px; font-size: 14px; }
.help summary { cursor: pointer; color: var(--teal-dark); font-weight: 600; }
.help p { margin: 6px 0; }
.grade-box { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 14px; }
.grade-grid { display: grid; grid-template-columns: 120px 170px minmax(0, 1fr); gap: 12px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--teal); line-height: 1.2; }
.stat-label { color: var(--muted); }

/* Cột phải */
.side-card { padding: 16px; }
.side-card > h2 { font-size: 22px; }
.side-card > .muted { margin: 2px 0 12px; }
.big-score { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 10px; }
.big-score b { font-size: 40px; color: var(--teal); line-height: 1; }
.big-score span { color: var(--muted); }
.side-sub { margin: 16px 0 8px; }
.task-list { display: flex; flex-direction: column; gap: 6px; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.task:hover { border-color: #b3dcd9; background: var(--teal-soft); }
.task-kind { font-size: 12px; font-weight: 700; color: var(--teal-dark); background: var(--teal-soft); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.task-title { font-size: 14px; line-height: 1.3; }
.grade-group { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.grade-group > h3 { color: var(--teal-dark); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.class-block { border-bottom: 1px solid var(--line); }
.class-block:last-child { border-bottom: 0; }
.class-row { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 14px; cursor: pointer; }
.class-row:hover { background: #f3f8fa; }
.class-row.active { background: var(--teal-soft); box-shadow: inset 3px 0 0 var(--teal); }
.class-name { display: block; font-weight: 700; font-size: 16px; }
.class-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.class-meta b { margin-left: auto; color: var(--teal-dark); font-size: 15px; }
.student-list { padding: 4px 8px 10px 14px; background: #fafcfd; }
.student-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; font-size: 14px; }
.student-row:hover { background: #eaf2f5; }
.student-row.active { background: var(--teal-soft); font-weight: 600; }
.student-pct { color: var(--muted); font-size: 12.5px; }
.student-row b { color: var(--teal-dark); min-width: 28px; text-align: right; }

.empty-state { max-width: 560px; margin: 60px auto; text-align: center; padding: 32px; }
.empty-state h2 { margin-bottom: 8px; }

/* ---------- Trang quản trị ---------- */
.admin { max-width: 1240px; margin: 0 auto; padding: 18px 20px 48px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 10px 18px; border: 0; border-bottom: 3px solid transparent; background: transparent; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--teal-dark); border-bottom-color: var(--teal); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-col h2 { margin-bottom: 8px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi-value { font-size: 32px; font-weight: 700; color: var(--teal); line-height: 1.15; }
.kpi-label { font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar select, .toolbar input[type=search] { width: auto; min-width: 170px; }
.export-group { display: inline-flex; gap: 6px; align-items: center; }
.export-group select { min-width: 110px; }
.card > h2 { margin-bottom: 10px; }

.chart-wrap { margin: 0; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e3eaef; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar-views { fill: var(--teal); }
.chart .bar-logins { fill: var(--blue); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 4px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw-views { background: var(--teal); }
.sw-logins { background: var(--blue); }

.table-wrap { overflow-x: auto; }
.table-wrap.tall { max-height: 420px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f8fbfc; position: sticky; top: 0; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #edf2f5; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.inactive td { opacity: .55; }
.bar-cell { min-width: 130px; }
.bar-cell .bar { margin-bottom: 3px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 4px; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid #edf2f5; }
.mini-list li:last-child { border-bottom: 0; }

.cred { background: #f1f7f8; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 16px; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.progress-table td.center { white-space: nowrap; }
.progress-table .st-2 { color: var(--ok); }
.progress-table .st-1 { color: var(--warn); }
.progress-table .st-0 { color: var(--muted); }
.chapter-row td { background: var(--teal-soft); font-weight: 700; color: var(--teal-dark); }
.log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-size: 14px; }
.log li { padding: 5px 0; border-bottom: 1px solid #edf2f5; }

.course-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; }
.chip-btn.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip-btn.add { border-style: dashed; color: var(--teal-dark); }
.edit-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.edit-row.chapter { margin-bottom: 8px; }
.edit-row.chapter h3 { color: var(--teal-dark); }
.edit-row.lesson { padding: 8px 0; border-top: 1px solid #edf2f5; }
.kind-dots { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.kdot { border: 1px solid var(--line); background: #f5f8fa; color: var(--muted); font-size: 12px; font-weight: 600; padding: 1px 10px; border-radius: 999px; cursor: pointer; }
.kdot::before { content: '○ '; }
.kdot.has { background: #e2f5ea; border-color: #b7e3c8; color: var(--ok); }
.kdot.has::before { content: '● '; }
.kdot:hover { border-color: var(--teal); }
.add-btn { margin-top: 8px; }

/* ---------- Màn hình nhỏ ---------- */
@media (max-width: 1100px) {
  .learn { grid-template-columns: minmax(230px, 280px) minmax(0, 1fr); }
  .col-right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .brand { font-size: 17px; }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand { font-size: 15px; white-space: normal; flex: 1 1 60%; }
  .top-actions { margin-left: auto; }
  .user-btn { max-width: 120px; }
  .course-tabs { order: 3; flex: 1 1 100%; margin-left: 0; }
  .course-tab { min-height: 38px; padding: 6px 14px; }
  .learn { display: flex; flex-direction: column; }
  .col-left { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .col-main { order: 1; padding: 14px 12px 20px; }
  .col-right { order: 3; }
  .main-head h1 { font-size: 24px; }
  .panel { padding: 10px; }
  .stage iframe { height: 65vh; }
  .stats { grid-template-columns: 1fr; }
  .stat { display: flex; align-items: baseline; gap: 12px; }
  .grade-grid { grid-template-columns: 1fr 1fr; }
  .grade-grid .grow { grid-column: 1 / -1; }
  .login-shell { padding: 20px 16px 24px; }
  .login-grid { grid-template-columns: 1fr; gap: 16px; }
  .two-col { grid-template-columns: 1fr; }
  .admin { padding: 12px 12px 40px; }
  .toolbar select, .toolbar input[type=search] { flex: 1 1 140px; }
  .overlay { padding: 2vh 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
