/* ==================================================================
   Мои вакансии — funnel pivot.
   Density goal: 8 stage columns + spine fit into the 1400px main area
   without horizontal scroll; a full recruiter view (≤10 vacancies with
   active candidates) stays within one viewport vertically.
   Palette is restricted to the project's amber/red/neutral — no new hues.
   ================================================================== */

.hr-funnel-section { position: relative; }

/* Expand-all toggle in the section header — small, unobtrusive */
.hr-funnel-toggle-all {
  padding: 5px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.hr-funnel-toggle-all:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #f59e0b;
}
.hr-funnel-toggle-all:active {
  transform: scale(0.97);
}

/* Live indicator next to section title — reuses existing pulse colour */
.hr-funnel-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  padding-top: 2px;
}
.hr-funnel-live::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.7);
  animation: funnel-live-pulse 2s ease-in-out infinite;
}
@keyframes funnel-live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* No overflow on desktop: overflow-x would force overflow-y to auto (per spec),
   making this a scroll ancestor and breaking viewport-sticky thead. */
.hr-funnel-wrap {
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.25) transparent;
}
.hr-funnel-wrap::-webkit-scrollbar { height: 6px; }
.hr-funnel-wrap::-webkit-scrollbar-thumb { background: rgba(245, 158, 11, 0.2); border-radius: 3px; }

.hr-funnel {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  table-layout: fixed; /* prevents any single long vacancy name from pushing columns wider */
}

/* ============= Head ============= */

.hr-funnel thead th {
  position: sticky;
  top: var(--site-header-height, 96px);
  z-index: 5;
  background: rgba(18, 22, 30, 0.98);
  backdrop-filter: blur(12px);
  padding: 10px 10px 8px;
  text-align: left;
  font-weight: 400;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 16px -12px rgba(0, 0, 0, 0.5);
}

.hr-funnel-head {
  /* 124px accommodates longer ТЗ-verbatim labels («Отправлен заказчику», «ТИ с
     заказчиком») on 2 lines. 8 × 124 + 220 spine = 1212px — fits in 1400px main area. */
  width: 124px;
  min-width: 124px;
  vertical-align: top;
}

.funnel-head-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.funnel-head-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.22);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: #f59e0b;
  flex-shrink: 0;
}

.funnel-head-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.2;
  /* Wrap to 2 lines so «Первый контакт» / «Отпр. клиенту» fit the 116px column
     without ellipsis. Ellipsis on column headers reads as incomplete data. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.funnel-head-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

.funnel-count {
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
}
.funnel-count[data-positive="1"] {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.funnel-breach {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  font-weight: 600;
}
.funnel-breach::before {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 5px rgba(239, 68, 68, 0.8);
  animation: funnel-breach-pulse 2.4s ease-in-out infinite;
}
@keyframes funnel-breach-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============= Sticky spine (vacancy meta) ============= */

.hr-funnel-spine {
  position: sticky;
  left: 0;
  z-index: 3;
  background: rgba(18, 22, 30, 0.98);
  backdrop-filter: blur(12px);
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  padding: 10px 28px 10px 12px !important; /* right padding = space for chevron */
  cursor: pointer;
  user-select: none;
}
.hr-funnel thead .hr-funnel-spine {
  z-index: 4;
  cursor: default;
  padding-right: 10px !important;
}

.funnel-spine-chevron {
  position: absolute;
  top: 14px;
  right: 10px;
  width: 10px;
  height: 10px;
  transform: rotate(0deg);
  color: rgba(255, 255, 255, 0.35);
  transition: transform 0.2s ease, color 0.2s ease;
  pointer-events: none;
}
.hr-funnel tbody tr[data-expanded="true"] .funnel-spine-chevron {
  transform: rotate(90deg);
  color: #f59e0b;
}
.hr-funnel-spine:hover .funnel-spine-chevron {
  color: rgba(255, 255, 255, 0.75);
}

/* Empty cell placeholder — center horizontally, but top-aligned by td rule above */
.cell-chips-empty {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.18);
  text-align: center;
  padding: 6px 0 0;
  letter-spacing: 0.04em;
}

.funnel-spine-card { display: flex; flex-direction: column; gap: 2px; }

.funnel-spine-recruiter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
  letter-spacing: 0.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.funnel-spine-vacancy {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.25;
  margin-top: 2px;
  /* Clamp to 2 lines so the row height is bounded */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.funnel-spine-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.04em;
}

.funnel-spine-chip {
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  text-transform: uppercase;
}
.funnel-spine-chip.is-tier {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  padding: 0 5px;
}
.funnel-spine-chip.is-plan {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0 5px;
  font-weight: 600;
}
.funnel-spine-chip.is-customer {
  color: rgba(255, 255, 255, 0.75);
  text-transform: none;
  letter-spacing: 0.01em;
}
.funnel-spine-chip.is-count {
  color: #34d399;
  background: rgba(16, 185, 129, 0.1);
  font-weight: 600;
}
.funnel-spine-chip.is-breach {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  font-weight: 600;
}
.funnel-spine-chip.is-empty {
  color: rgba(255, 255, 255, 0.3);
  text-transform: none;
  background: transparent;
  padding: 0;
  font-style: italic;
}

/* ============= Body ============= */

.hr-funnel tbody tr { transition: background 0.15s ease; }
.hr-funnel tbody tr:hover { background: rgba(245, 158, 11, 0.025); }
.hr-funnel tbody tr:hover .hr-funnel-spine {
  background: rgba(22, 26, 36, 0.99);
}

.hr-funnel tbody td {
  padding: 8px 6px;
  /* top-aligned: in tall rows (e.g. 10+ chips in one stage) sparse cells must keep
     their content at the row header, not drift to the middle. */
  vertical-align: top;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
}
.hr-funnel tbody tr:last-child td { border-bottom: none; }

/* Tight padding for collapsed rows → 44px row height */
.hr-funnel tbody tr[data-expanded="false"] td { padding: 6px 6px; }
.hr-funnel tbody tr[data-expanded="false"] .hr-funnel-spine { padding: 8px 28px 8px 12px !important; }
.hr-funnel tbody tr[data-expanded="false"] .funnel-spine-meta { margin-top: 3px; }

/* Cell pill (collapsed): single count chip per cell. CSS swaps between pill and
   full chip list — no JS re-render needed when toggling rows. */
.hr-funnel-cell .cell-pill { display: none; }
.hr-funnel-cell .cell-chips { display: none; }
.hr-funnel tbody tr[data-expanded="false"] .hr-funnel-cell .cell-pill { display: inline-flex; }
.hr-funnel tbody tr[data-expanded="true"]  .hr-funnel-cell .cell-chips { display: block; }

.cell-pill {
  align-items: center;
  gap: 5px;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.04);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
}
.cell-pill[data-has="1"] {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
}
.cell-pill[data-breach="1"] {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
}
.cell-pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
  flex-shrink: 0;
}
.cell-pill[data-has="0"]::before { opacity: 0.35; }

/* Expanded cell: chip column with max-height ≈ 10 chips + scroll for overflow */
.cell-chips {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.3) transparent;
}
.cell-chips::-webkit-scrollbar { width: 4px; }
.cell-chips::-webkit-scrollbar-track { background: transparent; }
.cell-chips::-webkit-scrollbar-thumb { background: rgba(245, 158, 11, 0.2); border-radius: 2px; }
.cell-chips::-webkit-scrollbar-thumb:hover { background: rgba(245, 158, 11, 0.45); }

/* Soft fade at bottom of overflowing cells — hint that there are more chips below.
   :has() check triggers only when 11+ chips present (scroll threshold). */
.cell-chips:has(> .funnel-chip:nth-child(11)) {
  mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent);
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent);
}

.hr-funnel-empty {
  text-align: center;
  color: rgba(255, 255, 255, 0.12);
  font-size: 13px;
  user-select: none;
}

.hr-funnel-empty-state {
  padding: 60px 20px !important;
  text-align: center;
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
}

/* ============= Candidate chip ============= */

.funnel-chip {
  position: relative;
  display: block;
  padding: 5px 8px 5px 10px;
  margin-bottom: 3px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-family: 'Outfit', sans-serif;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
  cursor: default;
  overflow: hidden;
}
.funnel-chip:last-child { margin-bottom: 0; }

.funnel-chip::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.15);
}

.funnel-chip:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(245, 158, 11, 0.3);
}

.funnel-chip[data-sla="warn"] {
  background: rgba(245, 158, 11, 0.05);
  border-color: rgba(245, 158, 11, 0.18);
}
.funnel-chip[data-sla="warn"]::before { background: #f59e0b; }

.funnel-chip[data-sla="breach"] {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.22);
}
.funnel-chip[data-sla="breach"]::before { background: #ef4444; }

.funnel-chip-name {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.funnel-chip-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 1px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.48);
}

.funnel-chip-days {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}
.funnel-chip[data-sla="warn"] .funnel-chip-days { color: #fbbf24; }
.funnel-chip[data-sla="breach"] .funnel-chip-days { color: #fca5a5; }

/* Narrow screens re-enable horizontal scroll; the wrap becomes the sticky
   ancestor, so thead pins to the wrap's top (0) rather than the viewport. */
@media (max-width: 1279px) {
  .hr-funnel-wrap { overflow-x: auto; }
  .hr-funnel { min-width: 1220px; }
  .hr-funnel thead th { top: 0; }
}
