/* admin 名單管理頁 — 寬版 + 質感升級 */
body.wide { max-width: 1200px; }

/* ============ Bulk Bar — 批次操作區（新設計）============ */
.bulk-bar { padding: 16px 20px; }
.bulk-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.bulk-select-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.bulk-status {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 14px;
  color: var(--c-text-2);
  font-variant-numeric: tabular-nums;
}
.bulk-status strong {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-primary);
  letter-spacing: -0.02em;
}
.bulk-status-divider { color: var(--c-text-mute); opacity: 0.6; }
.bulk-status-suffix { color: var(--c-text-mute); margin-left: 4px; font-size: 13px; }

/* Action grid — 每組獨立卡片；desktop 1fr 2fr 1fr 1fr / mobile 2 cols */
.bulk-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
}
@media (min-width: 900px) {
  .bulk-actions-grid {
    grid-template-columns: 1fr 1.6fr 1fr 1fr;
  }
}
.bulk-actions-grid.hidden { display: none; }

.action-group {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
}
.action-group:hover {
  border-color: var(--c-primary);
  background: white;
}
.action-group-export { background: linear-gradient(135deg, #ecfdf5, #d1fae5); border-color: #6ee7b7; }
.action-group-export:hover { background: linear-gradient(135deg, #d1fae5, #a7f3d0); border-color: #10b981; }

.action-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.action-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.action-controls > select {
  flex: 1 1 140px;
  min-width: 0;
  padding: 8px 12px;
  font-size: 14px;
}
.action-controls > button.primary.small {
  flex-shrink: 0;
}
.action-export-btn {
  width: 100%;
  background: linear-gradient(135deg, #10b981, #059669) !important;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}
.action-export-btn:hover {
  background: linear-gradient(135deg, #059669, #047857) !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

/* Rep checkbox chips — 取代之前 inline-style label */
.rep-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}
.rep-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  background: white;
  border: 1.5px solid var(--c-border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-2);
  cursor: pointer;
  user-select: none;
  transition: all 0.12s var(--ease-bezier);
}
.rep-chip:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
}
.rep-chip input[type="checkbox"] {
  width: 14px; height: 14px;
  margin: 0;
  accent-color: var(--c-primary);
  cursor: pointer;
}
.rep-chip:has(input:checked) {
  background: var(--c-primary-soft);
  border-color: var(--c-primary);
  color: var(--c-primary);
  font-weight: 600;
}

.filter-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; row-gap: 12px; }
.filter-row label {
  font-size: 13px; color: #4b5563; margin: 0; font-weight: 500;
  margin-right: -8px;        /* 把 label 跟它後面的 select/input 拉近一點 */
}
.filter-row select, .filter-row input[type="text"], .filter-row input[type="email"], .filter-row input[type="tel"], .filter-row input[type="search"] {
  width: auto; padding: 8px 12px; font-size: 14px;
  min-width: 120px;
}
.filter-row .spacer { flex: 1; }
button.primary.small { padding: 8px 16px; width: auto; font-size: 13px; }

/* 搜尋框 */
.search-box {
  position: relative;
  flex: 1; min-width: 220px; max-width: 360px;
}
.search-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  font-size: 14px;
  border: 1px solid var(--c-border);
  border-radius: 9px;
  background: var(--c-surface-2);
  transition: all 0.15s;
}
.search-box input:focus { background: white; border-color: var(--c-primary); }
.search-box::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%; transform: translateY(-50%);
  font-size: 13px;
  opacity: 0.55;
  pointer-events: none;
}

/* 過濾 chip — active filter 顯示用 */
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.filter-chip button {
  background: transparent; border: none; cursor: pointer;
  color: var(--c-primary); padding: 0 0 0 2px; font-size: 14px; line-height: 1;
}
.filter-chip button:hover { opacity: 0.6; }

/* 表格 */
.lead-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}
table.lead-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  table-layout: fixed;        /* 固定佈局 → 欄寬完全照 col 設定 */
}
table.lead-table th, table.lead-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  white-space: nowrap;        /* 不換行（搭配 ellipsis） */
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 欄寬：客戶資料庫 8 欄（checkbox / 店名 / 縣市 / 產業 / 狀態 / 業務 / 電話 / LINE） */
table.lead-table.cols-admin th:nth-child(1),
table.lead-table.cols-admin td:nth-child(1) { width: 36px; padding-right: 0; }
table.lead-table.cols-admin th:nth-child(2),
table.lead-table.cols-admin td:nth-child(2) { width: auto; }     /* 店名拿剩下空間 */
table.lead-table.cols-admin th:nth-child(3),
table.lead-table.cols-admin td:nth-child(3) { width: 70px; }    /* 縣市 */
table.lead-table.cols-admin th:nth-child(4),
table.lead-table.cols-admin td:nth-child(4) { width: 100px; }   /* 產業 */
table.lead-table.cols-admin th:nth-child(5),
table.lead-table.cols-admin td:nth-child(5) { width: 100px; }   /* 狀態 */
table.lead-table.cols-admin th:nth-child(6),
table.lead-table.cols-admin td:nth-child(6) { width: 110px; }   /* 業務 */
table.lead-table.cols-admin th:nth-child(7),
table.lead-table.cols-admin td:nth-child(7) { width: 130px; }   /* 電話 */
table.lead-table.cols-admin th:nth-child(8),
table.lead-table.cols-admin td:nth-child(8) { width: 70px; }    /* LINE */

/* 業務工作台 6 欄（店名 / 狀態 / 跟進 / 電話 / LINE / 產業-地區） */
table.lead-table.cols-rep th:nth-child(1),
table.lead-table.cols-rep td:nth-child(1) { width: auto; }       /* 店名 */
table.lead-table.cols-rep th:nth-child(2),
table.lead-table.cols-rep td:nth-child(2) { width: 100px; }     /* 狀態 */
table.lead-table.cols-rep th:nth-child(3),
table.lead-table.cols-rep td:nth-child(3) { width: 130px; }     /* 跟進日 */
table.lead-table.cols-rep th:nth-child(4),
table.lead-table.cols-rep td:nth-child(4) { width: 130px; }     /* 電話 */
table.lead-table.cols-rep th:nth-child(5),
table.lead-table.cols-rep td:nth-child(5) { width: 70px; }      /* LINE */
table.lead-table.cols-rep th:nth-child(6),
table.lead-table.cols-rep td:nth-child(6) { width: 160px; }     /* 產業/地區 */

/* badge 跟連結不要被 ellipsis 切掉 */
table.lead-table .status-badge,
table.lead-table a {
  overflow: visible;
  text-overflow: clip;
}
table.lead-table th {
  font-weight: 600;
  color: var(--c-text-2);
  background: var(--c-surface-2);
  position: sticky; top: 0; z-index: 1;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--c-border);
}
table.lead-table tr {
  transition: background 0.12s var(--ease-bezier);
}
table.lead-table tbody tr:hover {
  background: var(--c-primary-soft);
}
table.lead-table tr.selected {
  background: linear-gradient(90deg, var(--c-primary-soft), rgba(238, 242, 255, 0.5));
  box-shadow: inset 3px 0 0 var(--c-primary);
}
table.lead-table .store-cell {
  font-weight: 600;
  cursor: pointer;
  color: var(--c-text);
}
table.lead-table .store-cell:hover { color: var(--c-primary); }
table.lead-table input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--c-primary);
  cursor: pointer;
}

/* 狀態 badge：dot + 漸層 */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.status-新名單     { background: #eef2ff; color: #4338ca; }
.status-第一次聯絡 { background: #dbeafe; color: #1d4ed8; }
.status-興趣中     { background: #fef3c7; color: #b45309; }
.status-報價中     { background: #fed7aa; color: #c2410c; }
.status-成交       { background: #d1fae5; color: #047857; }
.status-無回應     { background: #f3f4f6; color: #4b5563; }
.status-不適合     { background: #fee2e2; color: #b91c1c; }

/* 空狀態 — 升級：圓形漸層底 + 大 icon + 標題副標分層 */
.empty {
  padding: 64px 32px;
  text-align: center;
  color: var(--c-text-mute);
  display: flex; flex-direction: column; align-items: center;
  gap: 14px;
  animation: fadeUp 0.4s var(--ease-out) both;
}
.empty::before {
  content: '🗂️';
  display: inline-flex; align-items: center; justify-content: center;
  width: 88px; height: 88px;
  font-size: 40px;
  background: radial-gradient(circle at 30% 30%, var(--c-primary-soft) 0%, white 70%);
  border-radius: 50%;
  box-shadow:
    0 0 0 1px var(--c-border) inset,
    0 12px 28px -8px rgba(79, 70, 229, 0.18);
  opacity: 0.9;
  transition: transform 0.3s var(--ease-bezier);
}
.empty:hover::before { transform: scale(1.05) rotate(-4deg); }
.empty.empty-leads::before  { content: '📋'; }
.empty.empty-search::before { content: '🔍'; }
.empty.empty-batches::before { content: '📦'; }
.empty .empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text-2);
  letter-spacing: -0.01em;
}
.empty .empty-sub {
  font-size: 13px;
  color: var(--c-text-mute);
  max-width: 340px;
  line-height: 1.5;
}

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s var(--ease-bezier);
}
.modal.hidden { display: none; }
.modal-card {
  background: white;
  border-radius: var(--radius-xl);
  max-width: 720px; width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s var(--ease-out);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; background: white;
  z-index: 1;
}
.modal-header h2 {
  font-size: 18px;
  margin: 0;
  letter-spacing: -0.01em;
}
.modal .body { padding: 22px 24px; }
.modal .field {
  display: flex; gap: 14px; padding: 10px 0; font-size: 14px;
  border-bottom: 1px solid #f3f4f6;
}
.modal .field-label { color: var(--c-text-mute); min-width: 90px; font-size: 13px; }
.modal .field-value { flex: 1; word-break: break-all; color: var(--c-text); }
.modal .field-value a { color: var(--c-primary); text-decoration: none; font-weight: 500; }
.modal .field-value a:hover { text-decoration: underline; }
.modal .field-value select, .modal .field-value input, .modal .field-value textarea {
  width: auto; min-width: 200px; max-width: 100%;
}
.modal .field-value button.small {
  margin-left: 6px;
}

.contact-log-form {
  background: var(--c-surface-2);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  border: 1px solid var(--c-border);
}
.contact-log-form .row { margin-bottom: 12px; }
.contact-log-list { margin-top: 14px; }
.contact-log-item {
  border-left: 3px solid var(--c-primary);
  padding: 10px 14px;
  margin-bottom: 8px;
  background: var(--c-surface-2);
  border-radius: 0 8px 8px 0;
  transition: all 0.15s;
  animation: fadeUp 0.3s var(--ease-out);
}
.contact-log-item:hover { background: var(--c-primary-soft); }
.contact-log-item .meta { font-size: 12px; color: var(--c-text-mute); margin-bottom: 4px; }
.contact-log-item .body { font-size: 14px; }

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg,
    var(--c-surface-2) 0%,
    #eef2ff 40%,
    var(--c-surface-2) 80%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: 6px;
}

/* ============ Mobile：表格變卡片 ============ */
@media (max-width: 640px) {
  /* table 全部不要 fixed 寬度，改成 row block 樣式 */
  table.lead-table { table-layout: auto; font-size: 13px; }
  table.lead-table thead { display: none; }
  table.lead-table tbody, table.lead-table tr {
    display: block; width: 100%;
  }
  table.lead-table tr {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    margin-bottom: 8px;
    padding: 12px 14px;
    box-shadow: var(--shadow-xs);
  }
  table.lead-table tr.selected {
    box-shadow: 0 0 0 2px var(--c-primary);
  }
  table.lead-table td {
    display: block;
    border-bottom: none;
    padding: 4px 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    width: 100% !important;
  }
  table.lead-table .store-cell {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
  }
  /* 把所有非店名 cell 變成標籤式 */
  table.lead-table td::before {
    content: attr(data-label);
    color: var(--c-text-mute);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 8px;
    display: inline-block;
    min-width: 50px;
  }
  table.lead-table .store-cell::before { content: none; }
  /* checkbox cell 浮在右上角 */
  table.lead-table.cols-admin td:first-child {
    position: absolute; right: 14px; top: 14px;
    width: auto !important; padding: 0;
  }
  table.lead-table.cols-admin tr { position: relative; padding-right: 40px; }
  table.lead-table .status-badge { font-size: 11px; padding: 2px 8px; }

  /* 篩選列 mobile 友善：full width selects */
  .filter-row > select,
  .filter-row > input,
  .filter-row > .search-box {
    flex: 1 1 100%;
    min-width: 0;
  }
  .filter-row > label { width: 100%; margin: 0 0 -6px 0; }
}
