/* ============================================================
   FEED — Bảng tin (newsfeed kiểu Facebook)
   ============================================================ */

#feed { max-width: 1400px; }

/* ---------- Bố cục 2 cột BẰNG NHAU: bảng tin (trái) · chat cộng đồng (phải, ghim) ---------- */
.feed-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-top: 4px;
}
.feed-layout__main { min-width: 0; }
.feed-layout__main > .sec-head:first-child { margin-top: 0; }   /* canh đỉnh cột trái = đỉnh khung chat */
.feed-layout__side {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  align-self: start;
}

@media (max-width: 1200px) {
  /* minmax(0,1fr) chứ KHÔNG phải 1fr — 1fr có min=auto khiến dải story ép nở ngang cả nghìn px */
  .feed-layout { grid-template-columns: minmax(0, 1fr); }
  .feed-layout__side { position: static; }
  .chat-window--embed { height: 540px; max-height: none; }
  .chat-window--embed .chat-messages { height: auto; flex: 1; }
}

.feed-empty {
  text-align: center; color: var(--muted); padding: 40px 16px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 16px;
}

/* ---------- Khu soạn bài ---------- */
.feed-compose { padding: 14px; margin-bottom: 18px; }
.feed-compose__top { display: flex; gap: 11px; align-items: flex-start; }
.feed-compose__av,
.feed-post__av,
.feed-cmt__av,
.feed-cmts__av {
  flex-shrink: 0; border-radius: 11px; overflow: hidden;
  display: grid; place-items: center; color: var(--bg); font-weight: 700;
  background: linear-gradient(135deg, var(--violet2), var(--cyan));
}
.feed-compose__av,
.feed-post__av { width: 44px; height: 44px; font-size: 19px; }
.feed-cmt__av,
.feed-cmts__av { width: 30px; height: 30px; font-size: 14px; }
.feed-compose__av img, .feed-post__av img, .feed-cmt__av img, .feed-cmts__av img
  { width: 100%; height: 100%; object-fit: cover; }

.feed-compose__input {
  flex: 1; min-height: 44px; resize: vertical; border: 0; outline: none;
  background: var(--surface2); border-radius: 12px; padding: 11px 13px;
  color: var(--ink); font-family: var(--font-main); font-size: 14px; line-height: 1.5;
}
.feed-compose__previews { display: flex; flex-wrap: wrap; gap: 8px; margin: 11px 0 0 55px; }
.feed-prev { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; }
.feed-prev img { width: 100%; height: 100%; object-fit: cover; }
.feed-prev__x {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border: 0; cursor: pointer;
  border-radius: 50%; background: rgba(var(--shadow-rgb), .6); color: var(--on-accent); font-size: 11px; line-height: 1;
}
.feed-compose__tags { margin: 10px 0 0 55px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.feed-compose__with { font-size: 12px; color: var(--muted); }
.feed-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  background: rgba(var(--violet-rgb), .16); color: #ECE6FF; border: 1px solid rgba(var(--violet-rgb), .4);
  border-radius: 999px; padding: 3px 5px 3px 9px;
}
.feed-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 11px; opacity: .8; }
.feed-chip button:hover { opacity: 1; }

.feed-compose__bar {
  display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 11px;
  border-top: 1px solid var(--line-soft);
}
.feed-compose__tool {
  border: 1px solid var(--line-soft); background: var(--surface2); color: var(--ink);
  border-radius: 10px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: var(--ease);
}
.feed-compose__tool:hover { background: var(--surface); transform: translateY(-1px); }
.feed-compose__post { margin-left: auto; padding: 8px 22px; }

/* ---------- Một bài viết ---------- */
.feed-post { padding: 14px; margin-bottom: 16px; }
.feed-post__head { display: flex; align-items: flex-start; gap: 11px; }
.feed-post__who { flex: 1; min-width: 0; line-height: 1.35; }
.feed-post__name { font-size: 14.5px; font-weight: 700; }
.feed-post__badge {
  font-size: 10px; font-weight: 700; color: var(--cyan);
  background: rgba(var(--cyan-rgb), .14); border-radius: 6px; padding: 1px 6px; vertical-align: middle;
}
.feed-post__with { font-size: 13px; color: var(--muted); font-weight: 400; }
.feed-post__time { display: block; font-size: 11.5px; color: var(--faint); margin-top: 1px; }
.feed-post__del { border: 0; background: none; cursor: pointer; font-size: 15px; opacity: .55; padding: 2px 4px; }
.feed-post__del:hover { opacity: 1; }

.feed-post__cap { margin: 11px 0; font-size: 14px; line-height: 1.6; color: var(--ink); white-space: pre-wrap; word-break: break-word; }

/* Lưới ảnh 1–4 (kiểu Facebook) */
.feed-post__imgs { display: grid; gap: 3px; border-radius: 12px; overflow: hidden; margin-top: 4px; }
.feed-post__imgs--n1 { grid-template-columns: 1fr; }
.feed-post__imgs--n2 { grid-template-columns: 1fr 1fr; }
.feed-post__imgs--n3 { grid-template-columns: 1fr 1fr 1fr; }
.feed-post__imgs--n4 { grid-template-columns: 1fr 1fr; }
.feed-post__img { width: 100%; cursor: pointer; display: block; transition: filter var(--ease); }
.feed-post__imgs--n1 .feed-post__img { max-height: 540px; object-fit: cover; }
.feed-post__imgs:not(.feed-post__imgs--n1) .feed-post__img { aspect-ratio: 1; object-fit: cover; }
.feed-post__img:hover { filter: brightness(1.06); }

.feed-post__stats {
  display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted);
  padding: 10px 2px 8px;
}
.feed-post__stats [data-stat="like"] b { color: var(--ink); }

.feed-post__actions {
  display: flex; gap: 4px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  padding: 4px 0; margin-bottom: 4px;
}
.feed-act {
  flex: 1; border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 8px; border-radius: 9px; transition: var(--ease);
}
.feed-act:hover { background: var(--surface2); color: var(--ink); }
.feed-act.is-liked { color: var(--pink); }

/* ---------- Bình luận ---------- */
.feed-cmts { padding-top: 6px; }
.feed-cmts__more { border: 0; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600;
  cursor: pointer; padding: 4px 2px; margin-bottom: 4px; }
.feed-cmts__more:hover { color: var(--ink); }
.feed-cmts__list { display: flex; flex-direction: column; gap: 8px; }
.feed-cmt { display: flex; gap: 8px; align-items: flex-start; }
.feed-cmt__bubble {
  background: var(--surface2); border-radius: 13px; padding: 7px 12px; max-width: 100%;
  font-size: 13px; line-height: 1.45;
}
.feed-cmt__name { font-size: 12.5px; font-weight: 700; margin-right: 6px; }
.feed-cmt__text { color: var(--ink); word-break: break-word; }
.feed-cmt__time { font-size: 10.5px; color: var(--faint); margin-top: 2px; }

.feed-cmts__add { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.feed-cmts__input {
  flex: 1; border: 1px solid var(--line-soft); background: var(--surface2); border-radius: 999px;
  padding: 8px 14px; color: var(--ink); font-family: var(--font-main); font-size: 13px; outline: none;
}
.feed-cmts__input:focus { border-color: var(--violet); }

/* Liên kết tên / @nhắc tên */
.feed-link { cursor: pointer; color: inherit; }
.feed-link:hover { text-decoration: underline; }
.feed-mention { color: var(--cyan); font-weight: 600; }

/* ---------- Tabs lọc ---------- */
.feed-filter { margin: 0 0 16px; }

/* ---------- Menu sửa/xoá ---------- */
.feed-post__menu { display: flex; gap: 2px; flex-shrink: 0; }
.feed-post__mbtn { border: 0; background: none; cursor: pointer; font-size: 14px; opacity: .55; padding: 3px 5px; border-radius: 8px; }
.feed-post__mbtn:hover { opacity: 1; background: var(--surface2); }

.feed-post__shared-tag { font-size: 11px; color: var(--violet); font-weight: 600; }
.feed-post__stats-r { display: inline-flex; gap: 12px; }

/* ---------- Bài chia sẻ lồng nhau ---------- */
.feed-shared {
  border: 1px solid var(--line-soft); border-radius: 13px; padding: 11px;
  margin: 4px 0 6px; background: var(--surface);
}
.feed-shared--gone { color: var(--faint); font-size: 13px; text-align: center; padding: 18px; }
.feed-shared__head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.feed-shared__av { width: 34px; height: 34px; font-size: 15px; }
.feed-shared__name { font-size: 13.5px; font-weight: 700; }
.feed-shared__time { display: block; font-size: 11px; color: var(--faint); }
.feed-shared__cap { font-size: 13.5px; line-height: 1.55; color: var(--ink); margin-bottom: 8px; white-space: pre-wrap; word-break: break-word; }
.feed-share-prev { margin-top: 10px; max-height: 320px; overflow: auto; }
.feed-edit__area { width: 100%; min-height: 90px; }

.feed-more { text-align: center; margin: 6px 0 30px; }

/* ============================================================
   NEBULA 2.0 — skin Cộng Đồng (feed) · 1 DOM · CSS-only theo theme.
   Cấu trúc 2 cột (feed trái · chat phải sticky) đã khớp mẫu → chỉ tô lại.
   Neon giữ nguyên. feed.js/chatbox.js KHÔNG đổi. feed ∈ NEB_SCREENS.
   ============================================================ */
:root[data-theme="nebula"] .app.is-neb #content > #feed.screen { max-width: 1400px; margin: 0 auto; padding: 26px 30px 60px; }

/* 2 cột 1.6fr : 1fr (feed rộng hơn chat) như mẫu.
   PHẢI minmax(0,…) — 1fr có min=auto khiến dải story ép nở cột cả nghìn px (bug đã biết). */
:root[data-theme="nebula"] #feed .feed-layout { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 22px; }

/* Thẻ (compose + bài viết) → glass PHẲNG như mẫu: nền đều + viền đều 4 cạnh.
   Bỏ gradient (top sáng) + bỏ box-shadow inset (vệt sáng cạnh TRÊN) → viền không "chỏi ở trên". */
:root[data-theme="nebula"] #feed .card {
  background: rgba(var(--hl-rgb), .04);
  border: 1px solid rgba(var(--hl-rgb), .09);
  box-shadow: none;
}
:root[data-theme="nebula"] #feed .feed-post { border-radius: 16px; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
:root[data-theme="nebula"] #feed .feed-post:hover { transform: translateY(-2px); border-color: rgba(var(--violet-rgb), .35); box-shadow: 0 16px 34px -20px rgba(var(--violet-rgb), .4); }

/* Ô soạn bài + nút công cụ → kính trong */
:root[data-theme="nebula"] #feed .feed-compose__input,
:root[data-theme="nebula"] #feed .feed-compose__tool { background: rgba(var(--hl-rgb), .05); border: 1px solid rgba(var(--hl-rgb), .08); }

/* Filter → viên pill (active tím-nhạt chữ tối, đúng mẫu) */
:root[data-theme="nebula"] #feed .feed-filter .itab { border-radius: 100px; padding: 8px 15px; background: rgba(var(--hl-rgb), .05); border: 1px solid rgba(var(--hl-rgb), .09); color: var(--ink-soft); }
:root[data-theme="nebula"] #feed .feed-filter .itab.is-active { background: var(--violet-tint); border-color: transparent; color: var(--bg); font-weight: 600; }

/* Chat panel phải: glass PHẲNG như mẫu (nền đều + viền đều 4 cạnh, KHÔNG inset/shadow) */
:root[data-theme="nebula"] #feed .chat-window--embed {
  background: rgba(var(--hl-rgb), .04);
  border: 1px solid rgba(var(--hl-rgb), .09); border-radius: 18px; overflow: hidden;
  box-shadow: none;
}

/* ============================================================
   RÀ SOÁT ĐỒNG BỘ (2026-07-08) — nền phụ + chat panel nội bộ + link/nút.
   Nguyên tắc: mọi bề mặt = kính rgba(--hl); thanh kẻ đã dịu ở token; bỏ hard-code tím.
   ============================================================ */

/* "Xem tất cả →" (header Story) → tím nhạt tinh tế (đồng bộ accent Nebula) */
:root[data-theme="nebula"] #feed .sec-head__see { color: var(--violet-tint); }
:root[data-theme="nebula"] #feed .sec-head h3 { font-weight: 800; letter-spacing: -.02em; }

/* Nền PHỤ trong bài viết (bong bóng/ô bình luận/bài chia sẻ) → kính trong (thay --surface2 tím đặc) */
:root[data-theme="nebula"] #feed .feed-cmt__bubble,
:root[data-theme="nebula"] #feed .feed-cmts__input,
:root[data-theme="nebula"] #feed .feed-shared {
  background: rgba(var(--hl-rgb), .05);
  border-color: rgba(var(--hl-rgb), .08);
}
:root[data-theme="nebula"] #feed .feed-act:hover { background: rgba(var(--hl-rgb), .06); }

/* ---- Chat panel nội bộ: đồng bộ glass (bỏ gradient tím hard-code + nền --surface sáng) ---- */
/* Titlebar (mac dots) + header phòng: kính trong, bỏ gradient tím #2A2350/#211B43 */
:root[data-theme="nebula"] #feed .chat-titlebar { background: rgba(var(--hl-rgb), .03); }
:root[data-theme="nebula"] #feed .chat-main__head { background: transparent; }
/* Ô nhập tin + nút thành viên → kính trong (thay nền --surface tím) */
:root[data-theme="nebula"] #feed .chat-input__field,
:root[data-theme="nebula"] #feed .chat-main__members {
  background: rgba(var(--hl-rgb), .05);
  border-color: rgba(var(--hl-rgb), .09);
}
/* Nút GỬI tin nhắn → tím đặc tinh tế (thay gradient hồng→tím chỏi; đúng mẫu #7a5bff = --violet2) */
:root[data-theme="nebula"] #feed .chat-input__send { background: var(--violet2); }

/* Viền sáng khi focus ô nhập chat (giữ MÀU CARET gốc).
   Ẩn placeholder khi focus → caret không còn ĐÈ lên chữ "N" của "Nhắn" (hết bị che). */
:root[data-theme="nebula"] #feed .chat-input__field:focus-within { border-color: rgba(var(--violet-rgb), .5); }
:root[data-theme="nebula"] #feed .chat-input__field input:focus::placeholder { color: transparent; }

/* 💝 TẶNG QUÀ NỔI BẬT (DOANH THU): gradient hồng→tím + icon trắng — mời gọi donate (đồng bộ chatbox 1-1) */
:root[data-theme="nebula"] #feed .chat-input__gift {
  background: linear-gradient(135deg, var(--pink), var(--violet)); border: 0; color: #fff;
  box-shadow: 0 6px 16px -7px rgba(var(--pink-rgb), .7);
}
:root[data-theme="nebula"] #feed .chat-input__gift svg { width: 19px; height: 19px; }
:root[data-theme="nebula"] #feed .chat-input__gift:hover { filter: brightness(1.1); color: #fff; transform: translateY(-1px); }
:root[data-theme="nebula"] #feed .feed-act[data-act="donate"] { color: var(--pink-tint); }
:root[data-theme="nebula"] #feed .feed-act[data-act="donate"]:hover { background: rgba(var(--pink-rgb), .12); color: var(--pink); }

/* ---- Header GỘP 1 hàng như mẫu (mac-dots + tên + online + nút thành viên) ----
   App có 2 hàng (titlebar + head); Nebula ẩn titlebar, vẽ mac-dots lên head bằng ::before. */
:root[data-theme="nebula"] #feed .chat-titlebar { display: none; }
:root[data-theme="nebula"] #feed .chat-main__head { padding: 11px 18px; gap: 9px; align-items: center; }
:root[data-theme="nebula"] #feed .chat-main__head::before {
  content: ''; flex: none; width: 11px; height: 11px; border-radius: 50%;
  background: #ff5f57; box-shadow: 16px 0 0 #febc2e, 32px 0 0 #28c840;
  margin-right: 35px;   /* chừa chỗ cho 2 chấm vẽ bằng box-shadow (không chiếm layout) */
}
:root[data-theme="nebula"] #feed .chat-main__room-name { font-size: 13.5px; font-weight: 700; }
/* Bỏ text "· N đang online" — LẶP với nút 👥 (đã hiện số online). Nút thành viên tự đẩy phải. */
:root[data-theme="nebula"] #feed .chat-main__online { display: none; }
:root[data-theme="nebula"] #feed .chat-main__members { margin-left: auto; }

/* Mobile/tablet: về 1 cột (override id-scope ở trên thắng media-query gốc → phải lặp lại) */
@media (max-width: 1200px) {
  :root[data-theme="nebula"] #feed .feed-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  #feed { max-width: 100%; }
  /* Mobile: CHAT CỘNG ĐỒNG lên TRÊN bảng tin (giữ grid minmax để story strip không ép nở ngang) */
  .feed-layout__side { order: -1; }
  .chat-window--embed { height: min(68dvh, 580px); }   /* cao hơn chút — vẫn ló story ngay dưới */

  /* Bỏ hàng "🏠 Quán-trọ · 🟢 online" (tiết kiệm chỗ chat); nút 👥 dời LÊN thanh tiêu đề */
  .chat-window--embed .chat-main__room-name,
  .chat-window--embed .chat-main__online { display: none; }
  .chat-window--embed .chat-main__head { padding: 0; border-bottom: 0; }
  .chat-window--embed .chat-main__members {
    position: absolute; top: -33px; right: 10px; z-index: 8;   /* neo theo .chat-main → nhảy lên titlebar */
  }
  .chat-window--embed .chat-members--pop { top: 8px; }
  .chat-window--embed .chat-titlebar__title {
    padding-right: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
}
