/* ============================================================
   DIRECTORY (danh bạ nhân sự) — chỉ class MỚI, không trùng
   .hr-toolbar/.hr-count/.emp-grid/.emp-card/.avatar/.pv-*/.prow/.seg/.btn
   đã có sẵn ở styles/hr.css + styles/components.css.
   ============================================================ */

/* — Hàng toolbar thứ 2: search + sort + view toggle + nút thêm — */
.dir-toolbar2 { align-items: center; }
.dir-toolbar2 .dir-sort { max-width: 210px; }
.dir-toolbar2 .seg button { white-space: nowrap; }

/* — Ô tìm kiếm có icon bên trái — */
.dir-search-wrap { position: relative; min-width: 220px; flex: 1 1 220px; max-width: 320px; }
.dir-search-wrap .ic {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none;
}
.dir-search-wrap input.inp { padding-left: 34px; }

/* — Badge đếm nhỏ trong tab .seg — */
.seg-count {
  display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: var(--r-pill);
  font-size: 10px; font-weight: 700; background: rgba(255,255,255,.08); color: var(--faint);
}
.seg button.on .seg-count { background: rgba(255,255,255,.16); color: var(--purple-xl); }

/* — Toggle ẩn/hiện ảnh thật (mặc định ẨN → hiện huy hiệu công ty) — */
.dir-photo-btn { white-space: nowrap; }
.dir-photo-btn.on { color: var(--purple-xl); background: var(--purple-soft); border-color: var(--line); }
.dir-photo-btn .ic { color: inherit; }

/* — Huy hiệu thay ảnh thật khi đang ẩn — dùng chung .avatar-img (sm/lg) cho kích thước — */
.avatar-img.dir-emblem { object-fit: contain; background: var(--bg-0); padding: 15%; }

/* ============================================================
   THẺ ẢNH (photo-tile) — mặt thẻ kiểu ảnh lớn ở trên, tên + trường
   phụ ở dưới, dải màu trang trí ở đáy. Đây là khái niệm MỚI riêng
   của Directory — không đụng .emp-card/.emp-grid dùng chung ở hr.css.
   ============================================================ */
.dir-pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: var(--sp-3); }
.dir-pcard {
  position: relative; border-radius: var(--r-lg); overflow: hidden; cursor: pointer;
  background: var(--card); border: 1px solid var(--line-2);
  transition: transform var(--mo-fast) var(--ease-out), border-color var(--mo-fast), box-shadow var(--mo-fast);
  animation: fadeUp var(--mo-base) var(--ease-out);
}
.dir-pcard:hover, .dir-pcard:focus-visible { transform: translateY(-3px); border-color: var(--gline); box-shadow: var(--el-2), 0 0 0 1px var(--gline); outline: none; }
.dir-pcard.sel { border-color: var(--purple-l); box-shadow: 0 0 0 1px var(--purple-l); }
.dir-pcard.gone { opacity: .68; }

.dpc-photo {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  box-shadow: inset 0 -30px 34px -20px rgba(124,58,237,.35);
}
.dpc-photo.placeholder { background-color: var(--bg-0); background-size: 46%; background-position: center; background-repeat: no-repeat; }
.dir-pcard.gone .dpc-photo { filter: grayscale(.65); }
.dpc-tag {
  position: absolute; left: 8px; top: 8px; font-size: 10px; font-weight: 700; letter-spacing: .3px;
  padding: 2px 8px; border-radius: 6px; color: #17101f; text-shadow: none;
  border: 1px solid rgba(255,255,255,.35); box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.dpc-resign {
  position: absolute; right: 8px; top: 8px; font-size: 9.5px; font-weight: 700; padding: 2px 7px;
  border-radius: 6px; background: var(--bad); color: #fff;
}
.dpc-body { padding: var(--sp-3) var(--sp-3) 12px; }
.dpc-name { font-size: var(--fs-emph); font-weight: 700; letter-spacing: .1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dpc-real { font-size: var(--fs-label); color: var(--muted); margin: 1px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dpc-ef { margin-top: 8px; }
.dpc-ef-lab { font-size: 10px; color: var(--faint); margin-bottom: 2px; }
.dpc-ef-val { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dpc-bar { margin-top: 11px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--purple), var(--gold-l), transparent); }

/* ============================================================
   MODAL "Thẻ hiển thị" — chọn tối đa 4 trường phụ hiện trên thẻ
   ============================================================ */
.cf-hint { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-label); color: var(--muted); padding-bottom: var(--sp-2); }
.cf-count { font-size: 11px; font-weight: 700; color: var(--purple-l); flex: none; margin-left: var(--sp-2); }
.cf-list { display: flex; flex-direction: column; gap: 2px; max-height: 300px; overflow-y: auto; }
.cf-row { display: flex; align-items: center; gap: 11px; padding: 9px 8px; border-radius: var(--r-sm); cursor: pointer; transition: background var(--mo-fast); }
.cf-row:hover { background: var(--hover); }
.cf-row.disabled { opacity: .42; cursor: not-allowed; }
.cf-box {
  width: 19px; height: 19px; flex: none; border-radius: 6px; border: 1.5px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
}
.cf-row.on .cf-box { border-color: transparent; background: linear-gradient(150deg, var(--gold-l), var(--gold)); color: #3a2c0a; }
.cf-row.on .cf-box .ic { width: 12px; height: 12px; }
.cf-label { flex: 1; font-size: 13px; font-weight: 500; }
.cf-order {
  width: 18px; height: 18px; flex: none; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  background: var(--purple); color: #fff; font-size: 10px; font-weight: 700;
}

/* ============================================================
   SƠ ĐỒ TỔ CHỨC — view mode riêng (khác Thẻ ảnh/Danh sách),
   nhóm nhân sự theo phòng ban, trưởng bộ phận nổi bật ở trên.
   ============================================================ */
.dir-org { padding: var(--sp-2) 0 var(--sp-6); }
.dir-org-hd {
  display: flex; align-items: center; gap: var(--sp-3); width: max-content; margin: 0 auto var(--sp-5);
  padding: 13px 22px; border-radius: var(--r-lg); background: var(--purple-soft); border: 1px solid var(--line);
}
.dir-org-badge {
  width: 42px; height: 42px; flex: none; border-radius: var(--r-md); background: var(--purple); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; font-family: var(--mono);
}
.dir-org-title { font-size: var(--fs-emph); font-weight: 800; letter-spacing: .2px; }
.dir-org-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.dir-org-cols { display: flex; gap: var(--sp-5); align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.dir-org-col { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); min-width: 200px; }
.dir-org-dept {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--dc) 16%, transparent); border: 1px solid color-mix(in srgb, var(--dc) 50%, transparent);
  color: var(--dc); font-weight: 700; font-size: 12.5px; white-space: nowrap;
}
.dir-org-dept .dot { width: 8px; height: 8px; border-radius: 3px; background: var(--dc); }
.dir-org-leaders { display: flex; flex-direction: column; gap: var(--sp-2); align-items: stretch; width: 100%; }
.dir-org-node {
  display: flex; align-items: center; gap: 10px; padding: 8px 13px 8px 9px; border-radius: var(--r-md);
  background: var(--card); border: 1px solid var(--line-2); cursor: pointer;
  transition: transform var(--mo-fast), border-color var(--mo-fast);
}
.dir-org-node:hover { transform: translateY(-2px); border-color: var(--purple-l); }
.dir-org-node .min0 { min-width: 0; }
.dir-org-node .nm { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 132px; }
.dir-org-node .ps { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 132px; }
.dir-org-staff { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: 100%; }
.dir-org-chip {
  display: flex; align-items: center; gap: 7px; padding: 5px 9px 5px 6px; border-radius: var(--r-sm);
  background: var(--card); border: 1px solid var(--line-2); cursor: pointer; min-width: 0;
}
.dir-org-chip:hover { border-color: var(--purple-l); }
.dir-org-chip span { font-size: 11.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* — Khối hồ sơ (right panel), 6 khối có tiêu đề riêng — */
.dir-block { margin-top: var(--sp-4); }
.dir-block:first-of-type { margin-top: 0; }
.dir-block-hd {
  display: flex; align-items: center; gap: 7px; font-size: var(--fs-label); font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
  padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line-2);
}
.dir-block-hd .ic { width: 14px; height: 14px; color: var(--purple-l); }
.dir-block-hd .cn { text-transform: none; letter-spacing: 0; font-weight: 500; }

/* — Giá trị trống trong hồ sơ — */
.pv-empty { color: var(--faint); }

/* — Trạng thái không có kết quả lọc/search — */
#dir-body .hint-box { margin-top: var(--sp-2); }

/* — Hàng hồ sơ đính kèm (trong panel phải) — */
.dir-doc-row {
  display: flex; align-items: center; gap: var(--sp-2); padding: 6px 0;
  border-bottom: 1px solid var(--line-2); font-size: var(--fs-label);
}
.dir-doc-row:last-child { border-bottom: none; }
.dir-doc-row .ic { width: 14px; height: 14px; color: var(--purple-l); flex: none; }

/* — Chip "từ Dashboard" khi mở Danh bạ qua KPI trên Bảng điều khiển (directory.js:85) — */
.dir-kpi-from { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-label); color: var(--purple-xl); background: var(--purple-soft); border-radius: var(--r-pill); padding: 2px 10px; margin-left: var(--sp-3); }
.dir-kpi-from .ic { width: 12px; height: 12px; }
.dir-doc-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
