/* JVL E-Learning — theme: white / blue / gold / MOPH green / DMH orange */
:root {
  --blue: #0b3d91; --blue-600: #1652b8; --blue-50: #eef4ff; --blue-100: #dbe7ff;
  --gold: #c9a227; --gold-50: #fbf6e6;
  --green: #12805c; --green-50: #e7f6ef;
  --orange: #f08a00; --orange-50: #fff3e2;
  --red: #c53030; --red-50: #fdecec;
  --ink: #1a2433; --ink-2: #4a5568; --ink-3: #8592a6;
  --line: #e3e8f0; --bg: #f5f7fb; --card: #fff;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(11,61,145,.06);
  --font: 'Sarabun', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.3; font-weight: 700; }
h1 { font-size: 26px; } h2 { font-size: 21px; } h3 { font-size: 17px; }
[v-cloak] { display: none; }
img { max-width: 100%; }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); height: 62px; display: flex; align-items: center; padding: 0 20px; gap: 20px; }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: linear-gradient(90deg, var(--blue) 0 55%, var(--gold) 55% 75%, var(--green) 75% 90%, var(--orange) 90%); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--blue); font-size: 17px; white-space: nowrap; cursor: pointer; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--blue), var(--blue-600)); color: #fff; display: grid; place-items: center; font-size: 15px; letter-spacing: .5px; box-shadow: inset 0 -3px 0 var(--gold); }
.brand small { display: block; font-weight: 400; color: var(--ink-3); font-size: 11.5px; margin-top: -2px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { padding: 8px 14px; border-radius: 10px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--blue-50); text-decoration: none; color: var(--blue); }
.nav a.active { background: var(--blue-50); color: var(--blue); }
.userchip { display: flex; align-items: center; gap: 10px; cursor: pointer; position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold-50); color: var(--gold); display: grid; place-items: center; font-weight: 700; border: 1px solid #ecdca8; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.dropdown { position: absolute; right: 0; top: 46px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.1); min-width: 220px; padding: 6px; z-index: 50; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--bg); text-decoration: none; }

.shell { display: flex; min-height: calc(100vh - 62px); }
.sidebar { width: 236px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); padding: 16px 10px; position: sticky; top: 62px; height: calc(100vh - 62px); overflow-y: auto; }
.sidebar h6 { margin: 14px 12px 6px; font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; }
.sidebar a:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: var(--blue-50); color: var(--blue); }
.sidebar .ico { width: 20px; text-align: center; }
.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.container { max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--ink-2); }

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .course-grid > .card + .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-3); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .mt0 { margin-top: 0; }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: #c8d2e2; background: var(--bg); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); border-color: var(--blue-600); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #0e6b4c; }
.btn-danger { color: var(--red); border-color: #f3c4c4; }
.btn-danger:hover { background: var(--red-50); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: 4px 7px; border-radius: 6px; color: var(--ink-2); font-size: 15px; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field .hint { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.input, select.input, textarea.input { width: 100%; padding: 9px 12px; border: 1px solid #cfd8e6; border-radius: 10px; font: inherit; color: var(--ink); background: #fff; transition: .15s; }
.input:focus { outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 3px var(--blue-100); }
textarea.input { min-height: 90px; resize: vertical; }
.input-sm { padding: 5px 8px; font-size: 13px; border-radius: 7px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--blue); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.b-blue { background: var(--blue-50); color: var(--blue); } .b-gold { background: var(--gold-50); color: #9a7a12; }
.b-green { background: var(--green-50); color: var(--green); } .b-orange { background: var(--orange-50); color: #b56500; }
.b-red { background: var(--red-50); color: var(--red); } .b-gray { background: #eef1f5; color: var(--ink-2); }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.tbl tr:hover td { background: #fbfcfe; }
.tbl tr:last-child td { border-bottom: 0; }

.progress { height: 8px; background: #e8edf5; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--blue-600), var(--green)); border-radius: 99px; transition: width .4s; }

.stat { padding: 18px 20px; }
.stat .label { color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 700; color: var(--ink); margin-top: 4px; line-height: 1.1; }
.stat .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.stat.accent-blue { border-top: 3px solid var(--blue); } .stat.accent-gold { border-top: 3px solid var(--gold); }
.stat.accent-green { border-top: 3px solid var(--green); } .stat.accent-orange { border-top: 3px solid var(--orange); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 16px; font: inherit; font-weight: 600; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty .big { font-size: 40px; margin-bottom: 6px; }
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert-err { background: var(--red-50); color: var(--red); }
.alert-ok { background: var(--green-50); color: var(--green); }
.alert-info { background: var(--blue-50); color: var(--blue); }
.alert-warn { background: var(--orange-50); color: #a35c00; }

/* toast */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; font-size: 14px; animation: slidein .2s; }
.toast.err { background: var(--red); } .toast.ok { background: var(--green); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: min(640px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(980px, 100%); } .modal.xwide { width: min(1240px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: #fafbfd; border-radius: 0 0 16px 16px; }

/* ---------- auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(150deg, #072a66 0%, var(--blue) 55%, #134fa8 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-hero::before { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 60px solid rgba(201,162,39,.16); right: -180px; bottom: -200px; }
.auth-hero::after { content: ''; position: absolute; width: 220px; height: 220px; border-radius: 50%; background: rgba(18,128,92,.25); right: 90px; top: -80px; }
.auth-hero h1 { font-size: 36px; margin-top: 30px; position: relative; z-index: 1; }
.auth-hero p { opacity: .85; font-size: 17px; max-width: 460px; position: relative; z-index: 1; }
.auth-hero .feat { display: grid; gap: 12px; margin-top: 28px; position: relative; z-index: 1; }
.auth-hero .feat div { display: flex; gap: 12px; align-items: center; opacity: .95; }
.auth-hero .feat span { width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.auth-side { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: #fff; }
.auth-box { width: min(400px, 100%); }
.auth-box h2 { font-size: 24px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg button { border: 0; background: none; padding: 9px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button.active { background: #fff; color: var(--blue); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- course cards ---------- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.ccard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: .18s; cursor: pointer; box-shadow: var(--shadow); }
.ccard:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(11,61,145,.12); }
.ccard .cover { aspect-ratio: 16/9; background: linear-gradient(135deg, var(--blue-50), #fff 60%, var(--gold-50)); position: relative; display: grid; place-items: center; color: var(--blue); font-size: 40px; }
.ccard .cover img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.ccard .cover .badge { position: absolute; top: 10px; left: 10px; }
.ccard .body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.ccard .title { font-weight: 700; font-size: 16px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ccard .meta { display: flex; gap: 12px; color: var(--ink-3); font-size: 13px; flex-wrap: wrap; margin-top: auto; }

/* ---------- player ---------- */
.player { display: grid; grid-template-columns: 330px 1fr; min-height: calc(100vh - 62px); }
.player-side { background: #fff; border-right: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 62px); position: sticky; top: 62px; }
.player-side .head { padding: 18px; border-bottom: 1px solid var(--line); }
.mod-title { padding: 12px 18px 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); background: #fafbfd; border-bottom: 1px solid #eef1f6; }
.lesson-item { display: flex; gap: 10px; align-items: flex-start; padding: 11px 18px; border-bottom: 1px solid #f1f3f8; cursor: pointer; font-size: 14px; }
.lesson-item:hover { background: var(--bg); }
.lesson-item.active { background: var(--blue-50); box-shadow: inset 3px 0 0 var(--blue); }
.lesson-item.locked { opacity: .5; cursor: not-allowed; }
.lesson-item .st { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #cdd5e1; flex-shrink: 0; display: grid; place-items: center; font-size: 12px; margin-top: 1px; }
.lesson-item.done .st { background: var(--green); border-color: var(--green); color: #fff; }
.player-main { padding: 26px 34px 60px; min-width: 0; }
.video-box { background: #000; border-radius: 14px; overflow: hidden; aspect-ratio: 16/9; position: relative; }
.video-box video, .video-box iframe, .video-box > div { width: 100%; height: 100%; border: 0; display: block; }
.pdf-box { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.lesson-content { font-size: 16px; line-height: 1.8; }
.lesson-content img { border-radius: 10px; }
.lesson-content table { border-collapse: collapse; } .lesson-content td, .lesson-content th { border: 1px solid var(--line); padding: 6px 10px; }
.lesson-content iframe { max-width: 100%; }

/* quiz */
.q-card { border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 14px; background: #fff; }
.q-card .qno { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.q-card .qtext { font-weight: 600; font-size: 16px; margin: 4px 0 12px; white-space: pre-wrap; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; transition: .12s; }
.opt:hover { border-color: #b8c6dc; background: #fafcff; }
.opt.sel { border-color: var(--blue-600); background: var(--blue-50); }
.opt.right { border-color: var(--green); background: var(--green-50); }
.opt.wrong { border-color: var(--red); background: var(--red-50); }
.opt input { margin-top: 4px; accent-color: var(--blue); }
.timer { position: sticky; top: 74px; z-index: 5; display: inline-flex; gap: 6px; align-items: center; background: var(--ink); color: #fff; padding: 6px 14px; border-radius: 99px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.low { background: var(--red); }
.result-ring { width: 130px; height: 130px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 10px; font-size: 30px; font-weight: 800; }

/* builder */
.mod-block { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; background: #fff; }
.mod-block > .mh { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: #fafbfd; border-bottom: 1px solid var(--line); border-radius: 12px 12px 0 0; }
.lrow { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #f0f2f7; }
.lrow:last-child { border-bottom: 0; }
.ltype { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; background: var(--bg); flex-shrink: 0; }
.rte-bar { display: flex; gap: 2px; flex-wrap: wrap; padding: 6px; border: 1px solid #cfd8e6; border-bottom: 0; border-radius: 10px 10px 0 0; background: #fafbfd; }
.rte-bar button { border: 0; background: none; padding: 5px 9px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.rte-bar button:hover { background: #e9eef6; }
.rte { min-height: 220px; max-height: 480px; overflow-y: auto; border: 1px solid #cfd8e6; border-radius: 0 0 10px 10px; padding: 12px 14px; background: #fff; }
.rte:focus { outline: none; border-color: var(--blue-600); }
.qb-q { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fff; }
.qb-opt { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }

/* certificate */
.cert-stage { background: #e9edf3; border-radius: 12px; padding: 16px; display: flex; justify-content: center; }
.cert-stage canvas { max-width: 100%; height: auto; box-shadow: 0 6px 24px rgba(0,0,0,.15); background: #fff; }
.designer { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.designer canvas { cursor: move; }
.el-list { max-height: 70vh; overflow-y: auto; }
.el-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.el-item.sel { border-color: var(--blue-600); background: var(--blue-50); }
.el-item .grid { gap: 6px; }

.verify-card { max-width: 900px; margin: 30px auto; }
.seal { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 12px; font-weight: 700; font-size: 17px; }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 10px; }
.bar-chart .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-chart .b div { width: 100%; max-width: 38px; background: linear-gradient(180deg, var(--blue-600), var(--blue)); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bar-chart .b span { font-size: 11.5px; color: var(--ink-3); }
.bar-chart .b em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--ink-2); }

.perm-matrix td, .perm-matrix th { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font-family: ui-monospace, monospace; background: var(--bg); padding: 14px; border-radius: 10px; }
.loading { display: flex; justify-content: center; padding: 50px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--blue-100); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.mobile-toggle { display: none; }
@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr 1fr; }
  .designer { grid-template-columns: 1fr; }
  .player { grid-template-columns: 1fr; } .player-side { position: static; max-height: none; }
  .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; }
}
@media (max-width: 760px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; top: 62px; z-index: 40; transition: .2s; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
  .sidebar.open { left: 0; }
  .mobile-toggle { display: inline-flex; }
  .main { padding: 18px 14px 50px; } .player-main { padding: 18px 14px; }
  .nav { display: none; } .brand small { display: none; }
}
@media print { .topbar, .sidebar, .no-print { display: none !important; } .main { padding: 0; } }
