/* =====================================================================
 * docs-proto.css — MODULE "TÀI LIỆU" · UI SHELL V1 (FORM=WEBAPP-TAI-LIEU-UI-SHELL-V1-01)
 *
 * Nạp SAU styles.css. Tiền tố .dc- · CHỈ dùng token :root đã có (WEBAPP_DESIGN_SYSTEM_V1 B0/B10).
 * Primitive dùng lại nguyên bản: .page-header · .panel · .tab · .btn · .tag · table.data · .ds-banner · .ds-empty.
 * ⛔ Không định nghĩa lại primitive chung ở đây. ⛔ Không @media prefers-color-scheme (THEME_V1 = LIGHT_ONLY).
 * Mốc nội dung riêng của module: 860px (danh sách ↔ chi tiết một cột). Mốc khung dùng đúng PHẦN D.
 * ===================================================================== */

.dc-mod {
  --dc-side-w: 330px;        /* bề rộng cột chọn/lọc — một chỗ duy nhất */
  --dc-icon-box: 36px;       /* ô biểu tượng tệp ở danh sách */
  --dc-icon-box-lg: 44px;    /* = .page-icon — ô biểu tượng ở đầu chi tiết */
  display: flex; flex-direction: column; gap: var(--space-3); min-width: 0;
}

/* ---- Đầu module ---- */
.dc-page-header { flex-wrap: wrap; }
.dc-page-header h1 { line-height: var(--line-tight); }
.dc-header-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.dc-header-note { font-size: var(--font-meta); color: var(--text-muted); }

/* ---- Hàng tab — vỏ DÍNH tầng 3 (B6), không tự cộng offset ---- */
.dc-shell { position: sticky; top: var(--sticky-module-top); z-index: var(--sticky-z-module);
  background: var(--bg-app); padding: var(--space-1) 0 0; box-shadow: var(--sticky-edge); }
.dc-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-soft);
  overflow-x: auto; scrollbar-width: thin; min-width: 0; }
.dc-tabs .tab { flex: none; display: inline-flex; align-items: center; gap: var(--space-1); }
.dc-tab-no { font-size: var(--font-meta); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.dc-tabs .tab.active .dc-tab-no { color: var(--brand-primary-hover); }

/* ---- Dòng giới thiệu workspace: trả lời "khu này để làm gì" + hành động chính (≤ 1) ---- */
.dc-intro { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  background: var(--bg-surface); border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-sm); }
.dc-intro-ic { width: var(--dc-icon-box); height: var(--dc-icon-box); border-radius: var(--radius-md);
  display: grid; place-items: center; font-size: var(--text-xl); background: var(--brand-primary-soft); flex: none; }
.dc-intro-text { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dc-intro-text b { font-size: var(--font-card-title); color: var(--text-primary); }
.dc-intro-text span { font-size: var(--font-help); color: var(--text-secondary); line-height: var(--line-normal); }

/* ---- Khung 2 cột: trái CHỌN/LỌC/DANH SÁCH · phải CHI TIẾT/HÀNH ĐỘNG ---- */
.dc-split { display: grid; grid-template-columns: minmax(0, var(--dc-side-w)) minmax(0, 1fr);
  gap: var(--space-3); align-items: start; min-width: 0; }
.dc-side, .dc-detail { min-width: 0; }
.dc-side { gap: var(--space-2); position: sticky; top: calc(var(--sticky-module-top) + var(--control-h) + var(--space-5));
  max-height: calc(100dvh - var(--sticky-module-top) - var(--control-h) - var(--space-8));
  overflow-y: auto; scrollbar-width: thin; }
.dc-detail { gap: var(--space-3); }
.dc-side-label { font-size: var(--font-meta); font-weight: var(--weight-semibold); color: var(--text-secondary);
  display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-1); }
.dc-count { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center;
  background: var(--bg-subtle); color: var(--text-secondary); font-size: var(--font-meta); font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums; }

/* Ô tìm kiếm + bộ lọc (B8) */
.dc-search { display: flex; align-items: center; gap: var(--space-2); height: var(--control-h);
  border: 1px solid var(--border-default); border-radius: var(--control-radius); padding: 0 var(--space-3);
  background: var(--bg-surface); flex: none; }
.dc-search:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--brand-primary-soft); }
.dc-search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0;
  font-size: var(--font-body); color: var(--text-primary); font-family: inherit; }
.dc-search input::placeholder { color: var(--text-disabled); }
.dc-filters { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); flex: none; }
.dc-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dc-field > span { font-size: var(--font-meta); color: var(--text-secondary); font-weight: var(--weight-medium); }
.dc-field select, .dc-field textarea { height: var(--control-h); border: 1px solid var(--border-default);
  border-radius: var(--control-radius); padding: 0 var(--space-2); font-size: var(--font-body); font-family: inherit;
  background: var(--bg-surface); color: var(--text-primary); min-width: 0; max-width: 100%; }
.dc-field textarea { height: auto; padding: var(--space-2); resize: vertical; }
.dc-field-full { width: 100%; }

/* V1-02 · NGUỒN (Thư viện) — nút phân đoạn: Tất cả · Hệ thống sinh ra · Người dùng tải lên.
   "AI được phép sử dụng" KHÔNG còn là nhóm ở đây — nó là bộ lọc thuộc tính. */
.dc-seg { display: flex; flex-wrap: wrap; gap: var(--space-1); flex: none; }
.dc-seg-btn { display: inline-flex; align-items: center; gap: var(--space-1); height: var(--control-h-sm);
  padding: 0 var(--space-2); border-radius: var(--control-radius); cursor: pointer;
  border: 1px solid var(--border-default); background: var(--bg-surface); color: var(--text-secondary);
  font: inherit; font-size: var(--font-meta); font-weight: var(--weight-medium); white-space: nowrap; }
.dc-seg-btn:hover { background: var(--bg-surface-soft); color: var(--text-primary); }
.dc-seg-btn.is-active { background: var(--brand-primary-soft); border-color: var(--brand-primary); color: var(--brand-primary-hover); font-weight: var(--weight-semibold); }
.dc-clear { margin-left: auto; font-size: var(--font-meta); }

/* V1-02 · Dải tổng quan GỌN bên trong Thư viện (không phải tab riêng). Mỗi ô = một lọc nhanh. */
.dc-overview { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.dc-ov { display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-h);
  padding: 0 var(--space-3); border-radius: var(--radius-md); cursor: pointer;
  border: 1px solid var(--border-soft); background: var(--bg-surface); box-shadow: var(--shadow-sm);
  font: inherit; font-size: var(--font-body); color: var(--text-primary); white-space: nowrap; }
.dc-ov:hover { background: var(--bg-surface-soft); }
.dc-ov.is-active { background: var(--brand-primary-soft); border-color: var(--brand-primary); }
.dc-ov-lb { color: var(--text-secondary); font-weight: var(--weight-medium); }
.dc-ov-n { font-size: var(--font-card-title); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.dc-ov-demo { margin-left: auto; }

/* Chip nhóm (Học & Hướng dẫn) */
.dc-chips { display: flex; flex-wrap: wrap; gap: var(--space-1); flex: none; }
.dc-chip { height: var(--control-h-sm); padding: 0 var(--space-3); border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-default); background: var(--bg-surface); color: var(--text-secondary);
  font: inherit; font-size: var(--font-meta); font-weight: var(--weight-medium); }
.dc-chip:hover { color: var(--text-primary); background: var(--bg-surface-soft); }
.dc-chip.is-active { background: var(--brand-primary-soft); border-color: var(--brand-primary); color: var(--brand-primary-hover); font-weight: var(--weight-semibold); }

/* Danh sách — cột trái cuộn CHUNG (tìm kiếm + nhóm + danh sách) trong khung dính của nó */
.dc-list { display: flex; flex-direction: column; gap: 2px; flex: none; }
.dc-item { display: flex; align-items: flex-start; gap: var(--space-2); width: 100%; text-align: left;
  border: 0; border-left: 3px solid transparent; background: transparent; border-radius: var(--radius-sm);
  padding: var(--space-2); cursor: pointer; font: inherit; color: var(--text-primary); }
.dc-item:hover { background: var(--bg-surface-soft); }
.dc-item.is-active { background: var(--brand-primary-soft); border-left-color: var(--brand-primary); }
.dc-ficon { width: var(--dc-icon-box); height: var(--dc-icon-box); flex: none; border-radius: var(--radius-sm);
  display: grid; place-items: center; background: var(--bg-subtle); font-size: var(--text-lg); }
.dc-item-main { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; flex: 1; }
.dc-item-title { font-size: var(--font-body); font-weight: var(--weight-semibold); line-height: var(--line-normal);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dc-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2);
  font-size: var(--font-meta); color: var(--text-muted); }
.dc-gtag { white-space: nowrap; }

/* ---- Chi tiết ---- */
.dc-back { display: none; align-self: flex-start; }
.dc-dhead { display: flex; align-items: flex-start; gap: var(--space-3); }
.dc-dhead-row { justify-content: space-between; flex-wrap: wrap; align-items: center; }
.dc-dhead-ic { width: var(--dc-icon-box-lg); height: var(--dc-icon-box-lg); flex: none; border-radius: var(--radius-md);
  display: grid; place-items: center; background: var(--brand-primary-soft); font-size: var(--text-2xl); }
.dc-dhead-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: var(--space-2); }
.dc-dtitle { margin: 0; font-size: var(--font-section-title); font-weight: var(--weight-bold); color: var(--text-primary); line-height: var(--line-tight); }
.dc-dtags { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.dc-code { font-size: var(--font-meta); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.dc-desc { margin: 0; font-size: var(--text-lg); color: var(--text-secondary); line-height: var(--line-relaxed); }
.dc-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.dc-sec-title { font-size: var(--font-card-title); font-weight: var(--weight-semibold); color: var(--text-primary);
  display: flex; align-items: center; gap: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--bg-subtle); }
.dc-muted { color: var(--text-muted); font-size: var(--font-help); }

.dc-kv { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-2) var(--space-4); }
.dc-kv-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dc-kv dt { font-size: var(--font-meta); color: var(--text-muted); }
.dc-kv dd { margin: 0; font-size: var(--font-body); color: var(--text-primary); font-weight: var(--weight-medium); overflow-wrap: anywhere; }

.dc-links { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); }
.dc-link { text-align: left; }

.dc-note { font-size: var(--font-help); color: var(--text-secondary); line-height: var(--line-normal);
  background: var(--bg-surface-soft); border: 1px solid var(--border-soft); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); }
.dc-sec-note { font-size: var(--font-meta); font-weight: var(--weight-normal); color: var(--text-muted); }
.dc-yes { color: var(--status-success); font-weight: var(--weight-semibold); }
.dc-mini { padding: 1px 6px; }
.dc-sub { display: flex; align-items: center; gap: var(--space-2); }
.dc-ai-row { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: var(--font-body); }
.dc-kv-inline { display: inline-flex; align-items: center; gap: var(--space-2); }
/* Phạm vi AI — VỎ giao diện: chip không bấm được, "is-on" = phạm vi đang áp cho tài liệu */
.dc-scope { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.dc-scope-chip { display: inline-flex; align-items: center; height: var(--control-h-sm); padding: 0 var(--space-2);
  border-radius: 999px; border: 1px dashed var(--border-strong); background: var(--bg-surface-soft);
  font-size: var(--font-meta); color: var(--text-muted); white-space: nowrap; }
.dc-scope-chip.is-on { border-style: solid; border-color: var(--status-ai-soft); background: var(--status-ai-soft); color: var(--status-ai); font-weight: var(--weight-semibold); }
.dc-plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--font-body); }
.dc-link-static { font-size: var(--font-body); color: var(--text-secondary); }
.dc-history { margin: 0; padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--font-body); }
/* Ma trận quyền: hai tầng đầu bảng — mỗi vai có HAI cột Xem | Tải (Xem ≠ Tải xuống) */
.dc-perm-table th.dc-th-group { text-align: center; border-left: 1px solid var(--border-default); }
.dc-perm-table th.dc-th-sub { text-align: center; text-transform: none; letter-spacing: 0; }
.dc-perm-table th.dc-th-sub:nth-child(odd), .dc-perm-table td.dc-perm-view { border-left: 1px solid var(--border-soft); }
.dc-perm-table td.dc-perm-view, .dc-perm-table td.dc-perm-dl { text-align: center; }
.dc-banner { margin: 0; }

.dc-preview { display: flex; align-items: center; gap: var(--space-3); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md); background: var(--bg-surface-soft); padding: var(--space-4); font-size: var(--font-body); }
.dc-preview > span { font-size: var(--text-metric); }

.dc-table-wrap { overflow-x: auto; min-width: 0; border: 1px solid var(--border-soft); border-radius: var(--radius-md); }
.dc-table { min-width: 560px; }
.dc-table td { vertical-align: middle; }
.dc-table .tag { white-space: nowrap; }
.dc-table .dc-code { display: block; }
/* Quản trị: bảng nhiều cột thao tác ⇒ cột chọn nhóm cấu hình hẹp hơn để bảng vừa khung desktop */
.dc-split[data-ws="admin"] { --dc-side-w: 270px; }
.dc-filters-stack { grid-template-columns: minmax(0, 1fr); }
.dc-row-acts { white-space: nowrap; }
.dc-row-acts .btn + .btn { margin-left: var(--space-1); }
.dc-row-muted td { color: var(--text-muted); }
.dc-shell-note { font-style: italic; }

/* Khối AI hỗ trợ (Catalog) — tím = AI (C3), chỉ là VỎ */
.dc-ai-box { display: flex; flex-direction: column; gap: var(--space-2); border: 1px solid var(--status-ai-soft);
  background: linear-gradient(0deg, var(--bg-surface), var(--status-ai-soft)); border-radius: var(--radius-md); padding: var(--space-3); }
.dc-ai-head { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.dc-ai-text { font-size: var(--font-help); color: var(--text-secondary); line-height: var(--line-normal); }

.dc-outline { margin: 0; padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1);
  font-size: var(--font-body); color: var(--text-primary); }
.dc-notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.dc-notes li { border-left: 3px solid var(--border-strong); padding: var(--space-1) var(--space-3); font-size: var(--font-body); }
.dc-note-meta { font-size: var(--font-meta); color: var(--text-muted); }
.dc-empty { padding: var(--space-6) var(--space-3); }

/* Thông báo nổi (UI shell) — dưới nền mờ ngăn kéo (90), trên vỏ module */
.dc-toast { position: fixed; left: 50%; bottom: var(--space-6); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text-primary); color: var(--text-inverse); padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--font-body); box-shadow: var(--shadow-floating); z-index: 85; max-width: min(520px, calc(100vw - var(--space-8)));
  transition: opacity .18s, transform .18s; }
.dc-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---- WEBAPP-DOCUMENT-UI-REAL-API-CUTOVER-V1-01 · trạng thái tải/lỗi · quy trình · tải lên · xem trước · biểu mẫu (docs-live.js) ----
   Chỉ token :root. Khối này đứng TRƯỚC các @media để các mốc responsive bên dưới vẫn thắng (bài học thứ tự CSS). */
.dc-state { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-4); color: var(--text-muted); font-size: var(--font-meta); }
.dc-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-soft); border-top-color: var(--brand-primary); animation: dc-spin 0.8s linear infinite; flex: none; }
@keyframes dc-spin { to { transform: rotate(360deg); } }
.dc-pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding-top: var(--space-2); font-size: var(--font-meta); }
.dc-wf { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.dc-wf-row { border: 1px solid var(--border-soft); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); font-size: var(--font-meta); }
.dc-wf-row .tag { margin-left: 2px; }
.dc-wf-op { border: 1px dashed var(--border-soft); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); margin: var(--space-2) 0; font-size: var(--font-meta);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.dc-progress { width: 160px; height: 8px; }
.dc-actions-sm { margin-top: var(--space-2); }
.dc-file-btn { cursor: pointer; }
.dc-actions a.btn { text-decoration: none; }
.dc-preview-box { min-height: 320px; display: flex; align-items: center; justify-content: center; background: var(--bg-subtle); border-radius: var(--radius-md); }
.dc-preview-img { max-width: 100%; max-height: 70vh; object-fit: contain; }
.dc-preview-frame { width: 100%; height: 70vh; border: 0; border-radius: var(--radius-md); }
.modal-card.dc-modal-wide { max-width: min(960px, 100%); }
.dc-form-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); }
.dc-check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--font-meta); cursor: pointer; }
.dc-perm-pick { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.dc-req { color: var(--status-danger); }
.dc-form-msg { color: var(--status-danger); font-size: var(--font-meta); min-height: 1em; }
.dc-toast[data-kind="err"] { border-left: 4px solid var(--status-danger); }
.dc-toast[data-kind="ok"] { border-left: 4px solid var(--status-success); }

/* ---- Máy tính bảng / cửa sổ hẹp ---- */
@media (max-width: 1180px) {
  .dc-mod { --dc-side-w: 290px; }
}
/* ---- ≤860px: MỘT cột. Danh sách ↔ chi tiết chuyển bằng data-view (nút "← Danh sách"). ---- */
@media (max-width: 860px) {
  .dc-split { grid-template-columns: minmax(0, 1fr); }
  .dc-side { position: static; max-height: none; overflow: visible; }
  .dc-split[data-view="list"] .dc-detail { display: none; }
  .dc-split[data-view="detail"] .dc-side { display: none; }
  .dc-back { display: inline-flex; }
  /* V1-02: 4 workspace PHẢI nhìn thấy cùng lúc ở mọi khổ hẹp (đo 768px: tab 04 bị giấu sau thanh cuộn) ⇒ lưới 2×2.
     Hàng tab thôi dính để không chiếm chỗ khi cuộn. */
  .dc-shell { position: static; box-shadow: none; }
  .dc-tabs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); overflow: visible; gap: 0 var(--space-1); }
  .dc-tabs .tab { padding: var(--space-2); white-space: normal; text-align: left; align-items: flex-start; line-height: var(--line-tight); }
}
@media (max-width: 640px) {
  .dc-page-header { padding: var(--space-3) var(--space-4); }
  .dc-filters { grid-template-columns: minmax(0, 1fr); }
  .dc-intro { padding: var(--space-3); }
  .dc-intro .btn-primary { width: 100%; }
  /* Dải tổng quan: MỘT hàng cuộn ngang TRONG khung (tiền lệ CRM §63) — xếp dòng thì cao ~160px. */
  .dc-overview { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .dc-overview::-webkit-scrollbar { display: none; }
  .dc-ov { flex: none; }
  .dc-ov-demo { flex: none; }
  .dc-kv { grid-template-columns: minmax(0, 1fr); }
  .dc-form-2 { grid-template-columns: minmax(0, 1fr); }
  .dc-progress { width: 100%; }
}
