/* ============================================================
   LAYOUT — app grid, sidebar, topbar, content, screen routing
   ============================================================ */

/* ---- App shell ---- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(var(--surface-rgb), .55), rgba(var(--bg-rgb), .2));
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;   /* mobile: trừ thanh URL trình duyệt — không cấn đáy (AdminCP/user card) */
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 18px;
  flex-shrink: 0;
}

.sidebar__logo {
  height: 66px; width: auto;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(var(--shadow-rgb), .5))
          drop-shadow(0 6px 20px rgba(var(--pink-rgb), .25));
  flex-shrink: 0;
}

.sidebar__label {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  padding: 14px 10px 6px;
  display: block;
}

/* Menu KHÔNG bị bóp khi màn thấp (toolbar trình duyệt hiện) — giữ nguyên giãn cách, tràn thì CUỘN.
   Lưu ý: .sidebar__nav dùng display:contents → flex item thật là các nút BÊN TRONG nó. */
.sidebar > *, .sidebar__nav > * { flex-shrink: 0; }

/* Thanh cuộn sidebar mỏng, luôn dùng được (menu dài hơn màn → cuộn mượt) */
.sidebar { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar__nav { display: contents; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
  transition: background var(--ease), color var(--ease);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn__icon { width: 20px; text-align: center; font-size: 17px; flex-shrink: 0; }

/* Badge tổng việc cần xử lý cạnh menu AdminCP */
.nav-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  margin-left: auto; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: var(--on-accent); font-size: 11px; font-weight: 800; flex-shrink: 0;
}

.nav-btn:hover  { background: var(--surface); color: var(--ink); }

.nav-btn.is-active {
  color: var(--ink);
  background: linear-gradient(90deg, rgba(var(--pink-rgb), .18), rgba(var(--violet-rgb), .08));
}
.nav-btn.is-active::before {
  content: "";
  position: absolute;
  left: -16px; top: 9px; bottom: 9px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--pink);
  box-shadow: 0 0 12px var(--pink);
}

/* ── Nhóm "Tài khoản" xổ ra / gập vào (gọn menu cho người mới) ── */
.nav-acct__chev { margin-left: auto; font-size: 11px; opacity: .6; transition: transform var(--ease); }
.nav-acct__head[aria-expanded="true"] .nav-acct__chev { transform: rotate(180deg); opacity: 1; }
.nav-acct__sub { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.nav-acct__sub[hidden] { display: none; }
.nav-acct__sub .nav-btn { padding-left: 30px; font-size: 14px; }
/* Đầu nhóm chỉ SÁNG NHẸ khi đang ở 1 mục con (không dùng thanh/nền như mục thường) */
.nav-acct__head.is-active { color: var(--ink); background: transparent; }
.nav-acct__head.is-active::before { display: none; }

.nav-btn__badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--bg);
  background: var(--cyan);
  padding: 1px 7px;
  border-radius: 20px;
  flex-shrink: 0;
}

.sidebar__user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--surface);
  flex-shrink: 0;
}

.sidebar__user-av {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--orange-tint), var(--pink-hot));
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--bg);
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar__user-av img { width: 100%; height: 100%; object-fit: cover; }

.sidebar__user-name   { font-size: 13.5px; font-weight: 700; }
.sidebar__user-status { font-size: 11px; color: var(--green); font-weight: 600; }

/* ---- Main column ---- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(var(--bg-rgb), .82);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.topbar__menu {
  display: none;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 20px;
  padding: 6px;
  border-radius: 8px;
}

.topbar__search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 9px 13px;
}
.topbar__search input {
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 100%;
  font-size: 14px;
  outline: none;
}
.topbar__search input::placeholder { color: var(--faint); }

/* Điều hướng nhanh trên header (Bảng tin · Cộng đồng · Xếp hạng · Story) */
.topnav { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav__btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border: 1px solid var(--line-soft); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 8px 13px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: var(--ease);
}
.topnav__btn:hover { border-color: var(--violet); background: var(--surface2); }
.topnav__btn.is-active { background: var(--violet); border-color: var(--violet); color: var(--on-accent); }
/* Màn hẹp: tiết kiệm chỗ để đủ hiện các mục nav (gồm Hướng dẫn) */
@media (max-width: 1360px) {
  .topnav { gap: 5px; }
  .topnav__btn { padding: 8px 10px; font-size: 13px; }
}

/* Nút "Newsfeed và Chatbox" — trung tâm cộng đồng, làm nổi bật hẳn */
.topnav__btn--feed {
  position: relative;
  border: 0;
  color: var(--on-accent);
  font-weight: 700;
  padding: 8px 15px 8px 9px;
  background: linear-gradient(120deg, var(--pink) 0%, var(--violet) 52%, var(--cyan) 100%);
  background-size: 200% 100%;
  background-position: 0% 50%;
  box-shadow: 0 6px 20px -7px rgba(var(--pink-rgb), .6), inset 0 1px 0 rgba(var(--hl-rgb), .28);
  animation: feed-glow 3.4s ease-in-out infinite;
  transition: background-position .45s ease, transform var(--ease), box-shadow var(--ease), filter var(--ease);
}
.topnav__btn--feed:hover {
  background-position: 100% 50%;
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 11px 26px -7px rgba(var(--violet-rgb), .7), inset 0 1px 0 rgba(var(--hl-rgb), .34);
}
.topnav__btn--feed.is-active {
  background-position: 100% 50%;
  box-shadow: 0 0 0 2px rgba(var(--hl-rgb), .2), 0 9px 24px -7px rgba(var(--violet-rgb), .7);
  animation: none;
}
/* Logo trong khung tròn sáng */
.topnav__btn--feed .topnav__btn-ic {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 8px;
  font-size: 14px;
  background: rgba(var(--hl-rgb), .22);
  box-shadow: inset 0 0 0 1px rgba(var(--hl-rgb), .25);
}
@keyframes feed-glow {
  0%, 100% { box-shadow: 0 6px 20px -7px rgba(var(--pink-rgb), .55), inset 0 1px 0 rgba(var(--hl-rgb), .28); }
  50%      { box-shadow: 0 8px 26px -6px rgba(var(--violet-rgb), .7),  inset 0 1px 0 rgba(var(--hl-rgb), .28); }
}
@media (prefers-reduced-motion: reduce) { .topnav__btn--feed { animation: none; } }

.topbar__wallet {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color var(--ease);
}
.topbar__wallet:hover { border-color: var(--gold); }
.topbar__wallet b   { font-family: var(--font-mono); letter-spacing: .3px; }
.topbar__wallet small { color: var(--faint); font-size: 11px; display: block; line-height: 1; }
.topbar__wallet-div { width: 1px; height: 24px; background: var(--line); margin: 0 1px; }

.topbar__icon-btn {
  width: 40px; height: 40px;
  border-radius: 11px;
  border: 1px solid var(--line-soft);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: border-color var(--ease);
  flex-shrink: 0;
}
.topbar__icon-btn:hover { border-color: var(--pink); }

.topbar__icon-btn--topup {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: var(--on-gold);
  border: 0;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 8px 20px -8px rgba(var(--gold-rgb), .7);
}
.topbar__icon-btn--topup:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ---- Content area & screen routing ---- */
.content {
  flex: 1;
  padding: 28px 30px 60px;
  overflow-x: clip;   /* clip (không phải hidden) → KHÔNG tạo scroll-container,
                         nhờ vậy position:sticky (cột chat Bảng tin) bám viewport được */
}

.screen {
  display: none;
  animation: fade-in .35s ease;
  max-width: 1280px;
  margin-inline: auto;   /* căn giữa nội dung, cân đối 2 bên */
}
.screen.is-active { display: block; }

/* ---- Mobile responsive ---- */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);   /* đúng bề rộng/giãn cách như bản desktop — quen mắt */
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 50;
    /* Drawer đè lên nội dung → nền phải ĐẶC (bản desktop trong suốt vì nằm cạnh bg) */
    background: linear-gradient(180deg, var(--surface), var(--bg2));
    border-right: 1px solid var(--line);
    box-shadow: 24px 0 70px rgba(var(--shadow-rgb), .6);
  }
  .sidebar.is-open { transform: none; }

  .topbar__menu { display: grid; }

  /* Topbar 1 TẦNG: ☰ + topnav icon-only + 🔔 + avatar tài khoản.
     Ví/Nạp/Điểm danh/Đăng xuất gom vào dropdown tài khoản (.acct). */
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar__wallet, #topupShortBtn, #checkinBtn, #authBtn { display: none; }
  .topnav__btn { font-size: 0; gap: 0; padding: 8px 11px; }   /* ẩn chữ, giữ icon */
  .topnav__btn span { font-size: 17px; }
  .topbar__icon-btn { margin-left: auto; }                     /* 🔔 đẩy về phải */
  .topbar .acct { display: block; }   /* selector mạnh hơn rule nền .acct{display:none} phía dưới */

  .content { padding: 18px 16px 60px; }
}

/* Lớp phủ sau drawer menu (mobile) — bấm vào là đóng */
.nav-backdrop {
  position: fixed; inset: 0; z-index: 49;
  background: rgba(10, 8, 24, .62);
  backdrop-filter: blur(2px);
}

/* ---- 📱 Menu tài khoản trên topbar (chỉ hiện mobile) ---- */
.acct { display: none; position: relative; flex-shrink: 0; }
.acct__btn {
  width: 38px; height: 38px; border-radius: 11px; overflow: hidden;
  border: 1px solid var(--line-soft); background: var(--surface);
  display: grid; place-items: center; font-size: 17px; cursor: pointer; padding: 0;
}
.acct__btn img { width: 100%; height: 100%; object-fit: cover; }
.acct__menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  min-width: 210px; padding: 6px;
  background: linear-gradient(180deg, var(--surface), var(--bg2));
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 50px -12px rgba(var(--shadow-rgb), .65);
  display: flex; flex-direction: column; gap: 2px;
}
.acct__item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: none; color: var(--ink); cursor: pointer;
  font-size: 13.5px; font-weight: 600; text-align: left;
  padding: 10px 11px; border-radius: 10px; transition: var(--ease);
}
.acct__item:hover { background: var(--surface2); }
.acct__bal { justify-content: space-between; font-family: var(--font-mono); background: var(--bg2); }
.acct__item--auth { border-top: 1px solid var(--line-soft); border-radius: 0 0 10px 10px; color: var(--muted); }
