/**
 * Premium data tables — Candidates + Vault (design only, locked UX)
 */

/* Card wrapper */
.candidates-main .table-container {
  position: relative;
}

.candidates-main > #candidate-list-body > .card,
.candidates-main > #hh-table-wrap > .card {
  border: 1px solid var(--color-gray-200, #E2E8F0);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.03);
}

/* Override global zebra striping for list tables */
.candidates-table tbody tr:nth-child(even),
.hh-table tbody tr:nth-child(even) {
  background: transparent !important;
}

/* ---------- Shared table base ---------- */

.candidates-table,
.hh-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
}

.candidates-table.dt-cols-sized,
.hh-table.dt-cols-sized {
  table-layout: fixed;
}

/* Clip cell content when columns are manually sized — prevents text bleeding into neighbours */
.candidates-table.dt-cols-sized th[data-col],
.candidates-table.dt-cols-sized td[data-col],
.hh-table.dt-cols-sized th[data-col],
.hh-table.dt-cols-sized td[data-col] {
  overflow: hidden;
  background-color: #fff;
}

.candidates-table.dt-cols-sized tbody tr:hover td[data-col],
.hh-table.dt-cols-sized tbody tr:hover td[data-col] {
  background-color: #F8FAFC;
}

.candidates-table.dt-cols-sized th[data-col],
.hh-table.dt-cols-sized th[data-col] {
  background-color: #F8FAFC;
}

.candidates-table.dt-cols-sized td[data-col="brokerage"],
.candidates-table.dt-cols-sized td[data-col="position"],
.candidates-table.dt-cols-sized td[data-col="nationality"],
.candidates-table.dt-cols-sized td[data-col="phone"],
.candidates-table.dt-cols-sized td[data-col="top_locations"],
.candidates-table.dt-cols-sized td[data-col="languages"],
.candidates-table.dt-cols-sized td[data-col="email"],
.hh-table.dt-cols-sized td[data-col="brokerage"],
.hh-table.dt-cols-sized td[data-col="position"],
.hh-table.dt-cols-sized td[data-col="nationality"],
.hh-table.dt-cols-sized td[data-col="phone"],
.hh-table.dt-cols-sized td[data-col="top_areas"],
.hh-table.dt-cols-sized td[data-col="languages"],
.hh-table.dt-cols-sized td[data-col="email"] {
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Name column — flex stack must shrink inside fixed-width cell */
.candidates-table.dt-cols-sized td[data-col="name"] .flex,
.hh-table.dt-cols-sized td[data-col="name"] .hh-agent-name {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.candidates-table.dt-cols-sized td[data-col="name"] .flex > div:last-child,
.hh-table.dt-cols-sized td[data-col="name"] .hh-agent-name > div:last-child {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.candidates-table.dt-cols-sized .candidate-name,
.candidates-table.dt-cols-sized td[data-col="name"] .text-xs,
.candidates-table.dt-cols-sized td[data-col="name"] .text-muted,
.hh-table.dt-cols-sized .hh-name-text,
.hh-table.dt-cols-sized .hh-position-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.candidates-table thead tr:first-child th.dt-col-resizable,
.hh-table thead tr:first-child th.dt-col-resizable {
  position: relative;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: -6px;
  width: 12px;
  height: 100%;
  cursor: col-resize;
  z-index: 4;
  touch-action: none;
}

.col-resize-handle::after {
  content: '';
  position: absolute;
  top: 8%;
  bottom: 8%;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--color-gray-300, #CBD5E1);
  transition: background 0.15s, width 0.15s, box-shadow 0.15s;
}

.candidates-table thead tr:first-child:hover .col-resize-handle::after,
.hh-table thead tr:first-child:hover .col-resize-handle::after {
  background: var(--color-gray-400, #94A3B8);
}

.col-resize-handle:hover::after,
.col-resize-handle.is-active::after {
  width: 4px;
  background: var(--color-teal-500, #14B8A6);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.18);
}

body.dt-col-resizing {
  cursor: col-resize !important;
  user-select: none;
}

body.dt-col-resizing * {
  cursor: col-resize !important;
}

/* Sticky header */
.candidates-table thead,
.hh-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.candidates-table th,
.hh-table th {
  font-size: 0.6875rem;
  font-weight: var(--font-weight-semibold, 600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-gray-500, #64748B);
  padding: 11px 14px;
  border-bottom: 1px solid var(--color-gray-200, #E2E8F0);
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
  user-select: none;
  vertical-align: middle;
}

.candidates-table th:first-child,
.hh-table th:first-child {
  padding-left: 16px;
}

.candidates-table th:last-child,
.hh-table th:last-child {
  padding-right: 16px;
}

.candidates-table th:hover,
.hh-table th.hh-sortable:hover {
  background: rgba(241, 245, 249, 0.95);
  color: var(--color-gray-700, #334155);
}

.candidates-table th.dragging { opacity: 0.5; cursor: grabbing; }
.candidates-table th.drag-over { background: rgba(13, 148, 136, 0.08); }
.candidates-table th { cursor: grab; }
.candidates-table th.dt-col-resizable { cursor: default; }

.candidates-table td,
.hh-table td {
  padding: 11px 14px;
  color: var(--color-gray-700, #334155);
  border-bottom: 1px solid var(--color-gray-100, #F1F5F9);
  vertical-align: middle;
  line-height: 1.4;
}

.candidates-table td:first-child,
.hh-table td:first-child {
  padding-left: 16px;
}

.candidates-table td:last-child,
.hh-table td:last-child {
  padding-right: 16px;
}

/* Row hover — left accent (HubSpot-style) */
.candidate-row,
.hh-row {
  cursor: pointer;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.candidate-row:hover,
.candidate-row:hover td,
.hh-table tbody tr:hover,
.hh-table tbody tr:hover td {
  background: #F8FAFC !important;
}

.candidate-row:hover,
.hh-row:hover {
  box-shadow: inset 3px 0 0 var(--color-secondary, #0D9488);
}

.hh-row--active {
  box-shadow: inset 3px 0 0 var(--color-primary, #1B2A4A);
}

/* Checkbox column */
.candidates-table .th-check,
.candidates-table td:first-child,
.hh-table .th-check,
.hh-table .td-check {
  width: 44px;
  text-align: center;
  padding-left: 14px;
  padding-right: 8px;
}

.candidates-table input[type="checkbox"],
.hh-table input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--color-primary, #1B2A4A);
  cursor: pointer;
  vertical-align: middle;
}

/* ---------- Name column ---------- */

.candidates-table td[data-col="name"] .flex,
.hh-agent-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.candidates-table td[data-col="name"] .avatar,
.hh-table td[data-col="name"] .avatar,
.hh-table td[data-col="name"] .hh-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: var(--font-weight-semibold, 600);
  box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.hh-table td[data-col="name"] .hh-avatar {
  object-fit: cover;
}

.candidates-table td[data-col="name"] .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.candidate-name,
.hh-name-text {
  font-weight: var(--font-weight-semibold, 600);
  color: var(--color-gray-900, #0F172A);
  font-size: 0.8125rem;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.candidate-row:hover .candidate-name,
.hh-row:hover .hh-name-text {
  color: var(--color-primary, #1B2A4A);
}

.candidates-table td[data-col="name"] .text-muted,
.candidates-table td[data-col="name"] .text-xs,
.hh-position-text {
  color: var(--color-gray-400, #94A3B8) !important;
  font-size: 0.6875rem !important;
  line-height: 1.35;
  margin-top: 1px;
}

/* ---------- Column typography tiers ---------- */

/* Primary text columns */
.candidates-table td[data-col="brokerage"],
.candidates-table td[data-col="position"],
.hh-table td[data-col="brokerage"],
.hh-table td[data-col="position"] {
  font-weight: var(--font-weight-medium, 500);
  color: var(--color-gray-800, #1E293B);
}

/* Secondary / metadata columns */
.candidates-table td[data-col="top_locations"],
.candidates-table td[data-col="languages"],
.candidates-table td[data-col="nationality"],
.candidates-table td[data-col="phone"],
.hh-table td[data-col="top_areas"],
.hh-table td[data-col="languages"],
.hh-table td[data-col="nationality"],
.hh-table td[data-col="phone"],
.hh-table td[data-col="email"] {
  color: var(--color-gray-600, #475569);
  font-size: 0.8125rem;
}

/* Truncated long text — default cap; removed when column is manually widened */
.candidates-table td[data-col="top_locations"],
.candidates-table td[data-col="languages"],
.hh-table td[data-col="top_areas"],
.hh-table td[data-col="languages"] {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidates-table.dt-cols-sized td[data-col="top_locations"],
.candidates-table.dt-cols-sized td[data-col="languages"],
.hh-table.dt-cols-sized td[data-col="top_areas"],
.hh-table.dt-cols-sized td[data-col="languages"] {
  max-width: none;
}

.hh-areas-cell {
  display: block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hh-table.dt-cols-sized .hh-areas-cell {
  max-width: none;
}

/* Numeric columns */
.candidates-table td[data-col="closed_deals"],
.candidates-table td[data-col="experience_since"],
.candidates-table td[data-col="outreach_score"],
.candidates-table td[data-col="star_rating"],
.candidates-table td[data-col="total_deal_value"],
.hh-table td[data-col="closed_deals"],
.hh-table td[data-col="experience_since"],
.hh-table td[data-col="rating"],
.hh-table td[data-col="review_count"],
.hh-table td[data-col="total_properties"],
.hh-table td[data-col="total_deal_volume"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Last row — clean bottom edge */
.candidates-table tbody tr:last-child td,
.hh-table tbody tr:last-child td {
  border-bottom: none;
}

.candidates-table td[data-col="outreach_score"] .badge-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 3px 8px;
  font-size: 0.6875rem;
  font-weight: var(--font-weight-semibold, 600);
  font-variant-numeric: tabular-nums;
  border-radius: 999px;
  background: #F1F5F9;
  color: var(--color-gray-500, #64748B);
  border: 1px solid var(--color-gray-200, #E2E8F0);
}

/* Stage pill */
.candidates-table td[data-col="stage"] .stage-cell-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 10px;
  font-size: 0.6875rem;
  font-weight: var(--font-weight-semibold, 600);
  border-radius: 999px;
  border: 1px solid transparent;
  line-height: 1.3;
  transition: filter 0.12s, box-shadow 0.12s;
}

.candidates-table td[data-col="stage"] .stage-cell-btn:hover {
  filter: brightness(0.97);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.candidates-table td[data-col="stage"] .badge-neutral.stage-cell-btn {
  background: var(--color-gray-100, #F1F5F9);
  color: var(--color-gray-600, #475569);
  border-color: var(--color-gray-200, #E2E8F0);
}

/* Horizontal scroll fade hint */
.candidates-main .table-container::after {
  content: '';
  position: sticky;
  right: 0;
  float: right;
  width: 24px;
  height: 100%;
  margin-right: -24px;
  pointer-events: none;
  background: linear-gradient(to left, rgba(255, 255, 255, 0.9), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.candidates-main .table-container:is(:hover, :focus-within)::after {
  opacity: 1;
}

/* Last row — clean bottom edge */
.candidates-table tbody tr:last-child td,
.hh-table tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Column header filters ---------- */

.dt-col-filter-row th {
  padding: 6px 8px;
  font-weight: var(--font-weight-normal, 400);
  text-transform: none;
  letter-spacing: normal;
  cursor: default;
  background: rgba(248, 250, 252, 0.98);
  border-bottom: 2px solid var(--color-gray-200, #E2E8F0);
  vertical-align: top;
}

.dt-col-filter-row th:first-child {
  padding-left: 16px;
}

.dt-col-filter-cell--empty {
  padding: 6px 8px;
}

.dt-col-filter-cell--active .col-filter-control {
  border-color: var(--color-teal-500, #14B8A6);
  background: rgba(13, 148, 136, 0.04);
}

.candidates-table thead th.dt-header-filter-active,
.hh-table thead tr:first-child th.dt-header-filter-active {
  color: var(--color-teal-700, #0F766E);
  box-shadow: inset 0 -2px 0 var(--color-teal-500, #14B8A6);
}

.col-filter-control {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.35;
  color: var(--color-gray-700, #334155);
  background: #fff;
  border: 1px solid var(--color-gray-200, #E2E8F0);
  border-radius: 6px;
  padding: 5px 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.col-filter-control::placeholder {
  color: var(--color-gray-400, #94A3B8);
  font-weight: 400;
}

.col-filter-control:hover {
  border-color: var(--color-gray-300, #CBD5E1);
}

.col-filter-control:focus {
  outline: none;
  border-color: var(--color-teal-500, #14B8A6);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.12);
}

.col-filter-select {
  cursor: pointer;
  padding-right: 24px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.col-filter-input[type='number'] {
  -moz-appearance: textfield;
}

.col-filter-input[type='number']::-webkit-outer-spin-button,
.col-filter-input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.candidates-table th[data-col='name'],
.hh-table th[data-col='name'] {
  min-width: 140px;
}

.candidates-table .dt-col-filter-cell[data-col='name'] .col-filter-control,
.hh-table .dt-col-filter-cell[data-col='name'] .col-filter-control {
  min-width: 120px;
}
