/* #440 Phòng, direction H (features/rooms-redesign-v4/h-hai-cot.html + shared.css, card v3).
   Sticky counts bar → online rail (desktop, own scroll, collapses to faces) + rule tabs, filters, compact
   table cards. Scoped to #panel-tables on index.html; markup from index.html + js/rooms-h.js.
   body keeps overflow-x: clip (never hidden: it kills position: sticky, #215). */

/* The page title bar is not shown on this screen; the counts bar is the first line under the 56px nav. */
body.zen-lobby .lobby:has(#panel-tables.is-active) { max-width: 1240px; padding-top: 0; }

#panel-tables { --rooms-bar-h: 64px; }
#panel-tables .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
#panel-tables .icon--md { width: 20px; height: 20px; }
#panel-tables .vstat b, #panel-tables .vr, #panel-tables .velo, #panel-tables .ve, #panel-tables .vtab__n, #panel-tables .vcode { font-variant-numeric: tabular-nums; }

/* ── 1. Sticky counts bar ─────────────────────────────────────────────── */
.rooms-bar { position: sticky; top: 56px; z-index: 5; display: flex; align-items: center; gap: 24px; min-height: var(--rooms-bar-h); box-sizing: border-box;
  margin: 0 -24px; padding: 12px 24px; background: var(--c-bg); border-bottom: 1px solid var(--c-border); }
#panel-tables .rooms-bar .rooms-bar__people { display: none; }
.rooms-bar__new { margin-left: auto; }
.vstat { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.vstat b { font-size: 22px; font-weight: 800; color: var(--c-ink); }
.vstat span { font-size: var(--text-sm); color: var(--c-ink-2); }
.vstat i { align-self: center; width: 8px; height: 8px; border-radius: 50%; background: var(--c-state-playing); box-shadow: 0 0 0 3px var(--c-success-bg, transparent); }
.vstat--play i { background: var(--c-state-waiting); box-shadow: none; }

/* ── buttons / chips / inputs (H vocabulary, aligned with components.css) ── */
#panel-tables .vbtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--ctl-h-md); min-width: 64px; padding: 0 var(--ctl-px-md);
  border: var(--ctl-bw) solid transparent; border-radius: var(--ctl-r-pill); font: inherit; font-size: var(--text-sm); font-weight: 800; cursor: pointer; white-space: nowrap; text-decoration: none; }
#panel-tables .vbtn--primary { background: var(--c-brand); color: var(--c-on-brand); }
#panel-tables .vbtn--primary:hover { background: var(--c-brand-dark, var(--c-brand)); }
#panel-tables .vbtn--ghost { background-color: color-mix(in srgb, var(--c-ink) var(--ctl-fill-pct), var(--c-surface)); border-color: transparent; color: var(--c-ink); }   /* #511 neutral tonal */
#panel-tables .vbtn--ghost:hover { background-color: color-mix(in srgb, var(--c-ink) var(--ctl-fill-hover-pct), var(--c-surface)); }
#panel-tables .vbtn--lg { min-height: var(--ctl-h-lg); padding: 0 var(--ctl-px-lg); font-size: var(--text-md); }
#panel-tables .vicon-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--ctl-h-md); height: var(--ctl-h-md); border: 0; border-radius: var(--ctl-r-pill);
  background: none; cursor: pointer; color: var(--c-ink-2); }
#panel-tables .vicon-btn:hover { background: var(--c-hover); }
#panel-tables button:focus-visible, #panel-tables input:focus-visible, #panel-tables select:focus-visible, #panel-tables [tabindex]:focus-visible {
  outline: var(--focus-w) solid var(--c-focus); outline-offset: var(--focus-offset); }

.vtabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.vtabs::-webkit-scrollbar { display: none; }
.vtab { display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: var(--ctl-h-md); padding: 0 14px; border: 0; border-radius: var(--ctl-r-pill);
  background: none; font: inherit; font-size: var(--text-sm); font-weight: 700; color: var(--c-ink-2); cursor: pointer; white-space: nowrap; }
.vtab:hover { color: var(--c-ink); background-color: color-mix(in srgb, var(--c-ink) var(--ctl-fill-pct), var(--c-surface)); }
.vtab[aria-selected="true"] { color: var(--c-brand-text); background-color: color-mix(in srgb, var(--c-brand-text) var(--ctl-tint-pct), var(--c-surface)); box-shadow: inset 0 0 0 var(--ctl-ring-w) var(--c-brand-text); font-weight: 800; }   /* #511 pill tab */
.vtab .icon { width: 18px; height: 18px; }
.vtab__n { min-width: 22px; padding: 0 7px; border-radius: var(--ctl-r-pill); background: var(--c-fill); font-size: var(--text-xs); font-weight: 800; text-align: center; color: var(--c-ink-2); }
.vtab[aria-selected="true"] .vtab__n { background: var(--c-brand-light); color: var(--c-brand-text); }
.vtab--guide { margin-left: auto; }

.vselect { min-height: var(--ctl-h-sm); padding: 0 32px 0 12px; border: var(--ctl-bw) solid var(--c-border-strong); border-radius: var(--ctl-r-pill); background-color: var(--c-field); color: var(--c-ink);
  font: inherit; font-size: var(--text-sm); font-weight: 700; }
@media (max-width: 860px) { .vselect { min-height: 44px; } }   /* B306: phone touch target (--ctl-h-sm is 40px there) */

.vsearch { display: flex; align-items: center; gap: 8px; min-height: var(--ctl-h-md); padding: 0 12px; border: var(--ctl-bw) solid var(--c-border-strong); border-radius: var(--ctl-r-pill);
  background: var(--c-field); color: var(--c-ink-3); }
.vsearch input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: var(--text-sm); color: var(--c-ink); }
.vsearch input:focus, .vsearch input:focus-visible { outline: none; }
.vsearch:focus-within { border-color: var(--c-brand-text); }
.vsearch input::-webkit-search-cancel-button { cursor: pointer; }

/* ── 2. Roster rows (rail + sheet) ────────────────────────────────────── */
.vroster { list-style: none; margin: 0; padding: 0; }
.vrow { display: flex; align-items: center; gap: 10px; min-height: 44px; box-sizing: border-box; padding: 6px 12px; border-radius: var(--radius-lg, 12px); }
.vrow[role="button"] { cursor: pointer; }
.vrow[role="button"]:hover { background: var(--c-hover); }
.vrow__n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: var(--text-sm); color: var(--c-ink); }
.vrow__you { font-weight: 600; color: var(--c-ink-3); }
.vrow--empty { color: var(--c-ink-3); font-size: var(--text-sm); }
.vrow .pav { flex: none; }
.vgroup { padding: 12px 12px 4px; font-size: var(--text-xs); font-weight: 800;color: var(--c-ink-3); }
.vr { display: inline-flex; justify-content: center; flex: none; min-width: 46px; box-sizing: border-box; padding: 2px 8px; border-radius: 999px; background: var(--c-fill);
  font-size: var(--text-xs); font-weight: 800; color: var(--c-ink); white-space: nowrap; }
.vr--top1 { background: var(--c-medal-gold); } .vr--top2 { background: var(--c-medal-silver); } .vr--top3 { background: var(--c-medal-bronze); }
.vr--prov { color: var(--c-ink-2); font-weight: 700; }
.vr--none { background: none; border: 1px dashed var(--c-border); color: var(--c-ink-3); font-weight: 700; }
.velo { font-size: var(--text-xs); font-weight: 700; color: var(--c-ink-3); }
.vmore { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 40px; margin-top: 4px; border: 1px dashed var(--c-border);
  border-radius: var(--radius-lg, 12px); background: none; font: inherit; font-size: var(--text-sm); font-weight: 700; color: var(--c-ink-2); cursor: pointer; }
.vmore:hover { color: var(--c-ink); border-color: var(--c-brand-text); }
.vmore:disabled { opacity: .6; cursor: progress; }

/* ── Columns + rail ───────────────────────────────────────────────────── */
.rooms-cols { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; margin-top: 20px; align-items: start; }
.rooms-cols.is-rail-min { grid-template-columns: 64px minmax(0, 1fr); }
.rooms-rail { position: sticky; top: calc(56px + var(--rooms-bar-h) + 12px); display: flex; flex-direction: column; box-sizing: border-box;
  max-height: calc(100dvh - 56px - var(--rooms-bar-h) - 28px); border: 1px solid var(--c-border); border-radius: var(--radius-xl, 16px); background: var(--c-surface); }
.rooms-rail__head { display: flex; align-items: flex-start; gap: 8px; padding: 14px 8px 8px 16px; }
.rooms-rail__t { flex: 1; min-width: 0; }
.rooms-rail__t h2 { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.25; color: var(--c-ink); }
.rooms-rail__sub { display: block; font-size: var(--text-xs); font-weight: 700; color: var(--c-brand-text); }
.rooms-rail__search { margin: 0 12px 8px; }
.rooms-rail__list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 4px 8px; }
.rooms-rail .vrow { padding: 6px 10px; }
.rooms-rail .velo { display: none; } /* the rail shows rank; Elo is in the sheet and on the cards */
.is-rail-min .rooms-rail__t, .is-rail-min .rooms-rail__search, .is-rail-min .vrow__n, .is-rail-min .vr, .is-rail-min .vgroup,
.is-rail-min .vmore, .is-rail-min .vrow--empty { display: none; }
.is-rail-min .rooms-rail__head { padding: 10px 0; justify-content: center; }
.is-rail-min .rooms-rail__head .icon { transform: scaleX(-1); }
.is-rail-min .vrow { justify-content: center; padding: 4px 0; }

/* ── 3. Tabs, 4. tools ────────────────────────────────────────────────── */
.rooms-tabs { box-shadow: inset 0 -1px 0 var(--c-border); }   /* inset: the scroller clips children, so the baseline lives inside it */
/* Rule filter reads as real tabs: flat, underline on the active one, the strip's rule is the baseline. */
.rooms-tabs .vtabs { gap: 0; }
.rooms-tabs .vtab { position: relative; min-height: 48px; padding: 0 14px; border-radius: 0; background: none; box-shadow: none; }
.rooms-tabs .vtab:hover { background: none; color: var(--c-ink); }
.rooms-tabs .vtab[aria-selected="true"] { background: none; box-shadow: none; color: var(--c-brand-text); }
.rooms-tabs .vtab::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
.rooms-tabs .vtab:hover::after { background: var(--c-border-strong, var(--c-ink-3)); }
.rooms-tabs .vtab[aria-selected="true"]::after { background: var(--c-brand-text); }
.rooms-tools { display: flex; align-items: center; justify-content: flex-end; margin: 14px 0; }
.rooms-sort { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-sm); font-weight: 700; color: var(--c-ink-2); white-space: nowrap; }
.rooms-rg { margin-top: 20px; }
.rooms-more { margin-top: 12px; }

/* ── 5. Card v3: ID + state + viewers + Vào / two seat lines / time | mode. No board, no "vs", no stripe. ── */
.rooms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.rooms-grid > .vempty { grid-column: 1 / -1; }
/* `.room-row` stays as the e2e hook; the old zen row rules (flex row, 14px 0 padding, pointer, hover fill) must not apply. */
#panel-tables .h-card.room-row { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-width: 0; padding: 10px 14px; cursor: default; container-type: inline-size; border: 1px solid var(--c-border);
  border-radius: var(--radius-lg, 12px); background: var(--c-surface); transition: border-color .15s, box-shadow .15s; }
#panel-tables .h-card.room-row:hover { background: var(--c-surface); border-color: var(--c-border-strong, var(--c-ink-3)); box-shadow: 0 2px 10px color-mix(in srgb, var(--c-ink) 8%, transparent); }
.h-card__top { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; white-space: nowrap; }
.h-card__top .vcode { font-size: var(--text-sm); font-weight: 800; letter-spacing: .06em; color: var(--c-ink-2); }
.h-card__top .vbtn { margin-left: auto; min-height: 30px; min-width: 56px; padding: 0 14px; font-size: var(--text-xs); }
.vstate { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: var(--text-xs); font-weight: 800; white-space: nowrap; }
.vstate::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.vstate.is-open { color: var(--c-state-waiting); } .vstate.is-ready { color: var(--c-time); } .vstate.is-live { color: var(--c-state-playing); }
.h-card__eye { display: inline-flex; align-items: center; gap: 4px; margin-left: 2px; font-size: 12px; font-weight: 700; color: var(--c-ink-3); }
.h-card__eye .icon { width: 14px; height: 14px; }
.h-card__seats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.h-seat { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 30px; }
.h-seat .pav--xs { width: 24px; height: 24px; }
.h-seat__n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); font-weight: 700; color: var(--c-ink); }
.h-seat--empty .h-seat__n { font-weight: 600; font-style: italic; color: var(--c-ink-3); }
.h-seat__hole { width: 24px; height: 24px; box-sizing: border-box; border-radius: 50%; border: 1.5px dashed var(--c-border); }
.ve { display: inline-flex; justify-content: flex-end; flex: none; min-width: 40px; font-size: var(--text-sm); font-weight: 800; color: var(--c-ink); }
.ve--prov { color: var(--c-ink-2); font-weight: 700; }
.ve--none { font-size: var(--text-xs); font-weight: 700; color: var(--c-ink-3); }
/* spec strip: one line, thin CSS dividers between slots (never a "·" string); only the time may shorten */
.h-card__foot { display: flex; align-items: center; min-width: 0; padding-top: 8px; border-top: 1px solid var(--c-border); white-space: nowrap; overflow: hidden; }
.h-spec__i { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 0 10px; font-size: 12px; font-weight: 600; color: var(--c-ink-3); }
.h-spec__i:first-child { padding-left: 0; }
.h-spec__i + .sr-only + .h-spec__i { border-left: 1px solid var(--c-border); }
.h-spec__i .icon { width: 14px; height: 14px; }
.h-spec__time { flex: 0 1 auto; min-width: 0; color: var(--c-ink-2); }
.h-spec__time > span { overflow: hidden; text-overflow: ellipsis; }
@container (max-width: 244px) { .h-card__eye { display: none; } } /* a very narrow card drops the viewer count first */

/* ── 6. Empty tab ─────────────────────────────────────────────────────── */
.vempty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 20px; border: 1px dashed var(--c-border);
  border-radius: var(--radius-xl, 16px); text-align: center; color: var(--c-ink-2); }
.vempty b { font-size: 16px; color: var(--c-ink); }
.vempty .vbtn { margin-top: 10px; }
.vempty > .icon { width: 24px; height: 24px; color: var(--c-ink-3); }

/* ── Phone sheet (roster) ─────────────────────────────────────────────── */
.vsheet { position: fixed; inset: 0; z-index: 40; }
.vsheet__scrim { position: absolute; inset: 0; background: var(--rh-scrim); }
.vsheet__panel { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; max-height: 86dvh; box-sizing: border-box;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); border-width: var(--ctl-bw) 0 0; border-radius: var(--ctl-r-modal) var(--ctl-r-modal) 0 0; }   /* surface: components.css §10 (#543) */
.vsheet__grip { align-self: center; width: 40px; height: 4px; margin: 4px 0 8px; border-radius: 4px; background: var(--c-border-strong); }
.vsheet__head { display: flex; align-items: flex-start; gap: 8px; padding: 0 8px 8px 12px; }
.vsheet__head > div { flex: 1; }
.vsheet__head h2 { margin: 0; font-size: 18px; font-weight: 800; color: var(--c-ink); }
.vsheet__head p { margin: 2px 0 0; font-size: var(--text-sm); color: var(--c-ink-2); }
.vsheet__body { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 4px; }
body.rooms-sheet-open { overflow: hidden; }

/* ── Phone ────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  #panel-tables { --rooms-bar-h: 108px; }
  .rooms-bar { margin: 0 -12px; padding: 10px 12px; gap: 10px 14px; flex-wrap: wrap; }
  #panel-tables .rooms-bar .rooms-bar__people { display: inline-flex; order: 3; }
  .rooms-bar__new { order: 4; margin-left: 0; }
  #panel-tables .rooms-bar__people, #panel-tables .rooms-bar__new { flex: 1 1 40%; }
  .vstat b { font-size: 20px; }
  .rooms-cols { display: block; margin-top: 8px; }
  .rooms-rail { display: none; } /* phones: the roster is the bottom sheet behind "Xem người online" */
  .vtab { padding: 0 10px; font-size: 14px; }
  .vtab--guide { margin-left: 0; }
  .rooms-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .h-card__top .vbtn { min-height: 36px; min-width: 64px; font-size: var(--text-sm); } /* thumb target */
}
@media (min-width: 861px) { .vsheet { display: none; } }

@media (prefers-reduced-motion: reduce) {
  #panel-tables .h-card.room-row { transition: none; }
}
