/* ProInvest Leads — CSS cơ chế, chạy với mọi theme; phần nhìn ở _proinvest-forms.scss. */

.pi-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Fallback để lỗi không bao giờ vô hình nếu theme quên style. */
[data-pi-error] {
  color: #c0392b;
}

/* Admin — card thống kê đầu màn Leads: 1 cột ở 375px → 2 từ 783px → 3 từ 1080px → đủ cột từ 1280px.
   Số cột KHÔNG cố định: hai cột webinar chỉ có mặt khi có dữ liệu, nên card chạy 4, 5 hoặc 6 cột
   và PHP đóng dấu pi-lstats--cols-N để mỗi trường hợp có tỉ lệ riêng. */
.pi-lstats {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  margin: 14px 0 12px;
  background: #fff;
  border: 1px solid #dcdcde;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

/* 🚨 Đường kẻ do CHÍNH TỪNG Ô vẽ ra, nền card để trắng — trước đây nền card màu xám và khe hở
   1px của grid chính là đường kẻ. Số ô không chia hết cho số cột (card chạy 4/5/6 ô) thì hàng
   cuối còn ô trống, mà ô trống thì ăn màu nền: thành một mảng xám to bên cạnh cột cuối, trông
   đúng như card vỡ.

   Dùng `outline` chứ không phải box-shadow: outline vẽ NGOÀI hộp nên nó rơi trọn vào khe 1px và
   không bị nền trắng của ô kế tiếp đè lên (box-shadow rơi vào phần đất của ô bên cạnh, và ô đó
   vẽ sau nên phủ mất — kẻ biến mất sạch). Ô trống không có outline nên nó chỉ là khoảng trắng,
   còn ở mép card thì outline nằm ngoài vùng overflow:hidden nên bị cắt, không đè lên border. */
.pi-lstats .pi-lpanel {
  outline: 1px solid #dcdcde;
}

@media (min-width: 783px) {
  .pi-lstats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1080px) {
  .pi-lstats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Cột phân bố rộng hơn vì phải chứa tên khóa / tên buổi webinar dài; hai cột số thì hẹp lại. */
@media (min-width: 1280px) {
  .pi-lstats--cols-4 {
    grid-template-columns: minmax(0, 0.7fr) minmax(0, 0.95fr) minmax(0, 1.35fr) minmax(0, 1fr);
  }

  .pi-lstats--cols-5 {
    grid-template-columns: minmax(0, 0.66fr) minmax(0, 0.85fr) minmax(0, 1.2fr) minmax(0, 0.95fr) minmax(0, 1.35fr);
  }

  /* Cột "Học phí buổi" hẹp nhất: nhãn của nó chỉ hai chữ và không bao giờ dài thêm, trong khi
     tên buổi webinar thì luôn có tiêu đề + ngày + giờ. */
  .pi-lstats--cols-6 {
    grid-template-columns:
      minmax(0, 0.55fr) minmax(0, 0.72fr) minmax(0, 1.05fr)
      minmax(0, 0.78fr) minmax(0, 1.4fr) minmax(0, 0.8fr);
  }
}

/* --- Cột tổng quan: tổng lead · tỉ lệ đóng phí ------------------------ */
/* flex-basis 130px: cột hẹp thì hai số tự xuống dòng, cột rộng thì nằm cạnh nhau. */
.pi-lpanel--sum {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px 24px;
}

.pi-lpanel--sum .pi-lpanel__head {
  flex: 1 1 100%;
  margin-bottom: 0;
}

.pi-lstats .pi-lsum {
  display: flex;
  flex: 1 1 130px;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 2px 0 0;
  color: #1d2327;
}

.pi-lsum__value {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.pi-lsum__label {
  font-size: 11px;
  line-height: 1.35;
  color: #646970;
}

/* --- Cột trạng thái --------------------------------------------------- */
.pi-lchips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.pi-lchip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border: 1px solid #dcdcde;
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  line-height: 1.6;
  color: #2c3338;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* Chấm màu = mã màu trạng thái, khớp badge trong bảng danh sách */
.pi-lchip::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8c8f94;
}

.pi-lchip--new::before {
  background: #d98600;
}

.pi-lchip--contacted::before {
  background: #2271b1;
}

.pi-lchip--converted::before {
  background: #007a4d;
}

.pi-lchip--spam::before {
  background: #b32d2e;
}

.pi-lchip__num {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pi-lchip:hover,
.pi-lchip:focus {
  border-color: #8c8f94;
  background: #f6f7f7;
  color: #2c3338;
}

.pi-lchip.is-active {
  border-color: #2271b1;
  background: #f0f6fc;
  color: #135e96;
  box-shadow: inset 0 0 0 1px #2271b1;
}

/* --- Cột (dùng chung cho cả 4 khối) ----------------------------------- */
.pi-lpanel {
  min-width: 0;
  padding: 9px 12px 10px;
  background: #fff;
}

.pi-lpanel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.pi-lstats .pi-lpanel__title {
  margin: 0;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #646970;
}

.pi-lpanel__clear {
  flex: none;
  font-size: 12px;
  text-decoration: none;
}

.pi-lpanel__empty {
  margin: 0;
  font-size: 13px;
  color: #646970;
}

/* minmax(0, 1fr): để auto = max-content thì nhãn khóa dài đẩy cả bảng tràn ngang. */
.pi-lbars {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pi-lbars__item {
  margin: 0;
}

/* Thanh tỉ lệ làm nền của dòng thay vì track riêng bên dưới — mỗi dòng thấp đi ~9px. */
.pi-lbar {
  position: relative;
  display: block;
  padding: 2px 6px;
  border-radius: 3px;
  overflow: hidden;
  color: #1d2327;
  text-decoration: none;
}

.pi-lbar:hover,
.pi-lbar:focus {
  color: #1d2327;
}

.pi-lbar.is-active {
  box-shadow: inset 0 0 0 1px #2271b1;
}

.pi-lbar__head {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  line-height: 1.45;
}

/* Tên khóa dài không được kéo giãn hàng — cắt bớt, số đếm luôn thấy được */
.pi-lbar__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chỗ đã giữ / trần chỗ — con số của màn Webinar, cố tình nhạt hơn số đăng ký bên cạnh
   để không ai đọc nhầm hai thứ khác nhau thành một. */
.pi-lbar__seats {
  flex: none;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: #646970;
}

.pi-lbar__num {
  flex: none;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pi-lbar__pct {
  flex: none;
  min-width: 34px;
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #646970;
}

.pi-lbar__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  min-width: 3px;
  border-radius: inherit;
  background: #eaf1f8;
  transition: background-color 0.15s ease;
}

/* Nền chỉ đậm khi hover/đang lọc — để nhạt cho chữ và số đọc trước, tránh cả bảng rực xanh. */
.pi-lbar:hover .pi-lbar__fill,
.pi-lbar:focus .pi-lbar__fill {
  background: #d5e4f2;
}

.pi-lbar.is-active .pi-lbar__fill {
  background: #cbdff2;
}

/* --- Gập đuôi cả 3 bảng bằng MỘT nút chung dưới chân card -------------- */
.pi-lstats .pi-lbars__item--extra {
  display: none;
}

.pi-lstats.is-open .pi-lbars__item--extra {
  display: block;
}

/* Hàng chân trải hết bề ngang, nút ở giữa — cân với hàng tiêu đề cột phía trên */
.pi-lstats__foot {
  display: flex;
  justify-content: center;
  grid-column: 1 / -1;
  padding: 3px 12px;
  background: #fff;
}

.pi-lmore {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 2px 0 0;
  padding: 2px 6px;
  border: 0;
  border-radius: 3px;
  background: none;
  font-size: 12px;
  line-height: 1.5;
  color: #2271b1;
  cursor: pointer;
}

.pi-lmore:hover,
.pi-lmore:focus {
  background: #f0f6fc;
  color: #135e96;
}

/* Mũi tên vẽ bằng 2 cánh CSS bẻ lên/xuống — không dùng ký tự ▾ */
.pi-lmore__chev {
  position: relative;
  display: block;
  flex: none;
  width: 12px;
  height: 12px;
}

.pi-lmore__chev::before,
.pi-lmore__chev::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 6px;
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
  background: currentColor;
  transition: transform 0.2s ease;
}

.pi-lmore__chev::before {
  right: 50%;
  margin-right: -1px;
  transform-origin: 100% 50%;
  transform: translateY(1px) rotate(32deg);
}

.pi-lmore__chev::after {
  left: 50%;
  margin-left: -1px;
  transform-origin: 0 50%;
  transform: translateY(1px) rotate(-32deg);
}

.pi-lstats.is-open .pi-lmore__chev::before {
  transform: translateY(-1px) rotate(-32deg);
}

.pi-lstats.is-open .pi-lmore__chev::after {
  transform: translateY(-1px) rotate(32deg);
}

@media (prefers-reduced-motion: reduce) {

  .pi-lmore__chev::before,
  .pi-lmore__chev::after {
    transition: none;
  }
}

/* Bề rộng thanh tỉ lệ bước 5% — thay style inline (pi_leads_bar_class trong admin.php). */
.pi-lfill--w0 { width: 0; min-width: 0; }
.pi-lfill--w5 { width: 5%; }
.pi-lfill--w10 { width: 10%; }
.pi-lfill--w15 { width: 15%; }
.pi-lfill--w20 { width: 20%; }
.pi-lfill--w25 { width: 25%; }
.pi-lfill--w30 { width: 30%; }
.pi-lfill--w35 { width: 35%; }
.pi-lfill--w40 { width: 40%; }
.pi-lfill--w45 { width: 45%; }
.pi-lfill--w50 { width: 50%; }
.pi-lfill--w55 { width: 55%; }
.pi-lfill--w60 { width: 60%; }
.pi-lfill--w65 { width: 65%; }
.pi-lfill--w70 { width: 70%; }
.pi-lfill--w75 { width: 75%; }
.pi-lfill--w80 { width: 80%; }
.pi-lfill--w85 { width: 85%; }
.pi-lfill--w90 { width: 90%; }
.pi-lfill--w95 { width: 95%; }
.pi-lfill--w100 { width: 100%; }

/* Cột "Link phòng": nhạt hơn badge trạng thái vì đây là dấu vết thao tác, không phải trạng thái của lead. */
.pi-lead-sent {
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
  color: #2a7b46;
}

/* Badge trạng thái trên bảng danh sách Leads. */
.pi-lead-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 7px;
  border: 1px solid #dcdcde;
  border-radius: 999px;
  background: #f6f7f7;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
  color: #2c3338;
}

.pi-lead-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8c8f94;
}

.pi-lead-status--new {
  border-color: #f0d09a;
  background: #fdf5e6;
  color: #8a5a00;
}

.pi-lead-status--new::before {
  background: #d98600;
}

.pi-lead-status--contacted {
  border-color: #b5d4ec;
  background: #f0f6fc;
  color: #135e96;
}

.pi-lead-status--contacted::before {
  background: #2271b1;
}

.pi-lead-status--converted {
  border-color: #a7d7bf;
  background: #edf7f2;
  color: #005c3a;
}

.pi-lead-status--converted::before {
  background: #007a4d;
}

.pi-lead-status--spam {
  border-color: #e6b3b3;
  background: #fcf0f1;
  color: #8c2426;
}

.pi-lead-status--spam::before {
  background: #b32d2e;
}

/* Cột Thao tác — CHỈ đặt bề rộng; height/font-size của control do theme admin.scss lo. */
.pi-lead-select {
  width: 100%;
  max-width: 100%;
}

/* Chỉ đặt bề rộng cột ở desktop — dưới 783px list table tự stack thành block */
@media (min-width: 783px) {
  .column-actions {
    width: 132px;
  }
}

/* ── Popup xác nhận ───────────────────────────────────────────────────────────
   Chép từ .pi-wb-modal của proinvest-webinar — hai plugin phải tắt được độc lập
   nên không dùng chung file; sửa hình dáng ở đây thì sửa cả bên kia.
   <dialog> lo nền mờ, bẫy focus và phím Esc; ở đây chỉ còn phần nhìn. */
.pi-lead-modal {
  width: calc(100vw - 32px);
  max-width: 420px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}

/* ── Hiện/tắt có chuyển động ──────────────────────────────────────────────────
   Giống hệt .pi-wb-modal bên proinvest-webinar — sửa ở đây thì sửa cả bên kia.

   🚨 KHÔNG BỎ `overlay`/`display` KHỎI DÒNG transition. Popup đang mở nằm ở lớp top layer và
   display:none; thiếu hai thuộc tính đó (cùng `allow-discrete`) thì trình duyệt gỡ nó khỏi màn
   hình NGAY khi close() chạy — hiệu ứng mở vẫn thấy, hiệu ứng đóng thì không, và người sửa sau
   sẽ tưởng transition viết sai.

   @starting-style là mốc "trước khi mở"; trình duyệt chưa hỗ trợ thì bỏ qua cả khối này và
   popup quay về hiện/tắt tức thì như cũ — mất hiệu ứng, không mất chức năng.

   .pi-lead-modal lặp lại selector ở trên là CỐ Ý: cả mục này chỉ có chuyển động, xoá trọn từ
   đây xuống hết @media reduce là popup về đúng như cũ, không phải gỡ lẫn trong phần bố cục. */

.pi-lead-modal {
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    overlay 0.16s allow-discrete,
    display 0.16s allow-discrete;
}

.pi-lead-modal[open] {
  opacity: 1;
  transform: none;
}

@starting-style {

  .pi-lead-modal[open] {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

.pi-lead-modal::backdrop {
  background: rgba(0, 0, 0, 0);
  transition:
    background-color 0.16s ease,
    overlay 0.16s allow-discrete,
    display 0.16s allow-discrete;
}

.pi-lead-modal[open]::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

@starting-style {

  .pi-lead-modal[open]::backdrop {
    background: rgba(0, 0, 0, 0);
  }
}

/* Người tắt hiệu ứng chuyển động thì popup vẫn phải mở/đóng đủ, chỉ bỏ phần nhúc nhích. */
@media (prefers-reduced-motion: reduce) {

  .pi-lead-modal,
  .pi-lead-modal::backdrop {
    transition: none;
  }

  .pi-lead-modal {
    transform: none;
  }
}

.pi-lead-modal__box {
  padding: 22px 24px 18px;
  text-align: center;
}

.pi-lead-modal__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  background: #fcf0f1;
  color: #b32d2e;
}

.pi-lead-modal__icon::before {
  content: "!";
}

.pi-lead-modal__title {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.4;
}

.pi-lead-modal__lead {
  margin: 0;
  color: #50575e;
}

.pi-lead-modal__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

/* Ghi chú là dòng CUỐI của popup — nó giải thích hậu quả, không chắn giữa câu hỏi và nút. */
.pi-lead-modal__note {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid #dcdcde;
  color: #646970;
  font-size: 12px;
  line-height: 1.6;
  text-align: left;
}
