/* =====================================================================
   Assessment CSS — หลักสูตรผสม + ประเมินผลหลายรูปแบบ (WP-A)
   ใช้ตัวแปร tone/token ของ core (assets/css/app.css) เท่านั้น
   ===================================================================== */

/* ---------- ชิประดับผล (ชื่อระดับ + ตัวเลข) ---------- */
.acad-lv { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px 0 4px; border-radius: 10px; background: var(--tone-soft); color: var(--tone-ink); font-weight: 650; font-size: 13px; white-space: nowrap; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 20%, transparent); }
.acad-lv b { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 7px; background: var(--tone); color: #fff; font-family: var(--font-num); font-size: 12.5px; }
.acad-lv.sm { height: 24px; font-size: 12px; padding-right: 8px; }
.acad-lv.sm b { min-width: 18px; height: 18px; font-size: 11px; }
.acad-lv.lg { height: 40px; font-size: 15px; padding-right: 14px; border-radius: 13px; }
.acad-lv.lg b { min-width: 30px; height: 30px; border-radius: 9px; font-size: 16px; }

/* ---------- แบนเนอร์หลักสูตรของรายวิชา ---------- */
.lv-banner { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: var(--r-xl); background: linear-gradient(120deg, var(--tone-soft), var(--surface) 70%); border: 1px solid color-mix(in srgb, var(--tone) 22%, var(--line)); }
.lv-banner-ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--tone); color: #fff; font-size: 26px; flex-shrink: 0; box-shadow: 0 10px 22px -12px var(--tone); }
.lv-banner-text { margin-top: 6px; font-size: 13.5px; color: var(--text-2); }
.lv-banner-kpi { text-align: right; flex-shrink: 0; }
.lv-banner-kpi b { font-family: var(--font-num); font-size: 30px; font-weight: 800; color: var(--tone-ink); line-height: 1; }
.lv-banner-kpi span { font-size: 14px; color: var(--muted); margin-left: 4px; }
.lv-banner-kpi small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- คำอธิบายระดับคุณภาพ ---------- */
.lv-scale { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.lv-scale.lv-n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lv-scale.lv-n8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lv-scale-item { padding: 12px; border-radius: 14px; background: var(--tone-soft); border: 1px solid color-mix(in srgb, var(--tone) 22%, transparent); }
.lv-scale-item b { color: var(--tone-ink); font-size: 14px; }
.lv-scale-item p { margin: 6px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--text-2); }
.lv-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--tone); color: #fff; font-family: var(--font-num); font-weight: 800; font-size: 13px; }
.lv-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 4px; }
.lv-kpis > div { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.lv-kpis b { display: block; font-family: var(--font-num); font-size: 22px; font-weight: 800; line-height: 1.1; }
.lv-kpis span { font-size: 12px; color: var(--muted); }

/* ---------- รายการหัวข้อ (ผลลัพธ์/มาตรฐาน) ---------- */
.lv-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; }
.lv-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; }
.lv-item:hover { background: var(--surface-2); }
.lv-group { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 6px 10px; border-radius: 10px; background: var(--tone-soft); color: var(--tone-ink); font-weight: 700; font-size: 13px; }
.lv-code { display: inline-grid; place-items: center; min-width: 40px; height: 24px; padding: 0 7px; border-radius: 8px; background: var(--violet-soft); color: var(--violet-ink); font-family: var(--font-num); font-weight: 750; font-size: 12px; flex-shrink: 0; }
.lv-fill { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lv-fill .select { width: auto; min-width: 96px; }

/* ---------- ตารางเลือกระดับ ---------- */
.lv-wrap { max-height: calc(100vh - 200px); overflow: auto; }
.lv-table th.lv-th { min-width: 132px; max-width: 170px; }
.lv-table.is-ec th.lv-th { min-width: 104px; }
.lv-th-name { display: block; margin-top: 4px; font-size: 11px; font-weight: 500; color: var(--muted); line-height: 1.35; text-transform: none; letter-spacing: 0; }
.lv-ghead th { text-align: center; font-size: 12.5px; color: var(--tone-ink); background: var(--tone-soft) !important; border-bottom: 2px solid var(--tone); }
.lv-pick { display: inline-flex; gap: 3px; padding: 3px; border-radius: 12px; background: var(--surface-3); transition: box-shadow .2s, background .3s; }
.lv-pick button { width: 28px; height: 30px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-family: var(--font-num); font-weight: 750; font-size: 13.5px; cursor: pointer; transition: background .15s, color .15s, transform .1s; }
.lv-pick button:hover:not(:disabled) { background: var(--tone-soft); color: var(--tone-ink); }
.lv-pick button:active:not(:disabled) { transform: scale(.92); }
.lv-pick button:focus-visible { outline: none; box-shadow: var(--ring); }
.lv-pick button.on { background: var(--tone); color: #fff; box-shadow: 0 6px 14px -8px var(--tone); }
.lv-pick button:disabled { cursor: default; opacity: .75; }
.lv-pick button:disabled:not(.on) { opacity: .35; }
.lv-pick.is-saving { background: var(--amber-soft); }
.lv-pick.is-saved { background: var(--emerald-soft); }
.lv-pick.is-invalid { background: var(--rose-soft); box-shadow: 0 0 0 2px var(--rose); }
.lv-overall { display: inline-flex; align-items: center; gap: 6px; }
.lv-prog { font-family: var(--font-num); font-size: 11.5px; color: var(--muted); font-weight: 650; }
.lv-doms { display: flex; gap: 3px; justify-content: center; margin-top: 4px; }
.lv-doms span { display: inline-flex; align-items: center; gap: 2px; padding: 1px 5px; border-radius: 6px; background: var(--tone-soft); color: var(--tone-ink); font-size: 10.5px; font-weight: 700; font-family: var(--font-num); }
.lv-ev-btn { gap: 4px; }
.lv-ev-n { font-family: var(--font-num); font-weight: 700; font-size: 12px; }
.lv-table tr.is-locked td { background: var(--surface-2); }

/* ---------- หลักฐานการเรียนรู้ ---------- */
.ev-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; }
.ev-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.ev-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone-ink); font-size: 20px; flex-shrink: 0; }
.ev-kinds { width: 100%; }
.ev-kinds label { flex: 1; justify-content: center; }

/* ---------- กรอบหลักสูตร (frameworks.php) ---------- */
.fw-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.fw-card { position: relative; padding: 18px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-xs); overflow: hidden; display: flex; flex-direction: column; gap: 10px; }
.fw-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--tone); }
.fw-card.is-off { opacity: .6; }
.fw-card .fw-ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone-ink); font-size: 24px; }
.fw-card h3 { margin: 0; font-size: 15.5px; line-height: 1.4; }
.fw-card p { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.fw-card .fw-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: auto; }
.fw-card .fw-stats div { padding: 8px; border-radius: 10px; background: var(--surface-2); text-align: center; }
.fw-card .fw-stats b { display: block; font-family: var(--font-num); font-size: 18px; font-weight: 800; }
.fw-card .fw-stats span { font-size: 11px; color: var(--muted); }
.fw-map { width: 100%; }
.fw-map td .select { min-width: 210px; }
.fw-stage { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: none; }
.fw-flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.fw-flow .arrow { color: var(--muted-2); }
.fw-tbl-icon { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--tone-soft); color: var(--tone-ink); font-size: 18px; }
.fw-settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fw-settings .kv-box { padding: 12px; border-radius: 12px; background: var(--surface-2); }
.fw-settings .kv-box b { display: block; font-family: var(--font-num); font-size: 18px; }
.fw-settings .kv-box span { font-size: 12px; color: var(--muted); }

/* ---------- ประเมิน 4 มิติ (assessments.php) ---------- */
.as-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.as-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.as-kpis > div { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.as-kpis b { display: block; font-family: var(--font-num); font-size: 24px; font-weight: 800; line-height: 1.1; }
.as-kpis span { font-size: 12px; color: var(--muted); }
.as-sum { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.as-room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.as-room { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.as-room:hover { border-color: color-mix(in srgb, var(--tone) 45%, var(--line)); box-shadow: var(--sh-sm); transform: translateY(-1px); }
.as-room.active { border-color: var(--tone); box-shadow: 0 0 0 3px var(--tone-soft); }
.as-room b { font-size: 14.5px; }

/* ---------- ผลการเรียนแบบสมรรถนะ (my_grades.php) ---------- */
.cmp-list { display: flex; flex-direction: column; gap: 10px; }
.cmp-card { border-radius: 16px; border: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.cmp-card > summary { display: flex; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; list-style: none; }
.cmp-card > summary::-webkit-details-marker { display: none; }
.cmp-card[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cmp-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone-ink); font-size: 21px; flex-shrink: 0; }
.cmp-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.cmp-out { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.cmp-out .grow { line-height: 1.5; }
.cmp-narr { padding: 10px 12px; border-radius: 12px; background: var(--violet-soft); color: var(--violet-ink); font-size: 13.5px; line-height: 1.6; }
.cmp-narr i { margin-right: 4px; }
.cmp-ev { display: flex; flex-wrap: wrap; gap: 6px; }
.ec-domains { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.ec-dom { padding: 14px; border-radius: 16px; background: var(--tone-soft); border: 1px solid color-mix(in srgb, var(--tone) 22%, transparent); }
.ec-dom .ec-dom-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--tone); color: #fff; font-size: 22px; margin-bottom: 8px; }
.ec-dom b { display: block; font-size: 14px; color: var(--tone-ink); }
.ec-dom ul { margin: 8px 0 0; padding-left: 16px; font-size: 12px; line-height: 1.6; color: var(--text-2); }
.dim-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dim-box { padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }
.dim-box h4 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.dim-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }
.dim-row:last-child { border-bottom: 0; }

/* ---------- ภาพรวม: ผลสัมฤทธิ์แยกหลักสูตร ---------- */
.la-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) 64px; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.la-row:last-child { border-bottom: 0; }
.la-name { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; min-width: 0; }
.la-stack { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.la-stack span { display: block; height: 100%; }
.la-val { text-align: right; font-family: var(--font-num); font-weight: 750; }
.map-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.map-chip { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; min-width: 64px; padding: 8px 6px; border-radius: 12px; background: var(--tone-soft); color: var(--tone-ink); font-size: 12px; font-weight: 700; }
.map-chip i { font-size: 18px; }

@media screen and (max-width: 1180px) {
  .fw-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ec-domains { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media screen and (max-width: 768px) {
  .lv-banner { flex-wrap: wrap; padding: 14px; }
  .lv-banner-kpi { text-align: left; width: 100%; }
  .lv-scale, .lv-scale.lv-n3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lv-items { grid-template-columns: 1fr; }
  .lv-wrap { max-height: none; }
  .lv-table.table-stack td { align-items: center; }
  .lv-pick button { width: 40px; height: 40px; font-size: 16px; }
  .lv-ghead { display: none; }
  .fw-cards, .fw-settings, .dim-grid { grid-template-columns: 1fr; }
  .as-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .la-row { grid-template-columns: 1fr 52px; }
  .la-row .la-stack { grid-column: 1 / -1; grid-row: 2; }
  .ec-domains { grid-template-columns: 1fr 1fr; }
  .fw-map td .select { min-width: 0; width: 100%; }
}

/* ---------- พิมพ์ (Ctrl+P จากหน้าทำงาน) — ปุ่มพิมพ์เปิดตัวอย่างก่อนพิมพ์ ?print=1 (ด้านล่าง) · ไม่ตั้ง @page ในไฟล์ที่ใช้ร่วมกันหลายหน้า ---------- */
@media print {
  .lv-table thead { display: table-header-group; }
  .lv-table tr { page-break-inside: avoid; }
  .lv-wrap { max-height: none !important; overflow: visible !important; }
  .lv-pick { background: none; padding: 0; }
  .lv-pick button { display: none; }
  .lv-pick button.on { display: inline-grid; place-items: center; background: none !important; color: #000 !important; box-shadow: none; border: 1px solid #000; width: 22px; height: 20px; }
  .lv-table th.lv-th { min-width: 0; }
  .acad-lv b { background: #000; }
}

/* ---------- เอกสาร A4 (.paper WYSIWYG — หน่วย mm/pt เท่านั้น): แบบบันทึกผลการประเมิน 4 มิติ (assessments.php?print=1) และรายวิชาแบบระดับ (gradebook.php?print=1) ---------- */
.asp-fields { margin: 1.5mm 0 2mm; font-size: 10pt; }
.asp-table th.asp-it { font-size: .92em; padding-left: .3mm; padding-right: .3mm; white-space: nowrap; }
.asp-table tbody td { white-space: nowrap; }
.asp-table td.ell { text-align: left; }
.asp-key { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3mm 5mm; font-size: 8.5pt; line-height: 1.3; }
.asp-key.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.asp-key > div { display: flex; gap: 1.5mm; min-width: 0; }
.asp-key b { flex-shrink: 0; min-width: 9mm; }
.asp-grp { font-weight: 700; font-size: 9pt; margin: 1.2mm 0 .3mm; }
.asp-sheet .doc-signs { margin-top: 6mm; }
.asp-sheet .doc-head.row .doc-aff, .asp-sheet .doc-head.row .doc-right > div { text-wrap: balance; }
