/* Xếp thời khóa biểu (app/cong-cu/thoi-khoa-bieu.php). File này nạp ở MỌI trang → mọi lớp đều tiền tố tkb-. Chỉ dùng token của app.css. */

/* Trang rộng: bảng phân công, kết quả (ưu tiên màn 1280px) */
@media (min-width: 900px) {
  .chinh:has(.tkb-rong), .chinh:has(.tkb-kq) { max-width: 1260px; }
}
.tkb-an { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tkb-cuon { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tkb-ghi-cong { margin-top: 22px; }

/* Danh sách bộ */
.tkb-ds { display: grid; gap: 12px; margin-bottom: 18px; }
.tkb-ds__o { margin: 0; }
.tkb-ds__ten { font-size: 1.0625rem; margin: 0 0 4px; }
.tkb-ds__ten a { color: var(--chu); text-decoration: none; }
.tkb-ds__ten a:hover { color: var(--c-dam); }
.tkb-ds__tao { margin-top: 8px; }
.tkb-ds__tao .the { margin: 0; }

/* Đầu trang một bộ */
.tkb-dau { margin: 4px 0 10px; }
.tkb-dau__ve { margin: 0 0 2px; }
.tkb-dau__ve a { color: var(--phu); text-decoration: none; }
.tkb-dau__ve a:hover { color: var(--c-dam); text-decoration: underline; }
.tkb-dau__ten { margin: 0; }
.tkb-buoc { margin-bottom: 16px; }

/* Tổng quan */
.tkb-buoc-ds { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
@media (min-width: 720px) { .tkb-buoc-ds { grid-template-columns: 1fr 1fr; column-gap: 20px; } }
.tkb-buoc-ds li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; }
.tkb-buoc-ds a { font-weight: 700; color: var(--chu); text-decoration: none; }
.tkb-buoc-ds a:hover { color: var(--c-dam); text-decoration: underline; }
.tkb-buoc-ds__so { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: #eef0ed; color: var(--phu); font-weight: 800; font-size: .875rem; }
.tkb-buoc-ds__xong .tkb-buoc-ds__so { background: var(--xanh-la-nhat); color: var(--xanh-la); }
.tkb-ds-loi { margin: 6px 0 0; padding-left: 20px; }
.tkb-ds-loi li { margin-bottom: 3px; }
.tkb-tq__ghi { margin: 8px 0 0; }
.tkb-tq > form { margin-top: 6px; }

/* Thông tin chung */
.tkb-ngay { border: 0; padding: 0; margin: 0 0 14px; }
.tkb-ngay legend { font-weight: 600; font-size: .9375rem; padding: 0; margin-bottom: 8px; }
.tkb-ngay__ds { display: flex; flex-wrap: wrap; gap: 8px; }
.tkb-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; border: 1px solid var(--vien);
  border-radius: 999px; background: var(--the); cursor: pointer; font-weight: 600; }
.tkb-chip input { width: 18px; height: 18px; accent-color: var(--c); margin: 0; }
.tkb-chip:has(input:checked) { background: var(--c-nhat); border-color: var(--c-vien); color: var(--c-dam); }
.tkb-gio__tieu { margin-top: 18px; font-size: 1rem; }
.tkb-gio { display: grid; gap: 12px; }
.tkb-gio__hang { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.tkb-gio__o { display: flex; flex-direction: column; gap: 2px; font-size: .8125rem; color: var(--phu); width: 76px; }
.tkb-gio__o[hidden] { display: none; }
.tkb-gio__o input { min-height: 40px; padding: 6px 8px; border: 1px solid #cfd6d1; border-radius: var(--r-nho); font: inherit; font-size: .9375rem;
  color: var(--chu); width: 100%; font-variant-numeric: tabular-nums; }

/* Bảng nhập nhiều dòng */
.tkb-nhap { border-collapse: collapse; width: 100%; min-width: 560px; }
.tkb-nhap th { text-align: left; font-size: .8125rem; color: var(--phu); font-weight: 700; padding: 4px 6px 6px; white-space: nowrap; }
.tkb-nhap td { padding: 3px 4px; vertical-align: middle; }
.tkb-nhap input[type="text"], .tkb-nhap input[type="number"], .tkb-nhap input:not([type]), .tkb-nhap select {
  width: 100%; min-height: 40px; padding: 6px 9px; border: 1px solid #cfd6d1; border-radius: var(--r-nho); font: inherit; font-size: .9375rem;
  color: var(--chu); background: #fff; }
.tkb-nhap input:focus, .tkb-nhap select:focus { border-color: var(--c); outline: 3px solid var(--c-nhat); }
.tkb-nhap__stt { width: 34px; color: var(--phu); font-size: .8125rem; text-align: right; font-variant-numeric: tabular-nums; }
.tkb-nhap__xoa { width: 44px; text-align: center; }
.tkb-nhap__xoa input { width: 20px; height: 20px; accent-color: var(--do); }
.tkb-nhap__ngan { width: 110px; }
.tkb-nhap__so { width: 96px; }
.tkb-nhap__ten { width: 22%; }
.tkb-nhap__them { white-space: nowrap; width: 1%; }
.tkb-nhap__moi input, .tkb-nhap__moi select { background: #fbfcfb; border-style: dashed; }
.tkb-nhap__loi input, .tkb-nhap__loi select { border-color: var(--do); }
.tkb-nhap__bao td { padding-top: 0; }
.tkb-nhap tr:has(input[data-truong="xoa"]:checked) input:not([data-truong="xoa"]), .tkb-nhap tr:has(input[data-truong="xoa"]:checked) select {
  text-decoration: line-through; opacity: .55; }

/* Lịch bận */
.tkb-ban { border-collapse: collapse; min-width: 100%; }
.tkb-ban th, .tkb-ban td { border: 1px solid var(--vien); padding: 0; text-align: center; }
.tkb-ban thead th { padding: 4px; background: var(--c-nhat); }
.tkb-ban tbody th { padding: 6px 10px; text-align: left; font-size: .875rem; white-space: nowrap; }
.tkb-ban__buoi th, .tkb-ban__buoi td { background: #f3f5f2; padding: 3px; }
.tkb-ban__chon { font: inherit; font-weight: 700; font-size: .875rem; color: var(--c-dam); background: transparent; border: 0; border-radius: var(--r-nho);
  min-height: 36px; padding: 4px 8px; cursor: pointer; width: 100%; }
.tkb-ban__chon:hover { background: #fff; }
.tkb-ban__chon--nho { font-size: .75rem; font-weight: 600; min-height: 30px; color: var(--phu); }
.tkb-ban__o label { display: grid; place-items: center; min-width: 56px; min-height: 44px; cursor: pointer; }
.tkb-ban__o input { width: 20px; height: 20px; accent-color: var(--do); margin: 0; }
.tkb-ban__o:has(input:checked) { background: var(--do-nhat); }

/* Phân công */
.tkb-cuon--pc { max-height: 72vh; overflow: auto; border: 1px solid var(--vien); border-radius: var(--r); background: var(--the); }
.tkb-pc { border-collapse: separate; border-spacing: 0; font-size: .8125rem; }
.tkb-pc th, .tkb-pc td { border-right: 1px solid var(--vien); border-bottom: 1px solid var(--vien); padding: 4px; vertical-align: top; }
.tkb-pc thead th { position: sticky; top: 0; z-index: 2; background: var(--c-nhat); color: var(--c-dam); font-weight: 800; text-align: center;
  padding: 6px 4px; white-space: nowrap; }
.tkb-pc thead tr.tkb-pc__dien > * { position: sticky; top: 31px; z-index: 2; background: #f6f8fb; }
.tkb-pc__lop { position: sticky; left: 0; z-index: 1; background: var(--the); text-align: left; min-width: 70px; font-weight: 800; font-size: .875rem; }
.tkb-pc thead .tkb-pc__lop { z-index: 3; text-align: left; }
.tkb-pc tr.tkb-pc__dien th.tkb-pc__lop { font-size: .75rem; font-weight: 600; color: var(--phu); white-space: normal; }
.tkb-pc__lop .phu { display: block; font-weight: 400; font-size: .75rem; }
.tkb-pc__o { min-width: 80px; width: 80px; }
.tkb-pc__o--co { background: #f4f8fd; }
.tkb-pc__o--thieu { background: var(--nhan-nhat); }
.tkb-pc select { width: 100%; min-height: 32px; padding: 3px 4px; border: 1px solid #cfd6d1; border-radius: 6px; font: inherit; font-size: .75rem;
  color: var(--chu); background: #fff; max-width: 100%; }
.tkb-pc__so { display: flex; gap: 4px; margin-top: 4px; }
.tkb-pc__so label { flex: 1; display: flex; flex-direction: column; font-size: .6875rem; color: var(--phu); }
.tkb-pc input[type="number"] { width: 100%; min-height: 30px; padding: 2px 4px; border: 1px solid #cfd6d1; border-radius: 6px; font: inherit;
  font-size: .875rem; text-align: center; font-variant-numeric: tabular-nums; background: #fff; }
.tkb-pc input:focus, .tkb-pc select:focus { border-color: var(--c); outline: 2px solid var(--c-nhat); }
.tkb-pc__dien-o { display: flex; gap: 3px; align-items: center; }
.tkb-pc__dien-o input { max-width: 36px; }
.tkb-pc__dien-o .nut { min-height: 30px; padding: 2px 6px; font-size: .75rem; }
.tkb-pc__tong { text-align: center; white-space: nowrap; font-size: .875rem; font-variant-numeric: tabular-nums; vertical-align: middle !important; min-width: 56px; }
.tkb-pc__tong--vuot { background: var(--do-nhat); color: var(--do); }
.tkb-pc-gv { margin-top: 16px; }
.tkb-pc-gv__ds { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tkb-pc-gv__ds li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--vien); font-size: .9375rem; }
.tkb-pc-gv__ds b { font-variant-numeric: tabular-nums; color: var(--c-dam); }

/* Ràng buộc */
.tkb-rb-so { margin-top: 14px; }
.tkb-ds-ban { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tkb-ds-ban li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--vien); }

/* Lượt xếp */
.tkb-lan__cho { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0; font-weight: 700; }
.tkb-lan__cho .phu { font-weight: 400; flex-basis: 100%; }
.tkb-quay { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--c-nhat); border-top-color: var(--c); animation: tkb-quay 1s linear infinite; }
@keyframes tkb-quay { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tkb-quay { animation: none; } }
.tkb-ly-do { margin-top: 8px; font-size: .9375rem; }
.tkb-ly-do p { margin: 0 0 .6em; }
.tkb-kq__thanh { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.tkb-kq__thanh .tab-loc { margin: 0; }
.tkb-kq__ds { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tkb-kq__ds a { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--vien); background: var(--the); color: var(--chu); text-decoration: none;
  font-size: .8125rem; font-weight: 600; }
.tkb-kq__ds a[aria-current="page"] { background: var(--c-dam); border-color: var(--c-dam); color: #fff; }
.tkb-chon { display: none; }
.tkb-mot h2 { margin-bottom: 10px; }

/* Bảng thời khóa biểu một lớp / giáo viên */
.tkb-bang { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .875rem; background: #fff; }
.tkb-bang th, .tkb-bang td { border: 1px solid #cdd5dd; padding: 5px 6px; vertical-align: middle; }
.tkb-bang thead th { background: var(--c-dam); color: #fff; font-weight: 700; text-align: center; }
.tkb-bang__tiet { width: 78px; text-align: left; font-weight: 700; white-space: nowrap; background: #f6f8fb; }
.tkb-bang__tiet span { display: block; font-weight: 400; font-size: .75rem; color: var(--phu); }
.tkb-bang thead .tkb-bang__tiet { background: var(--c-dam); }
.tkb-bang__buoi th { background: var(--c-nhat); color: var(--c-dam); text-align: left; font-size: .8125rem; padding: 3px 8px; letter-spacing: .02em; }
.tkb-bang td { text-align: center; height: 46px; }
.tkb-bang__co { background: #fff; }
.tkb-bang__trung { background: var(--do-nhat); }
.tkb-bang__hd + .tkb-bang__hd { border-top: 1px dashed #cdd5dd; margin-top: 3px; padding-top: 3px; }
.tkb-bang__hd b { display: block; color: var(--chu); line-height: 1.25; }
.tkb-bang__phu { display: block; font-size: .75rem; color: var(--phu); line-height: 1.25; }
.tkb-ngan { display: none; }
.tkb-bang__phong { display: inline-block; font-size: .6875rem; color: var(--nhan-dam); background: var(--nhan-nhat); border-radius: 4px; padding: 0 4px; margin-top: 2px; }

/* Bảng toàn trường */
.tkb-cuon--truong { border: 1px solid var(--vien); border-radius: var(--r); background: var(--the); max-height: 75vh; overflow: auto; }
.tkb-truong { border-collapse: separate; border-spacing: 0; font-size: .75rem; }
.tkb-truong th, .tkb-truong td { border-right: 1px solid #e3e8ee; border-bottom: 1px solid #e3e8ee; padding: 3px 4px; text-align: center; white-space: nowrap; min-width: 34px; }
.tkb-truong thead th { position: sticky; top: 0; background: var(--c-nhat); color: var(--c-dam); z-index: 2; }
.tkb-truong thead tr + tr th { top: 24px; font-weight: 600; color: var(--phu); background: #f6f8fb; }
.tkb-truong__ngay { font-size: .8125rem; }
.tkb-truong .tkb-truong__dau { border-left: 2px solid var(--c-vien); }
.tkb-truong__lop { position: sticky; left: 0; z-index: 1; background: var(--the); font-weight: 800; text-align: left !important; min-width: 56px; }
.tkb-truong thead .tkb-truong__lop { z-index: 3; }
.tkb-truong__lop a { color: var(--c-dam); text-decoration: none; }
.tkb-truong tbody tr:hover td { background: #f6f8fb; }

/* Tệp nạp ngoài */
.tkb-tep-xep .field { max-width: 260px; margin-bottom: 12px; }

/* Điện thoại */
@media (max-width: 720px) {
  .tkb-chon { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 600; font-size: .9375rem; }
  .tkb-chon select { min-height: 46px; padding: 8px 10px; border: 1px solid #cfd6d1; border-radius: var(--r-nho); font: inherit; background: #fff; }
  .tkb-kq__ds { display: none; }
  .tkb-mot { padding: 10px; }
  .tkb-bang { font-size: .75rem; min-width: 340px; }
  .tkb-bang th, .tkb-bang td { padding: 3px 2px; }
  .tkb-bang td { height: 40px; }
  .tkb-bang__tiet { width: 44px; font-size: .6875rem; white-space: normal; }
  .tkb-bang__phu { font-size: .625rem; }
  .tkb-bang__hd b { font-size: .75rem; overflow-wrap: anywhere; }
  .tkb-bang .tkb-dai { display: none; }
  .tkb-bang .tkb-ngan { display: inline; }
}
@media print { .tkb-bang .tkb-dai { display: inline !important; } .tkb-bang .tkb-ngan { display: none !important; } }

/* In: mỗi lớp / giáo viên một trang A4 ngang */
@page tkb { size: A4 landscape; margin: 10mm; }
.tkb-trang { margin: 0 0 28px; }
.tkb-trang__dau { text-align: center; margin-bottom: 10px; }
.tkb-trang__dau h1 { font-size: 1.35rem; margin: 0; text-transform: uppercase; letter-spacing: .02em; }
.tkb-trang__truong { margin: 0; font-weight: 700; }
.tkb-trang__nam { margin: 2px 0 0; }
.tkb-in .tkb-khong-in { margin-bottom: 14px; }
@media print {
  body:has(.tkb-in) { background: #fff; }
  body:has(.tkb-in) .dau, body:has(.tkb-in) .chan, body:has(.tkb-in) .demo-bar, body:has(.tkb-in) .bao, body:has(.tkb-in) .skip, .tkb-khong-in { display: none !important; }
  body:has(.tkb-in) .chinh { max-width: none; padding: 0; }
  .tkb-trang { page: tkb; break-after: page; margin: 0; }
  .tkb-trang:last-child { break-after: auto; }
  .tkb-bang { font-size: 10.5pt; }
  .tkb-bang td { height: 13mm; }
  .tkb-bang thead th { background: #e8edf3 !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tkb-bang__tiet, .tkb-bang__buoi th { background: #f3f5f8 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tkb-bang th, .tkb-bang td { border-color: #555; }
}
