/* =========================================================================
   forum.css — DIEN DAN NGUOI DUNG
   Danh sach chu de, nut vote, chi tiet chu de + binh luan, bang xep hang.
   ========================================================================= */

.forum {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
  gap: clamp(20px, 3vw, 40px);
  align-items: start;
}
@media (max-width: 940px) {
  .forum { grid-template-columns: 1fr; }
  /* Bang xep hang xuong duoi danh sach tren man hinh hep. */
  .forum__side { order: 2; }
}

/* ── Thanh loc ──────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}
.chip {
  padding: 7px 14px;
  border: var(--hair) solid var(--border);
  border-radius: 4px;
  background: var(--card);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 650;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.is-active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.filters__spacer { flex: 1; }
.filters select {
  padding: 7px 10px;
  border: var(--hair) solid var(--border);
  border-radius: 4px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-xs);
}

/* ── Mot chu de trong danh sach ─────────────────────────── */
.topic {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 16px;
  padding: 18px 20px;
  margin-bottom: 12px;
}
.topic--pinned { border-color: var(--accent); box-shadow: var(--sh-md); }
/* Bai bi an: chi admin thay, lam mo di cho de phan biet. */
.topic--hidden { opacity: .55; }

/* Cot vote ben trai */
.vote {
  display: grid;
  gap: 2px;
  justify-items: center;
  align-content: start;
}
.vote__btn {
  width: 44px; height: 40px;
  display: grid; place-items: center;
  border: var(--hair) solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: transform var(--dur) var(--ease-spring),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}
.vote__btn:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }
/* Da vote: nen dam, mui ten trang. Bam lai la rut phieu. */
.vote__btn.is-on {
  background: var(--accent-solid);
  border-color: transparent;
  color: var(--accent-fg);
}
.vote__n {
  font-family: var(--font-mono);
  font-weight: 750;
  font-size: .95rem;
}
.vote__l {
  font-family: var(--font-mono);
  font-size: .58rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.topic__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.topic__title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}
a.topic__title:hover { color: var(--accent); }
.topic__body {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin: 0 0 10px;
  /* Cat con 2 dong trong danh sach; xem day du khi mo chu de. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.topic__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: var(--fs-xs);
  color: var(--text-faint);
}
.topic__author { display: inline-flex; align-items: center; gap: 7px; color: var(--text-muted); font-weight: 650; }
.topic__author .avatar { width: 24px; height: 24px; font-size: .7rem; border-radius: 4px; }

.topic__acts { display: flex; gap: 6px; margin-left: auto; }

/* Anh / video dinh kem */
.media {
  margin: 10px 0;
  border: var(--hair) solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-3);
  max-width: 460px;
}
.media img, .media video { width: 100%; display: block; max-height: 320px; object-fit: cover; background: #000; }

/* ── Chi tiet chu de ────────────────────────────────────── */
.thread__head { margin-bottom: 20px; }
.thread__head h1 { font-size: clamp(1.35rem, 2.6vw, 1.9rem); margin-bottom: 10px; }
.thread__body { font-size: var(--fs-body); color: var(--text); white-space: pre-wrap; }

.comment {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  padding: 16px 0;
  border-top: var(--hair) solid var(--border);
}
.comment--hidden { opacity: .55; }
.comment__body { white-space: pre-wrap; font-size: var(--fs-sm); color: var(--text); margin: 6px 0 8px; }
.comment__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: var(--fs-xs); color: var(--text-faint); }

/* Nut vote nho cho binh luan */
.vote--sm .vote__btn { width: 34px; height: 30px; }
.vote--sm .vote__n { font-size: .8rem; }

/* ── O soan bai ─────────────────────────────────────────── */
.composer { padding: 18px 20px; margin-bottom: 20px; }
.composer textarea { min-height: 90px; }

/* ── Bang xep hang ──────────────────────────────────────── */
.board { position: sticky; top: calc(var(--nav-h) + 16px); display: grid; gap: 14px; }
.board__seg { display: flex; gap: 4px; margin-bottom: 12px; }
.board__seg button {
  flex: 1;
  padding: 7px 6px;
  border: var(--hair) solid var(--border);
  border-radius: 4px;
  background: var(--card);
  color: var(--text-muted);
  font: inherit;
  font-family: var(--font-mono);
  font-size: .66rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}
.board__seg button.is-active { background: var(--accent-solid); color: var(--accent-fg); border-color: transparent; }

.board__item {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: var(--hair) solid var(--border);
  font-size: var(--fs-sm);
}
.board__item:first-of-type { border-top: 0; }
.board__rank {
  font-family: var(--font-mono);
  font-weight: 750;
  color: var(--text-faint);
}
/* Ba hang dau to mau — hang nhat dam nhat. */
.board__item:nth-of-type(1) .board__rank { color: var(--accent); }
.board__item:nth-of-type(2) .board__rank { color: var(--text-muted); }
.board__t { font-weight: 650; line-height: 1.35; color: var(--text); display: block; }
.board__t:hover { color: var(--accent); }
.board__s { font-size: var(--fs-xs); color: var(--text-faint); }

/* ═══ BỔ SUNG CHO BẢN web2 ══════════════════════════════════════════════ */

/* Bố cục hai cột: nội dung + bảng xếp hạng. Cột phải ẩn dưới 900px —
   điện thoại đọc danh sách trước đã, bảng xếp hạng là phụ. */
.forum {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: clamp(20px, 3vw, 32px);
  align-items: start;
  padding-bottom: clamp(48px, 8vw, 96px);
}

.forum__main { min-width: 0; }
.forum__more { text-align: center; margin-top: 16px; }

@media (max-width: 900px) {
  .forum { display: block; }
  .board { display: none; }
}

/* Nút dạng chữ (Trả lời / Báo cáo / Ẩn / Ghim…) — đủ vùng bấm cho ngón
   tay nhưng không choán chỗ như nút thật. */
.linklike {
  padding: 6px 4px;
  min-height: 32px;
  border: 0;
  background: none;
  color: var(--text-faint);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.linklike:hover { color: var(--accent); }

/* Thanh vote nhỏ nằm trong hàng hành động. */
.votebar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.votebar b {
  min-width: 22px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.votebar__btn {
  width: 34px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .72rem;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.votebar__btn:hover { border-color: var(--accent-solid); color: var(--accent); }

.votebar__btn.is-on {
  background: var(--accent-solid);
  border-color: transparent;
  color: var(--accent-fg);
}

/* Khung soạn: hai ô chọn nằm cạnh nhau, xuống dòng khi hẹp. */
.composer__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 14px;
}

.composer__acts { display: flex; gap: 10px; }

/* Ô lọc: select + ô tìm dùng chung giọng với .searchbox bên products. */
.filters select,
.filters input[type="search"] {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
}

.filters input[type="search"] { min-width: 0; flex: 1 1 140px; }

@media (max-width: 640px) {
  .filters select,
  .filters input[type="search"] { font-size: 16px; }  /* chong iOS phong to */
  .composer__acts .btn { flex: 1; }
  .votebar__btn { width: 44px; height: 38px; }         /* vua ngon tay */
}

/* ═══ TRÌNH SOẠN THẢO ═══════════════════════════════════════════════════ */

/* position:relative: nút kéo góc ảnh định vị theo khung này. */
.editor {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: visible;
}

.editor:focus-within {
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor__bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  /* Dinh len tren khi vung soan dai: cuon xuong viet tiep van voi toi nut. */
  position: sticky;
  top: 0;
  z-index: 3;
}

.editor__bar button {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
}

.editor__bar button:hover { background: var(--surface-3); color: var(--text); }

.editor__sep {
  width: 1px;
  height: 20px;
  margin: 0 5px;
  background: var(--border-strong);
}

/* Vùng soạn: RỘNG và CAO — đủ chỗ viết bài dài, tự giãn theo nội dung. */
.editor__body {
  min-height: 280px;
  max-height: 65dvh;
  overflow-y: auto;
  padding: 14px 16px;
  color: var(--text);
  font-size: var(--fs-body);
  line-height: 1.7;
  outline: none;
  word-break: break-word;
}

/* Placeholder cho contenteditable — thẻ này không có thuộc tính placeholder. */
.editor__body:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
}

.editor__body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.editor__body img.editor__img-on { outline: 2px solid var(--accent-solid); }
.editor__body img.editor__uploading { opacity: .6; }

.editor__body blockquote {
  margin: 8px 0;
  padding: 6px 14px;
  border-left: 3px solid var(--accent-solid);
  background: var(--surface-2);
  color: var(--text-muted);
}

.editor__body h3 { font-size: 1.05rem; margin: 12px 0 6px; }
.editor__body ul, .editor__body ol { padding-left: 24px; }

/* Nút kéo góc ảnh — chấm tròn vàng, 22px đủ tầm ngón tay. */
.editor__grip {
  position: absolute;
  z-index: 5;
  width: 22px;
  height: 22px;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: var(--accent-solid);
  cursor: nwse-resize;
  touch-action: none;          /* keo bang ngon tay khong bi cuon trang */
  padding: 0;
}

/* ═══ BÀI VIẾT DẠNG HTML (đã lọc ở máy chủ) ════════════════════════════ */
.thread__body--html { white-space: normal; }
.thread__body--html img { max-width: 100%; height: auto; border-radius: 6px; }
.thread__body--html blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent-solid);
  background: var(--surface-2);
  color: var(--text-muted);
}
.thread__body--html ul, .thread__body--html ol { padding-left: 24px; }
.thread__body--html a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.thread__body--html h3 { font-size: 1.05rem; margin: 14px 0 6px; }
.thread__body--html pre, .thread__body--html code {
  font-family: var(--font-mono);
  font-size: .86em;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 2px 6px;
}
.thread__body--html pre { padding: 10px 12px; overflow-x: auto; }

/* ═══ ĐIỆN THOẠI ════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* Nut thanh cong cu 40px — vua ngon tay; hang tu xuong dong. */
  .editor__bar button { min-width: 40px; height: 40px; }

  /* 16px chong iOS tu phong to khi cham vao vung soan. */
  .editor__body { font-size: 16px; min-height: 220px; max-height: 60dvh; }

  /* Nut keo goc to hon chut tren man cham. */
  .editor__grip { width: 28px; height: 28px; }
}

/* ═══ MÁY TÍNH BẢNG (641–1024px) ═══════════════════════════════════════
   Tablet phần lớn là màn chạm: nút phải đủ tầm ngón tay như điện thoại,
   nhưng bề ngang thì rộng — vùng soạn cao hơn và hai ô chọn vẫn nằm
   cạnh nhau. */
@media (min-width: 641px) and (max-width: 1024px) {
  .editor__bar button { min-width: 40px; height: 40px; }
  .editor__body { font-size: 16px; min-height: 300px; }
  .editor__grip { width: 26px; height: 26px; }
  .votebar__btn { width: 40px; height: 36px; }
  .linklike { min-height: 40px; }
}

/* Màn chạm bất kể bề ngang (tablet lai, laptop cảm ứng): nút kéo góc và
   vote nới theo ngón tay. hover: none = không có chuột. */
@media (hover: none) {
  .editor__grip { width: 28px; height: 28px; }
  .editor__bar button { min-width: 40px; height: 40px; }
}

/* Chip "Bài của tôi" — tach khoi nhom chuyen muc bang duong ke dot. */
.chip--mine {
  border-left: 1px dashed var(--border-strong);
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  padding-left: 14px;
  margin-left: 4px;
}

/* ═══ SỬA THEO GÓP Ý 30/08 ══════════════════════════════════════════════ */

/* ── 1. Bình luận: bỏ lưới hai cột ──────────────────────────────────────
   Luật .comment gốc chia cột "44px + 1fr" chờ sẵn ô avatar; bản này không
   vẽ avatar nên đầu bài, thân, hàng nút rơi xen kẽ vào cột 44px — chữ
   "Báo cáo" bị bẻ đôi từng chữ. Trả về khối thường. */
.comment {
  display: block;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.comment .comment__foot + .comment__body { margin-top: 8px; }

/* ── 2. Tên chủ đề: hạ cỡ ───────────────────────────────────────────────
   h2 mặc định ăn cỡ tiêu đề khối trang chủ (tới 2.25rem) — trong trang bài
   viết nó to lấn át nội dung. */
.thread__title {
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.35;
  margin: 8px 0 !important;
}

/* ── 3. Nút Like một biểu tượng ─────────────────────────────────────────
   Thay cặp ▲/▼: một ngón tay cái + số. Bấm = vote, bấm lại = bỏ vote. */
.likebtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s, transform .1s;
}

.likebtn b { font-variant-numeric: tabular-nums; }
.likebtn:hover { border-color: var(--accent-solid); color: var(--accent); }
.likebtn:active { transform: scale(.95); }

.likebtn.is-on {
  background: var(--accent-solid);
  border-color: transparent;
  color: var(--accent-fg);
}

/* ── 4. Nới vùng nội dung ───────────────────────────────────────────────
   Trang diễn đàn được rộng hơn khung 1180px chung: cột nội dung ăn hết
   phần dư, bảng xếp hạng dính mép phải. */
#forum-root { max-width: 1400px; }

.forum { grid-template-columns: minmax(0, 1fr) 290px; }

@media (hover: none) {
  .likebtn { min-height: 44px; padding: 8px 16px; }
}

/* Cả thẻ trong danh sách bấm được — con trỏ nói điều đó ra.
   Chỉ áp cho dòng danh sách (topic--link), không dính thẻ bài viết chi tiết. */
.topic--link { cursor: pointer; }
.topic--link:hover .topic__title { color: var(--accent); }

/* ── Ảnh đại diện tròn trước tên ────────────────────────────────────── */
.favt {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-solid);
  color: var(--accent-fg);
  font-size: .6rem;
  font-weight: 800;
  overflow: hidden;
  vertical-align: middle;
}

.favt img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Trong hàng meta (flex) avatar đứng sát tên. */
.topic__meta .favt { margin-right: -4px; }

/* ── Nội quy diễn đàn: hộp gập/mở đầu trang ────────────────────────────── */
.forum-rules {
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.forum-rules summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
}

.forum-rules ol { margin: 12px 0 8px; padding-left: 22px; }
.forum-rules li { margin-bottom: 6px; font-size: var(--fs-sm); color: var(--text-muted); }
.forum-rules p  { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   Dau "da chinh sua"  +  nut xoa cua quan tri   (06/09/2026)
   ═══════════════════════════════════════════════════════════ */

/* Doc tu cot EditedAt cua CSDL. KHONG bao gio doc UpdatedAt: cot do khai
   ON UPDATE current_timestamp() nen no doi theo moi cau UPDATE, ke ca lenh
   cong ViewCount chay o MOI luot xem — dung no thi chu de nao cung deo dau
   nay ngay sau nguoi xem dau tien. */
.da-sua{
  font-style:italic;
  opacity:.7;
  font-size:.92em;
}
.da-sua::before{ content:'· '; font-style:normal; }

/* Nut xoa bai nguoi khac: khong hoan tac bang mot cu bam nhu An/Hien lai,
   nen phai nhin khac nhung nut con lai. */
.linklike--danger{ color:var(--danger,#c0392b); }
.linklike--danger:hover{ color:var(--danger,#c0392b); text-decoration:underline; }

/* ── Bang goi y khi go @ ── */
.tagbang{
  position:absolute; z-index:20; left:0; top:100%;
  min-width:190px; max-width:280px;
  background:var(--surface-1,#fff);
  border:1px solid var(--border,#e5e7eb); border-radius:8px;
  box-shadow:0 10px 28px rgba(0,0,0,.18);
  overflow:hidden;
}
.tagbang__d{ padding:8px 12px; font-size:13px; cursor:pointer; }
.tagbang__d.is-chon, .tagbang__d:hover{ background:var(--surface-3,#eef2f7); }

/* ── Day so trang (danh sach chu de + binh luan) ── */
.sotrang{
  display:flex; flex-wrap:wrap; gap:4px;
  align-items:center; justify-content:center;
  margin:18px 0 4px;
}
.sotrang__o{
  min-width:34px; height:34px; padding:0 9px;
  border:1px solid var(--border,#e5e7eb); border-radius:8px;
  background:var(--surface-1,#fff); color:var(--text,#111);
  font-size:13px; cursor:pointer;
}
.sotrang__o:hover:not(:disabled){ background:var(--surface-3,#eef2f7); }
.sotrang__o:disabled{ cursor:default; }

/* Trang dang xem: to dam va doi mau, KHONG chi doi nen — nguoi nhin man hinh
   nhat mau van phai biet minh dang o trang nao. */
.sotrang__o.is-nay{
  background:var(--accent,#b4610f); border-color:var(--accent,#b4610f);
  color:#fff; font-weight:700;
}
.sotrang__cach{ padding:0 2px; color:var(--text-muted,#6b7280); }
