/* redesign-chrome.css — chrome scoped (sidebar + topbar + page-head) chỉ dùng
   cho các trang redesign, KHÔNG conflict với production CSS. */

/* ===== TOKENS ===== */
.rd-shell {
  --rd-bg: oklch(98% 0.003 80);
  --rd-surface: #ffffff;
  --rd-ink: oklch(18% 0.01 80);
  --rd-ink-2: oklch(35% 0.01 80);
  --rd-ink-3: oklch(52% 0.008 80);
  --rd-ink-4: oklch(68% 0.006 80);
  --rd-line: oklch(91% 0.004 80);
  --rd-line-strong: oklch(85% 0.005 80);
  --rd-surface-2: oklch(97.5% 0.004 80);
  --rd-accent: oklch(48% 0.13 156);
  --rd-accent-soft: oklch(94% 0.04 156);
  --rd-accent-ink: oklch(28% 0.08 156);
  --rd-r-2: 10px;
  --rd-r-3: 14px;
  --rd-shadow-2: 0 1px 2px rgba(15,15,14,0.04), 0 0 0 1px var(--rd-line);
  --rd-sidebar-w: 232px;
  --rd-topbar-h: 60px;
  --rd-font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --rd-font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  font-family: var(--rd-font-sans);
  background: var(--rd-bg);
  color: var(--rd-ink);
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--rd-sidebar-w) 1fr;
  /* KHÔNG transition grid-template-columns — animating grid rất lag.
     Snap instant để mượt. */
}
.rd-shell.rd-collapsed { grid-template-columns: 64px 1fr; }

/* ===== SIDEBAR ===== */
/* .rd-sidebar styles — SYNC chính xác với .sidebar trong redesign.css để 3 trang
   (index / do-luong / tai-khoan) hiển thị sidebar giống nhau hoàn toàn.
   Chỉ khác CSS var namespace: --rd-* (chrome) vs --* (handoff). */
.rd-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--rd-surface);
  border-right: 1px solid var(--rd-line);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 4px;
}
.rd-sidebar .sb-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--rd-r-2, 8px);
  text-decoration: none;
  background: rgba(184,150,110,.08);
  border-left: 3px solid #b8966e;
  color: #b8966e;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 8px;
  transition: background 120ms;
}
.rd-sidebar .sb-back:hover { background: rgba(184,150,110,.16); }
.rd-sidebar .sb-back .sb-icon { width: 14px; height: 14px; }
.rd-sidebar .sb-back .sb-icon svg { width: 14px; height: 14px; }

.rd-sidebar .sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 14px;
  border-bottom: 1px solid var(--rd-line);
  margin-bottom: 10px;
}
.rd-sidebar .sb-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--rd-ink);
  color: var(--rd-bg);
  font-family: var(--rd-font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.rd-sidebar .sb-brand-text { min-width: 0; }
.rd-sidebar .sb-brand-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--rd-ink);
  line-height: 1.1;
}
.rd-sidebar .sb-brand-sub {
  font-size: 11px;
  color: var(--rd-ink-3);
  margin-top: 2px;
}

.rd-sidebar .sb-section {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rd-ink-4);
  padding: 14px 8px 6px;
}
.rd-sidebar .sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--rd-r-2, 8px);
  color: var(--rd-ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition: background 120ms, color 120ms;
}
.rd-sidebar .sb-link:hover { background: var(--rd-surface-2); color: var(--rd-ink); }
.rd-sidebar .sb-link.active {
  background: var(--rd-ink);
  color: var(--rd-bg);
}
.rd-sidebar .sb-link.active .sb-icon svg { stroke: var(--rd-bg); }
.rd-sidebar .sb-icon {
  display: flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
}
.rd-sidebar .sb-icon svg { width: 16px; height: 16px; stroke: currentColor; }
.rd-sidebar .sb-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--rd-accent-soft);
  color: var(--rd-accent-ink);
  letter-spacing: 0.04em;
}
.rd-sidebar .sb-link.active .sb-tag {
  background: rgba(255,255,255,0.15);
  color: var(--rd-bg);
}
.rd-sidebar .sb-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-top: 1px solid var(--rd-line);
}
.rd-sidebar .sb-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--rd-ink);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--rd-font-mono);
  font-size: 12px; font-weight: 600;
}
.rd-sidebar .sb-foot-name { font-size: 12px; font-weight: 600; }
.rd-sidebar .sb-foot-status {
  font-size: 10.5px;
  color: var(--rd-ink-3);
  display: inline-flex; align-items: center; gap: 4px;
}
.rd-sidebar .sb-foot-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--rd-accent);
}

/* ===== MAIN AREA ===== */
.rd-main { min-width: 0; }

/* ===== TOPBAR ===== */
.rd-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--rd-surface);
  border-bottom: 1px solid var(--rd-line);
  height: var(--rd-topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  font-family: var(--rd-font-sans);
}
.rd-topbar .topbar-crumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
}
.rd-topbar .crumb-mute { color: var(--rd-ink-3); }
.rd-topbar .crumb-sep { color: var(--rd-ink-4); }
.rd-topbar .crumb-here { color: var(--rd-ink); font-weight: 600; }
.rd-topbar .topbar-spacer { flex: 1; }
.rd-topbar .topbar-meta {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--rd-ink-3);
}
.rd-topbar .dot-live {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--rd-accent);
  box-shadow: 0 0 0 3px var(--rd-accent-soft);
}
.rd-topbar .rd-icon-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--rd-line);
  background: var(--rd-surface);
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--rd-ink-2);
}
.rd-topbar .rd-icon-btn:hover { background: var(--rd-surface-2); border-color: var(--rd-line-strong); }
.rd-topbar .rd-icon-btn svg { width: 16px; height: 16px; }
/* Safeguards pill cũ trong topbar — copy production style cho consistency */
.rd-topbar #safeguards-badge { display: inline-flex; align-items: center; }

/* ===== PAGE ===== */
.rd-page {
  padding: 24px 24px 48px;
  font-family: var(--rd-font-sans);
}
.rd-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.rd-page-head .rd-page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.015em;
}
.rd-page-head .rd-page-sub {
  font-size: 13px;
  color: var(--rd-ink-3);
  margin: 4px 0 0;
  max-width: 720px;
}

/* Full-width page — override .container max-width khi kèm .rd-page */
.rd-shell .container,
.rd-shell .rd-page.container,
.rd-page.container { max-width: none; }

/* Defensive: ép [hidden] = none, tránh display:flex/grid override */
.rd-shell .bp-filter-bar[hidden],
.rd-shell [hidden] { display: none !important; }

/* Kill sticky verdict bar + summary row + bp-filter-bar — tránh pile up */
.rd-shell .dl-verdict-bar,
.rd-shell .dl-table tbody tr.summary-row td,
.rd-shell .bp-filter-bar {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
}

/* Table header KHÔNG sticky — overflow-x auto trên container conflict với sticky */
.rd-shell .dl-table thead,
.rd-shell .dl-table thead th {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
}

/* Reset extra styling cũ của sticky verdict bar (margin/padding âm để mở rộng bg) */
.rd-shell .dl-verdict-bar {
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  border-bottom: none !important;
}

/* .dl-toolbar (date filter) — chỉ element duy nhất sticky trong content */
.rd-shell .dl-toolbar {
  z-index: 20 !important;
}

/* Compact mode — thu nhỏ toàn bộ content trong rd-page (do-luong-new) ~85% */
.rd-shell .rd-page {
  zoom: 0.85;
}

/* Table scroll: bỏ max-height + cuộn dọc, GIỮ cuộn ngang để table 16+ cột không tràn */
.rd-shell .dl-table-scroll {
  max-height: none !important;
  overflow-y: visible !important;
  overflow-x: auto !important;
}
.rd-shell #dl-table-wrap,
.rd-shell #dl-bypost-wrap {
  min-height: 0 !important;
  overflow-y: visible !important;
  overflow-x: auto !important;
  max-width: 100%;
}

/* Global font cho redesign (apply lên all content trong .rd-shell) */
.rd-shell, .rd-shell input, .rd-shell button, .rd-shell select, .rd-shell textarea {
  font-family: var(--rd-font-sans);
}
.rd-shell .mono, .rd-shell .tnum,
.rd-shell input[type="number"], .rd-shell input[type="date"] {
  font-variant-numeric: tabular-nums;
}

/* ===== SIDEBAR TOGGLE (thu gọn / mở rộng) — inline flex item, dễ thấy ===== */
.rd-sidebar-toggle {
  align-self: flex-end;
  width: 28px; height: 28px;
  border: 1px solid var(--rd-line);
  background: var(--rd-surface);
  color: var(--rd-ink-2);
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: 8px;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.rd-sidebar-toggle:hover {
  background: var(--rd-accent-soft);
  border-color: var(--rd-accent);
  color: var(--rd-accent-ink);
}

/* Collapsed state — hỗ trợ CẢ 2 layout: .rd-shell + .rd-sidebar VÀ .app + .sidebar */
.rd-shell.rd-collapsed { grid-template-columns: 64px 1fr; }
.app.rd-collapsed { grid-template-columns: 64px 1fr; }

.rd-shell.rd-collapsed .rd-sidebar,
.app.rd-collapsed .sidebar {
  padding: 16px 6px 12px;
}
.rd-shell.rd-collapsed .sb-back > span:last-child,
.rd-shell.rd-collapsed .sb-brand-text,
.rd-shell.rd-collapsed .sb-section,
.rd-shell.rd-collapsed .sb-link > span:not(.sb-icon):not(.sb-tag),
.rd-shell.rd-collapsed .sb-tag,
.rd-shell.rd-collapsed .sb-foot > div:last-child,
.app.rd-collapsed .sb-back > span:last-child,
.app.rd-collapsed .sb-brand-text,
.app.rd-collapsed .sb-section,
.app.rd-collapsed .sb-link > span:not(.sb-icon):not(.sb-tag),
.app.rd-collapsed .sb-tag,
.app.rd-collapsed .sb-foot > div:last-child {
  display: none !important;
}
.rd-shell.rd-collapsed .sb-back,
.rd-shell.rd-collapsed .sb-link,
.app.rd-collapsed .sb-back,
.app.rd-collapsed .sb-link {
  justify-content: center;
  padding: 8px;
}
.rd-shell.rd-collapsed .sb-brand,
.app.rd-collapsed .sb-brand {
  justify-content: center;
  padding: 8px 0;
}
.rd-shell.rd-collapsed .sb-foot,
.app.rd-collapsed .sb-foot {
  justify-content: center;
  padding: 12px 0;
}
.rd-shell.rd-collapsed .rd-sidebar-toggle,
.app.rd-collapsed .rd-sidebar-toggle {
  align-self: center;
}

@media (max-width: 1000px) {
  .rd-shell { grid-template-columns: 1fr; }
  .rd-sidebar { display: none; }
}
