/* ============================================================================
   RP2 REPORT — CHECK-BRAND + GUIDE + STAFF DASHBOARD POLISH
   ----------------------------------------------------------------------------
   Load AFTER liquidglass.css / sidebar.css (dùng :root tokens, có fallback).
   Phạm vi file này (staff index.html):
     1. #/check  — "Kiểm tra brand" bố cục kiểu Google: search nổi bật + grid cân
     2. .brand-detail — trang chi tiết brand thoáng, cân đối, 3 tab giữ chức năng
     3. #/guide  — panel Cẩm nang (mục lục trái + nội dung phải)
     4. Chrome nhỏ: footer trong .main, ô search, empty state
   KHÔNG chứa logic — chỉ trình bày. Skin = CaMell v6.3 Liquid Glass.
   ============================================================================ */

/* ========================= 1. KIỂM TRA BRAND (#/check) ==================== */

/* view check + guide cần bề ngang dashboard (grid 3 cột / mục lục 2 cột) —
   nới container CHỈ khi đang chứa 2 view này, các view cũ giữ nguyên 640px */
.container:has(> .check-view),
.container:has(> .guide-view) {
  max-width: var(--maxw-wide, 1160px);
}

/* hero — canh giữa như trang chủ Google: nhiều khoảng trắng, phân cấp rõ */
.check-hero {
  text-align: center;
  padding: clamp(16px, 4vw, 48px) 12px clamp(8px, 2vw, 20px);
}
.check-hero .eyebrow { justify-content: center; }
.check-hero .h1 {
  margin-top: 6px;
  font-size: clamp(24px, 3.4vw, 34px);
  letter-spacing: -.02em;
}
.check-hero__sub {
  max-width: 520px;
  margin: 10px auto 0;
  line-height: 1.55;
}

/* thanh tìm — pill kính lớn, nổi bật (kiểu Google search bar) */
.check-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(640px, 100%);
  margin: clamp(16px, 3vw, 28px) auto 0;
  padding: 0 18px;
  height: 52px;
  border-radius: 999px;
  cursor: text;
  background: var(--glass-bg, rgba(16, 24, 38, .48));
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid var(--lg-border-subtle, rgba(255, 255, 255, .19));
  box-shadow: var(--shadow-soft, 0 4px 16px rgba(0, 0, 0, .35));
  transition:
    border-color 250ms var(--ease, ease),
    box-shadow 250ms var(--ease, ease),
    transform 250ms var(--lg-spring, cubic-bezier(.34, 1.56, .64, 1));
}
.check-search:hover {
  border-color: var(--glass-hi, rgba(255, 255, 255, .33));
  box-shadow: var(--shadow-deep, 0 8px 24px rgba(0, 0, 0, .42));
}
.check-search:focus-within {
  border-color: var(--accent, #60AFFF);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, .42),
    0 0 0 3px rgba(96, 175, 255, .22),
    0 0 14px rgba(0, 232, 255, .18);
}
.check-search__ico {
  font-size: 16px;
  opacity: .75;
  flex: 0 0 auto;
}
.check-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text, #FAFAFF);
  font: inherit;
  font-size: 15px;
}
.check-search input::placeholder { color: var(--text-3, #CCD0E8); opacity: .65; }
.check-search input::-webkit-search-cancel-button { filter: invert(1) opacity(.6); }

/* hàng tiêu đề grid — kéo vào cùng khối, không lệch */
.check-headrow { margin-top: 4px; }

/* grid brand — auto-fit cân đều, canh giữa, không lệch cột cuối */
.brand-grid.brand-grid--check {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--cardgap, 14px);
  justify-content: center;
  align-items: stretch;
}
.brand-grid--check .brand-card { width: 100%; }

/* empty state của kết quả tìm */
.check-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 16px;
}

/* ===================== 2. CHI TIẾT BRAND (.brand-detail) ================== */
/* Giữ NGUYÊN cấu trúc + id/data-hook — chỉ nới khoảng trắng và cân đối. */

.brand-detail { gap: var(--s4, 16px); }

/* header brand: thoáng hơn, tiêu đề lớn rõ phân cấp.
   Cap+center to the SAME 820px column as the panels/cards below so the H1's left edge
   lines up with the card edges (was full-width → H1 sat ~20px left of the cards). */
.brand-detail > .row:first-child { padding: 4px 2px 0; width: min(820px, 100%); margin-inline: auto; }
.brand-detail #brand-title {
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -.02em;
}

/* 3 tab segmented — canh giữa như thanh chip Google, không dàn sát trái */
.brand-detail .segmented[role="tablist"] {
  /* .segmented is display:flex, so align-self/margin:auto could not center it and max-width:100%
     did not cap it — the tablist ran full-width. Cap to the 820px column like header+panels. */
  width: min(820px, 100%);
  margin: 2px auto 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.brand-detail .segmented[role="tablist"]::-webkit-scrollbar { display: none; }
.brand-detail .segmented button { padding: 8px 18px; white-space: nowrap; }

/* panel nội dung: giới hạn bề ngang dễ đọc + canh giữa, nhiều không khí */
.brand-detail [data-panel] {
  width: min(820px, 100%);
  margin: 0 auto;
  gap: var(--s3, 12px);
}
.brand-detail [data-panel] > .row:first-child { padding: 0 2px; }

/* domain card thở hơn một chút */
.brand-detail .domain-row { padding-block: 4px; }
.brand-detail .domain-row__body { padding-top: 2px; }

/* submit bar cũng theo cùng bề ngang đọc được */
.brand-detail .submit-bar {
  width: min(820px, 100%);
  margin-left: auto;
  margin-right: auto;
}

/* ========================== 3. CẨM NANG (#/guide) ========================= */

.guide-layout {
  display: grid;
  /* minmax(0,1fr) not plain 1fr: a bare 1fr column is min-width:auto, so a long unwrapped
     TOC link forces the column (and the page) wider than the viewport on mobile. */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4, 16px);
  align-items: start;
}
.guide-layout > * { min-width: 0; }
@media (min-width: 900px) {
  .guide-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .guide-toc-card {
    position: sticky;
    top: calc(var(--s4, 16px) + 56px);   /* dưới app-header sticky */
    max-height: calc(100dvh - 140px);
    overflow-y: auto;
  }
}
.guide-toc { display: flex; flex-direction: column; gap: 2px; }
.guide-toc__link {
  display: block;
  padding: 6px 10px;
  border-radius: var(--r-md, 10px);
  color: var(--text-3, #CCD0E8);
  font-size: 12.5px;
  text-decoration: none;
  line-height: 1.4;
  overflow-wrap: anywhere;   /* long section titles wrap instead of forcing sideways scroll */
  transition:
    background 250ms var(--ease, ease),
    color 250ms var(--ease, ease),
    transform 250ms var(--lg-spring, cubic-bezier(.34, 1.56, .64, 1));
}
.guide-toc__link:hover {
  background: rgba(255, 255, 255, .09);
  color: var(--text, #FAFAFF);
  transform: translateX(3px);
}
.guide-toc__link--sub { padding-left: 22px; font-size: 12px; opacity: .9; }

/* nội dung guide — typography đọc dài thoải mái */
.guide-body { line-height: 1.65; font-size: 14px; }
.guide-body > :first-child { margin-top: 0; }
.guide-body h2 {
  margin: 26px 0 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.01em;
  scroll-margin-top: 76px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.guide-body h3 {
  margin: 18px 0 8px;
  font-size: 15px;
  font-weight: 600;
  scroll-margin-top: 76px;
  color: var(--accent-2, #7DB5FF);
}
.guide-body p { margin: 8px 0; color: var(--text-2, #E4E6F4); }
.guide-body ul, .guide-body ol { margin: 8px 0 8px 20px; padding: 0; }
.guide-body li { margin: 4px 0; color: var(--text-2, #E4E6F4); }
.guide-body strong { color: var(--text, #FAFAFF); }
.guide-body a { color: var(--accent, #60AFFF); }
.guide-body code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
}
.guide-body table {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: 13px;
}
.guide-body th, .guide-body td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.guide-body th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--lg-cyan, #00E8FF);
}
.guide-body blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent, #60AFFF);
  border-radius: 0 10px 10px 0;
  background: rgba(96, 175, 255, .08);
  color: var(--text-2, #E4E6F4);
}

/* ========================= 4. CHROME NHỎ (shell staff) ==================== */

/* footer nằm trong .main (sidebar layout) — đẩy xuống đáy khi view ngắn */
.shell > .main > .app-main { flex: 1; }

/* iOS-spring nhẹ cho thẻ brand ở grid check (đồng bộ skin v6.3) */
@media (hover: hover) {
  .brand-grid--check .brand-card:hover { transform: scale(1.045); }
  .brand-grid--check .brand-card:active { transform: scale(1.01); }
}

/* ============ 6. THỨ HẠNG GOOGLE DÂN CƯ — kiểu Google SERP ================ */
/* Mỗi dòng = 1 kết quả Google THẬT, xếp đúng thứ tự Google:
   URL breadcrumb (xanh lá) → tiêu đề (link xanh dương lớn) → mô tả (snippet)
   → khác Google ở: badge địch/nhà + nút đăng ký/đăng nhập → hậu đài (🟢 nhà / 🔴 địch). */

.serp-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px 14px;
  padding: 14px 16px;
  border-left: 3px solid transparent;
  border-radius: 12px;
  transition: background 200ms var(--ease, ease);
}
.serp-row:hover { background: rgba(255, 255, 255, .035); }
/* dải màu trái + chấm hạng: đỏ = địch, xanh = nhà */
.serp-row[data-label="foreign"] { border-left-color: rgba(255, 69, 58, .5); }
.serp-row[data-label="own"]     { border-left-color: rgba(48, 209, 88, .5); }

.serp-row__rank {
  grid-row: 1 / span 4;
  align-self: start;
  min-width: 28px;
  height: 28px;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--lg-border-subtle, rgba(255, 255, 255, .16));
  color: var(--text-2, #E4E6F4);
}
.serp-row[data-label="foreign"] .serp-row__rank { color: #ff9c9c; border-color: rgba(255,69,58,.32); }
.serp-row[data-label="own"]     .serp-row__rank { color: #7ee89a; border-color: rgba(48,209,88,.32); }

.serp-row__main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.serp-row__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* ⚠️ đối chiếu — hàng có brand key: nhắc NV check kỹ hậu đài/logo (địch nhái brand key) */
.serp-warn {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; line-height: 1; white-space: nowrap;
  padding: 3px 8px; border-radius: 999px; cursor: help;
  /* dùng token --warn chung với .badge--warn/.pill--draft/.sev--med… để cùng một sắc vàng cảnh báo */
  color: var(--warn, #ffcf70);
  background: var(--warn-soft, rgba(254, 240, 112, .13));
  border: 1px solid rgba(254, 240, 112, .4);
}
/* breadcrumb URL — xanh lá kiểu Google */
.serp-row__crumb {
  font-size: 12.5px;
  color: #86e0a6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
/* tiêu đề — link xanh dương lớn kiểu Google, hiện đầy đủ (tự xuống dòng) */
.serp-row__title {
  font-size: 18px;
  line-height: 1.32;
  font-weight: 500;
  color: var(--serp-title, #8ab4f8);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.serp-row__title:hover { text-decoration: underline; }
.serp-row__title:visited { color: #c58af9; }
.serp-row__title--plain { color: var(--text, #FAFAFF); pointer-events: none; }
/* mô tả (snippet / meta description) — xám, tối đa 3 dòng như Google */
.serp-row__desc {
  margin: 2px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-3, #C6CAE0);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
/* hàng CTA đăng ký/đăng nhập → hậu đài */
.serp-row__cta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.hd-cta__prefix { font-size: 11.5px; color: var(--text-3, #C6CAE0); opacity: .8; margin-right: 2px; }
.hd-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.5;
  text-decoration: none;
  border: 1px solid transparent;
}
.hd-cta::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.hd-cta__tag { font-weight: 700; }
.hd-cta__dom { color: var(--text-2, #E4E6F4); opacity: .82; overflow-wrap: anywhere; }
a.hd-cta:hover { text-decoration: underline; }
.hd-cta--own {
  background: var(--success-soft, rgba(48, 209, 88, .14));
  border-color: rgba(48, 209, 88, .38);
}
.hd-cta--own::before { background: #30d158; }
.hd-cta--own .hd-cta__tag { color: #7ee89a; }
.hd-cta--foreign {
  background: var(--danger-soft, rgba(255, 69, 58, .14));
  border-color: rgba(255, 69, 58, .4);
}
.hd-cta--foreign::before { background: #ff453a; }
.hd-cta--foreign .hd-cta__tag { color: #ff8f88; }

.serp-row__add { align-self: start; margin-top: 2px; white-space: nowrap; }

/* nút lọc địch/ta đang bật (aria-pressed) — nổi bật hơn trạng thái ghost */
[data-users-filter][aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--accent, #60AFFF); }

/* hẹp (mobile): rank về cùng hàng meta, CTA xuống dòng gọn */
@media (max-width: 560px) {
  .serp-row { grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; padding: 12px; }
  .serp-row__add { grid-column: 2; justify-self: start; }
  .serp-row__title { font-size: 16px; }
}

/* ========================= 5. REDUCED MOTION ============================== */
@media (prefers-reduced-motion: reduce) {
  .check-search, .guide-toc__link, .brand-grid--check .brand-card { transition: none; }
  .guide-toc__link:hover { transform: none; }
  .brand-grid--check .brand-card:hover,
  .brand-grid--check .brand-card:active { transform: none; }
  .serp-row { transition: none; }
}
