/* PPCT – giao diện chung
   Bảng màu lấy từ đồ dùng lớp học: mực bút bi, bảng xanh, giấy kẻ ngang, bút đỏ chấm bài. */

:root {
  --muc: #123b6d;
  --muc-dam: #0c2a4e;
  --muc-sang: #1e5fa8;
  --bang: #0e6e5c;
  --giay: #f6f8fb;
  --ke: #d7e3f1;
  --but-do: #c7402f;
  --vang: #e9a93c;
  --than: #1b2430;
  --xam: #62718a;
  --trang: #ffffff;
  --radius: 14px;
  --shadow: 0 18px 40px -24px rgba(12, 42, 78, 0.55);
  --font: "Be Vietnam Pro", "Segoe UI", Roboto, system-ui, sans-serif;
  --serif: "Lora", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--than);
  background: var(--giay);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--muc-sang); }

button, input, select, textarea { font-family: inherit; font-size: 1rem; }

button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--vang);
  outline-offset: 2px;
}

/* ---------- Trang chính ---------- */

.trang-chinh {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 40fr 60fr;
}

.khu-tren {
  position: relative;
  background:
    repeating-linear-gradient(to bottom, transparent 0 37px, rgba(255, 255, 255, 0.09) 37px 38px),
    linear-gradient(160deg, var(--muc) 0%, var(--muc-dam) 62%, #071c35 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 28px clamp(18px, 5vw, 64px);
  overflow: hidden;
}
.khu-tren::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 clamp(14px, 4vw, 52px);
  width: 2px;
  background: rgba(233, 169, 60, 0.5);
}

.khu-tren__noi-dung {
  position: relative;
  width: min(1080px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(300px, 380px);
  gap: clamp(20px, 4vw, 56px);
  align-items: center;
}

.hieu {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.15;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.hieu span { display: block; font-size: 0.52em; font-weight: 500; color: #a9c8ea; margin-top: 10px; letter-spacing: 0.02em; }

.mo-ta { margin: 0; max-width: 46ch; color: #cfe0f2; line-height: 1.6; }

.the-dang-nhap {
  background: rgba(255, 255, 255, 0.97);
  color: var(--than);
  border-radius: var(--radius);
  padding: 20px 20px 22px;
  box-shadow: var(--shadow);
  border-top: 5px solid var(--vang);
}
.the-dang-nhap h2 { margin: 0 0 14px; font-size: 1.05rem; color: var(--muc); }

.nhom { margin-bottom: 12px; }
.nhom label { display: block; font-size: 0.86rem; color: var(--xam); margin-bottom: 5px; }
.nhom input, .nhom select, .o-nhap {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--ke);
  border-radius: 10px;
  background: #fff;
  color: var(--than);
}
.nhom input:focus, .nhom select:focus { border-color: var(--muc-sang); outline: none; }

.nut {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--muc);
  color: #fff;
  font-weight: 600;
  transition: background 0.15s ease;
}
.nut:hover { background: var(--muc-sang); }
.nut:disabled { opacity: 0.6; cursor: not-allowed; }
.nut--phu { background: transparent; color: var(--muc); border: 1.5px solid var(--ke); }
.nut--phu:hover { background: #eef3f9; }
.nut--do { background: var(--but-do); }
.nut--do:hover { background: #a8331f; }
.nut--nho { width: auto; padding: 7px 12px; font-size: 0.85rem; border-radius: 8px; }

.loi {
  display: none;
  margin: 12px 0 0;
  padding: 11px 13px;
  border-left: 4px solid var(--but-do);
  background: #fdf0ee;
  color: #8e2e20;
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
  line-height: 1.5;
}
.loi.hien { display: block; }

.khu-duoi {
  position: relative;
  background: #dbe6f2 center/cover no-repeat;
  border-top: 4px solid var(--vang);
}
.khu-duoi::after {
  content: attr(data-trong);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #7d93ad;
  font-size: 0.95rem;
}
.khu-duoi.co-anh::after { content: none; }

.nut-quan-tri {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  background: rgba(18, 59, 109, 0.92);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.86rem;
  font-weight: 500;
  backdrop-filter: blur(6px);
}
.nut-quan-tri:hover { background: var(--muc-sang); }

/* ---------- Hộp thoại ---------- */

.lop-phu {
  position: fixed;
  inset: 0;
  background: rgba(9, 25, 43, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 60;
}
.lop-phu.hien { display: flex; }
.hop-thoai {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  width: min(420px, 100%);
  box-shadow: var(--shadow);
}
.hop-thoai h2 { margin: 0 0 16px; font-size: 1.1rem; color: var(--muc); }
.hop-thoai .hang-nut { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- Khung ứng dụng (sau đăng nhập / quản trị) ---------- */

.thanh-tren {
  background: var(--muc);
  color: #fff;
  padding: 14px clamp(14px, 4vw, 36px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.thanh-tren strong { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; }
.thanh-tren .ai { color: #b9d2ec; font-size: 0.88rem; }
.thanh-tren .hang-nut { display: flex; gap: 8px; align-items: center; }
.thanh-tren .nut { width: auto; padding: 8px 14px; background: rgba(255,255,255,0.14); font-size: 0.9rem; }
.thanh-tren .nut:hover { background: rgba(255,255,255,0.26); }

.than-trang { width: min(1180px, 100%); margin: 0 auto; padding: clamp(16px, 3vw, 30px); }

.tab-muc {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--ke);
  margin-bottom: 20px;
}
.tab-muc button {
  border: none;
  background: none;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--xam);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  border-radius: 8px 8px 0 0;
}
.tab-muc button.chon { color: var(--muc); border-bottom-color: var(--vang); background: #eef3f9; }

.thanh-loc { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.thanh-loc .nhom { margin: 0; min-width: 170px; }

.nhom-khoi { margin-bottom: 26px; }
.nhom-khoi h3 {
  font-size: 0.95rem;
  color: var(--bang);
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 4px solid var(--bang);
}

.luoi-tai-lieu { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

.the-tai-lieu {
  background: #fff;
  border: 1px solid var(--ke);
  border-radius: 12px;
  padding: 14px 14px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  text-align: left;
  width: 100%;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.the-tai-lieu::before {
  content: "";
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--muc-sang);
}
.the-tai-lieu:hover { border-color: var(--muc-sang); transform: translateY(-2px); }
.the-tai-lieu .ten { font-weight: 600; color: var(--than); line-height: 1.4; }
.the-tai-lieu .phu { font-size: 0.82rem; color: var(--xam); }

.trong-rong {
  padding: 40px 20px;
  text-align: center;
  color: var(--xam);
  background: #fff;
  border: 1px dashed var(--ke);
  border-radius: 12px;
}

/* ---------- Quản trị ---------- */

.bang { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.bang th, .bang td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--ke); font-size: 0.92rem; vertical-align: middle; }
.bang th { background: #eef3f9; color: var(--muc); font-weight: 600; }
.bang tr:last-child td { border-bottom: none; }
.bang .thao-tac { display: flex; gap: 6px; flex-wrap: wrap; }

.khung { background: #fff; border: 1px solid var(--ke); border-radius: 12px; padding: 18px; margin-bottom: 22px; }
.khung h3 { margin: 0 0 14px; font-size: 1rem; color: var(--muc); }
.luoi-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.luoi-form .nut { width: auto; }

.goi-y { font-size: 0.85rem; color: var(--xam); line-height: 1.6; margin: 8px 0 0; }
.goi-y code { background: #eef3f9; padding: 1px 6px; border-radius: 5px; color: var(--muc); }

.xem-truoc { width: 100%; max-height: 190px; object-fit: cover; border-radius: 10px; border: 1px solid var(--ke); background: #eef3f9; }
.xem-truoc[hidden] { display: none; }

.bao {
  display: none;
  margin-bottom: 16px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.92rem;
}
.bao.hien { display: block; }
.bao--ok { background: #e8f5f0; color: #0b5546; border-left: 4px solid var(--bang); }
.bao--loi { background: #fdf0ee; color: #8e2e20; border-left: 4px solid var(--but-do); }

/* ---------- Trình đọc PDF (có lật trang) ---------- */

.doc-sach {
  position: fixed;
  inset: 0;
  background: #0b1b2d;
  z-index: 80;
  display: none;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
}
.doc-sach.hien { display: flex; }

.doc-sach__dau {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px clamp(10px, 3vw, 20px);
  background: rgba(255, 255, 255, 0.06);
  color: #eaf1f8;
  flex-wrap: wrap;
}
.doc-sach__dau .ten { font-weight: 600; font-size: 0.95rem; }
.doc-sach__dau .phu { font-size: 0.8rem; color: #9fb6cd; }
.doc-sach__dau button {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
}
.doc-sach__dau button:hover { background: rgba(255, 255, 255, 0.24); }

.doc-sach__khung {
  flex: 1;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2vw, 22px);
}
.doc-sach__sach { transform-origin: center top; }

.pf-trang {
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.pf-trang canvas { width: 100%; height: 100%; display: block; }
.pf-trang .cho {
  color: #9fb6cd;
  font-size: 0.85rem;
}

.doc-sach__chan {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #eaf1f8;
  flex-wrap: wrap;
}
.doc-sach__chan button {
  background: var(--muc-sang);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
}
.doc-sach__chan button:disabled { opacity: 0.45; }
.doc-sach__chan .so-trang { font-size: 0.9rem; min-width: 120px; text-align: center; }
.doc-sach__chan .zoom { background: rgba(255,255,255,0.14); padding: 9px 12px; }

.dang-tai {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #cfe0f2;
  font-size: 0.95rem;
}

/* Không cho in trang có tài liệu */
@media print {
  body { display: none !important; }
}

/* ---------- Mobile ---------- */

@media (max-width: 860px) {
  .khu-tren__noi-dung { grid-template-columns: 1fr; gap: 18px; }
  .trang-chinh { grid-template-rows: auto auto; }
  .khu-tren { padding: 24px 18px 26px; }
  .khu-duoi { min-height: 42dvh; }
  .hieu { font-size: 1.6rem; }
  .mo-ta { font-size: 0.92rem; }
  .thanh-tren { padding: 12px 14px; }
  .bang thead { display: none; }
  .bang tr { display: block; border-bottom: 8px solid var(--giay); }
  .bang td { display: flex; justify-content: space-between; gap: 12px; border: none; padding: 8px 12px; }
  .bang td::before { content: attr(data-nhan); color: var(--xam); font-size: 0.8rem; }
}
