/* STS Browser — bảng hồ sơ chi tiết (profile_list.js): cột tùy chỉnh, sắp xếp, bộ lọc nâng cao + chip, sửa tại chỗ, đến trang, mật độ dòng.
   Chỉ dùng token của stc_theme.css / stc_orbit.css nên tự theo Sáng/Tối. Chữ phụ dùng --stc-muted (đã đo >= 4,5:1 ở cả hai giao diện). */

/* ---- thanh công cụ ---- */
.stc-tab[hidden], #pl-tag-filter[hidden] { display: none; }
.stc-search .pl-kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); min-width: 20px; height: 20px; padding: 0 5px; box-sizing: border-box;
  border: 1px solid var(--stc-border); border-radius: var(--stc-r-ctl); background: var(--stc-surface-2); color: var(--stc-muted); font: 600 12px/18px var(--stc-font); text-align: center; pointer-events: none; }
.stc-search input:focus + .pl-kbd, .stc-search input:not(:placeholder-shown) + .pl-kbd { display: none; }
.stc-search { min-width: 220px; }
.stc-search input { padding-right: 36px; }
#pl-tag-filter { min-width: 120px; max-width: 200px; }
.pl-badge { min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: var(--stc-r-card); background: var(--stc-accent); color: var(--stc-accent-ink);
  font-size: 12px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; margin-left: -2px; }
#pl-filter-btn[aria-expanded="true"], #stc-btn-cols[aria-expanded="true"] { border-color: var(--stc-border-hover); color: var(--stc-accent-text); }
.pl-icon-btn { padding: 9px 10px; }
.pl-icon-btn[aria-busy="true"] { cursor: progress; }
@media (prefers-reduced-motion: no-preference) {
  .pl-icon-btn[aria-busy="true"] svg { animation: pl-spin 0.8s cubic-bezier(0.22, 1, 0.36, 1) infinite; }
}
@keyframes pl-spin { to { transform: rotate(360deg); } }

/* ---- chip bộ lọc đang áp dụng ---- */
.pl-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 28px 0; }
.pl-chips[hidden] { display: none; }
#view-profiles.trash-mode > .pl-chips { display: none; }      /* tab Thùng rác: bộ lọc của bảng hồ sơ không áp dụng */
.pl-chips-l { color: var(--stc-muted); font-size: 13px; }
.pl-chip { display: inline-flex; align-items: center; gap: 2px; max-width: 360px; padding: 2px 2px 2px 10px; border-radius: var(--stc-r-ctl); border: 1px solid var(--stc-border-strong);
  background: var(--stc-accent-soft); color: var(--stc-text-strong); font-size: 13px; }
.pl-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-chip button { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; border-radius: var(--stc-r-ctl); background: transparent; color: var(--stc-text); cursor: pointer; flex-shrink: 0; }
.pl-chip button:hover { background: var(--stc-row-hover); color: var(--stc-text-strong); }
.pl-clear { border: 0; background: transparent; color: var(--stc-accent-text); font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: var(--stc-r-ctl); text-decoration: underline; text-underline-offset: 3px; }

/* ---- bảng ---- */
/* cột theo bề rộng tự nhiên (không bóp méo, không xuống dòng); nhiều cột hơn khung thì khung cuộn ngang, cột Thao tác ghim phải */
#view-profiles table.stc-table { width: max-content; min-width: 100%; }
#view-profiles .stc-table td { white-space: nowrap; }
/* cột "Thao tác" dính bên phải: bảng rộng hơn thẻ thì cột này ĐÈ lên cột Trạng thái ("Đã đ…", tiêu đề "Trạng th"). Ở cửa sổ 1280x820 với các cột mặc định
   (kể cả hồ sơ có proxy và hồ sơ đang báo thiếu lõi) bảng phải vừa thẻ — đo bằng tests/test_ui_bocuc_bit.py (Chrome thật, mục 5):
   đệm ô 6px, khoảng cách trong ô tên 8px, chữ dài (tên, proxy) có trần co theo cửa sổ + dấu "…" (đủ chữ ở chú thích), nút Mở/Đóng gọn.
   Bật thêm nhiều cột thì vẫn cuộn ngang như cũ, cột Thao tác ghim phải. Thẻ nội dung cũng rộng thêm 56px (titlebar.css: bỏ lề ngang thứ hai). */
#view-profiles .stc-table :is(th, td)[data-col] { padding-left: 6px; padding-right: 6px; }
#view-profiles .stc-table > :is(thead, tbody) > tr > :first-child:not([colspan]) { padding-left: 12px; padding-right: 6px; }
#view-profiles .stc-table .stc-name { gap: 8px; }
#view-profiles .stc-name .t { max-width: min(240px, 12vw); }
#view-profiles td[data-col="proxy"] .pxq-cell { max-width: min(220px, 12vw); position: relative; }
/* bút "đổi proxy" chỉ hiện khi rê/tiêu điểm: nổi trên mép phải (không giữ chỗ) => chữ IP:cổng có thêm ~20px trong cùng bề rộng cột */
#view-profiles td[data-col="proxy"] .pxq-cell .pxq-pen { position: absolute; right: 3px; top: 50%; margin-top: -9.5px; padding: 3px; box-sizing: content-box; border-radius: var(--stc-r-ctl); background: var(--stc-row-hover); }
#view-profiles .stc-act { gap: 2px; }
#view-profiles .stc-act .main { min-width: 56px; padding-left: 10px; padding-right: 10px; }
#view-profiles .stc-act .stc-kebab { width: 30px; }
#view-profiles .stc-table td.pl-act-cell { padding-left: 10px; padding-right: 8px; }
/* trạng thái lưu phiên (trước là cột "Đồng bộ" riêng) nằm cạnh chữ Trạng thái: bình thường chỉ biểu tượng (có chú thích), cảnh báo có thêm chữ */
.stc-st-sync { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.stc-st-sync .stc-sync { gap: 4px; font-size: 13px; }
.stc-st-sync .stc-sync svg { flex-shrink: 0; }
.stc-st-sync .stc-sync.is-icon { color: var(--stc-muted); cursor: help; }
.stc-st-sync .stc-sync.pending.is-icon { color: var(--stc-warn); }
#view-profiles .stc-table td:is([data-col="seq"], [data-col="core"], [data-col="created"], [data-col="last"], [data-col="owner"], [data-col="notes"], [data-col="tags"]) { font-weight: 400; }
.stc-table th[data-col] { padding-top: 0; padding-bottom: 0; height: 42px; }
.pl-sort { display: inline-flex; align-items: center; gap: 5px; margin: 0 -6px; padding: 6px; border: 0; border-radius: var(--stc-r-ctl); background: transparent; color: inherit;
  font: inherit; font-weight: inherit; cursor: pointer; white-space: nowrap; }
.pl-sort svg { opacity: 0.55; flex-shrink: 0; }
.pl-sort:hover { color: var(--stc-text-strong); background: var(--stc-row-hover); }
.pl-sort:hover svg, .pl-sort.on svg { opacity: 1; }
.pl-sort.on { color: var(--stc-accent-text); }
.stc-table .pl-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pl-none { color: var(--stc-muted); }
.pl-os { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 26px; border-radius: var(--stc-r-ctl); color: var(--stc-text); }
.stc-table td[data-col="os"] { text-align: center; } .stc-table th[data-col="os"] { width: 1%; }
.pl-tags { display: inline-flex; gap: 5px; max-width: 220px; overflow: hidden; }
.pl-tag { padding: 1px 8px; border-radius: var(--stc-r-ctl); border: 1px solid var(--stc-border); background: var(--stc-surface-2); color: var(--stc-text); font-size: 12.5px; white-space: nowrap;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.pl-tag.pl-more { color: var(--stc-muted); }
.pl-core, .pl-owner { white-space: nowrap; }
.pl-notes { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 220px; }
.pl-note-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--stc-text); cursor: text; }
.stc-name .t { cursor: text; }

/* nút bút sửa nhanh: hiện khi rê chuột / tiêu điểm vào hàng; máy cảm ứng luôn hiện */
.pl-pen { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 26px; height: 26px; border: 1px solid transparent; border-radius: var(--stc-r-ctl);
  background: transparent; color: var(--stc-muted); cursor: pointer; opacity: 0; }
.stc-table tr:hover .pl-pen, .stc-table tr:focus-within .pl-pen, .pl-pen:focus-visible { opacity: 1; }
.pl-pen:hover { color: var(--stc-text-strong); border-color: var(--stc-border); background: var(--stc-surface-2); }
@media (hover: none) { .pl-pen { opacity: 1; } }
.stc-name [hidden], .pl-pen[hidden] { display: none !important; }
.stc-table td[data-col="notes"] { min-width: 150px; } .stc-table td[data-col="tags"] { min-width: 110px; }

/* ô sửa tại chỗ */
.pl-edit-box { position: relative; display: flex; flex-direction: column; flex: 1; min-width: 160px; }
.pl-inline { width: 100%; box-sizing: border-box; padding: 5px 8px; border-radius: var(--stc-r-ctl); border: 1px solid var(--stc-accent); background: var(--stc-input); color: var(--stc-text-strong);
  font: inherit; font-size: 14px; line-height: 1.35; outline: none; box-shadow: 0 0 0 3px var(--stc-accent-soft); resize: vertical; }
textarea.pl-inline { min-height: 52px; max-height: 140px; }
.pl-inline[aria-invalid="true"] { border-color: var(--stc-err); box-shadow: 0 0 0 3px var(--stc-err-soft); }
.pl-edit-err { font-size: 12.5px; color: var(--stc-err-text); line-height: 1.3; }
.pl-edit-err:empty { display: none; }
.pl-edit-err.busy { color: var(--stc-muted); }
.stc-table tr.pl-editing td { vertical-align: top; padding-top: 7px; padding-bottom: 7px; }

/* số thứ tự đã có cột riêng => bỏ ô số lặp lại trong ô tên */
#view-profiles.pl-has-seq .stc-name .stc-seq { display: none; }

/* cột Thao tác ghim bên phải khi bảng cuộn ngang (cửa sổ hẹp / nhiều cột) */
.stc-table th.pl-act-head, .stc-table td.pl-act-cell { position: sticky; right: 0; z-index: 1; background: var(--stc-surface); box-shadow: -1px 0 0 var(--stc-border); }
.stc-table th.pl-act-head { background: var(--stc-surface-2); }
.stc-table tbody tr:hover td.pl-act-cell { background: linear-gradient(var(--stc-row-hover), var(--stc-row-hover)), var(--stc-surface); }
.stc-table tbody tr.selected td.pl-act-cell { background: linear-gradient(var(--stc-row-selected), var(--stc-row-selected)), var(--stc-surface); }

/* mật độ dòng: Gọn */
#view-profiles.pl-compact .stc-table td { height: 36px; }
#view-profiles.pl-compact .stc-table th[data-col] { height: 36px; }
#view-profiles.pl-compact .stc-tile { width: 22px; height: 22px; font-size: 12px; border-radius: var(--stc-r-ctl); }
#view-profiles.pl-compact .stc-act .main { padding: 4px 10px; }
#view-profiles.pl-compact .stc-kebab { width: 28px; height: 28px; }

/* ---- khay nổi (Tùy chỉnh cột / Bộ lọc nâng cao): không chặn trang ---- */
.pl-pop { position: fixed; z-index: 99790; box-sizing: border-box; width: min(420px, calc(100vw - 16px)); overflow: auto; padding: 14px; border-radius: var(--stc-r-card);
  border: 1px solid var(--stc-border); background: var(--stc-surface); color: var(--stc-text); box-shadow: var(--stc-shadow); }
.pl-pop.pl-filter { width: min(500px, calc(100vw - 16px)); }
.pl-pop-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.pl-pop-head b { color: var(--stc-text-strong); font-size: 15px; }
.pl-pop-head span { color: var(--stc-muted); font-size: 12.5px; }
.pl-pop-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px 2px; margin-top: 8px; border-top: 1px solid var(--stc-border); font-size: 13.5px; }
.pl-pop-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--stc-border); }
.pl-match { margin-right: auto; color: var(--stc-muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.pl-col-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.pl-col-list li { display: grid; grid-template-columns: 18px 1fr 28px 28px; align-items: center; gap: 6px; padding: 5px 6px; border-radius: var(--stc-r-card); }
.pl-col-list li:hover { background: var(--stc-row-hover); }
.pl-col-list li.dragging { opacity: 0.45; }
.pl-col-list li.drop-before { box-shadow: inset 0 2px 0 var(--stc-accent); }
.pl-col-list li.drop-after { box-shadow: inset 0 -2px 0 var(--stc-accent); }
.pl-grip { color: var(--stc-muted); cursor: grab; display: inline-flex; }
.pl-col-lbl { display: flex; align-items: flex-start; gap: 9px; min-width: 0; cursor: pointer; }
.pl-col-lbl input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--stc-accent); flex-shrink: 0; cursor: pointer; }
.pl-col-lbl > span { display: flex; flex-direction: column; min-width: 0; }
.pl-col-lbl b { font-weight: 600; font-size: 13.5px; color: var(--stc-text-strong); }
.pl-col-lbl small { font-size: 12px; color: var(--stc-muted); line-height: 1.35; }
.pl-mv { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 1px solid transparent; border-radius: var(--stc-r-ctl); background: transparent; color: var(--stc-text); cursor: pointer; }
.pl-mv:hover:not([disabled]) { border-color: var(--stc-border); background: var(--stc-surface-2); }
.pl-mv[disabled] { opacity: 0.3; cursor: default; }

.pl-f-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.pl-f { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 12.5px; color: var(--stc-muted); }
.pl-f-wide { grid-column: 1 / -1; }
.pl-f select, .pl-f input { box-sizing: border-box; width: 100%; height: 34px; padding: 0 10px; border-radius: var(--stc-r-ctl); border: 1px solid var(--stc-border-ctl); background: var(--stc-input);
  color: var(--stc-text); font: inherit; font-size: 13.5px; }
.pl-f select[disabled] { opacity: 0.6; }
.pl-range { display: flex; align-items: center; gap: 8px; }
.pl-range span { color: var(--stc-muted); }
.pl-fs { border: 0; margin: 12px 0 0; padding: 0; min-width: 0; }
.pl-fs legend { padding: 0 0 6px; font-size: 12.5px; color: var(--stc-muted); }
.pl-chks { display: flex; flex-wrap: wrap; gap: 6px; }
.pl-chk { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: var(--stc-r-ctl); border: 1px solid var(--stc-border); background: var(--stc-surface-2); font-size: 13px; cursor: pointer; color: var(--stc-text); }
.pl-chk:has(input:checked) { border-color: var(--stc-border-hover); background: var(--stc-fill-active); color: var(--stc-text-strong); }
.pl-chk input { width: 15px; height: 15px; margin: 0; accent-color: var(--stc-accent); }
.pl-cnt { color: var(--stc-muted); font-variant-numeric: tabular-nums; font-size: 12px; }

/* ---- phân trang: đến trang ---- */
.pl-goto { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--stc-muted); }
.pl-goto[hidden] { display: none; }
.pl-goto input { width: 64px; height: 34px; box-sizing: border-box; padding: 0 8px; border-radius: var(--stc-r-card); border: 1px solid var(--stc-border-ctl); background: var(--stc-input); color: var(--stc-text);
  font: inherit; font-variant-numeric: tabular-nums; }
.pl-goto input[aria-invalid="true"] { border-color: var(--stc-err); }

/* tiêu điểm bàn phím: cùng vòng vàng với các nút khác của STC */
:is(.pl-sort, .pl-pen, .pl-mv, .pl-chip button, .pl-clear, .pl-chk, .pl-col-lbl):focus-visible,
:is(.pl-chk, .pl-col-lbl):has(input:focus-visible),
.pl-f :is(select, input):focus-visible, .pl-goto input:focus-visible { outline: 2px solid var(--stc-accent); outline-offset: 1px; }

@media (max-width: 1180px) {
  .stc-search { min-width: 180px; }
  .pl-f-grid { grid-template-columns: 1fr; }
}
