/*
 * RingCraft Design V1 — Pipeline command board
 * Presentation-only layer; drag/drop contracts and dynamic IDs are unchanged.
 */

.pipe-filters-bar,
.filters-bar:has(#pipe-search) {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background:
    linear-gradient(90deg, var(--rc-blue) 0 3px, transparent 3px),
    var(--rc-surface);
  border: 1px solid var(--rc-line);
  border-radius: var(--rc-radius-md);
  box-shadow: var(--rc-shadow-sm);
}

.pipe-filter-search-zone {
  flex: 1 1 280px;
  min-width: 220px;
}

.pipe-filter-group {
  display: grid;
  gap: 5px;
  min-width: 128px;
}

.pipe-filter-group label {
  color: var(--rc-muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.pipe-filter-input,
.pipe-filter-select,
.pipe-custom-date-input {
  min-height: 38px;
  color: var(--rc-ink);
  background: var(--rc-surface);
  border: 1px solid var(--rc-line);
  border-radius: 8px;
  font-size: 12px;
}

.pipe-filter-input:hover,
.pipe-filter-select:hover,
.pipe-custom-date-input:hover {
  border-color: var(--rc-line-strong);
}

.pipe-filter-input:focus,
.pipe-filter-select:focus,
.pipe-custom-date-input:focus {
  border-color: var(--rc-blue);
  box-shadow: var(--rc-focus);
  outline: 0;
}

.pipe-custom-date-input {
  font-family: var(--rc-font-mono);
  font-variant-numeric: tabular-nums;
}

.pipe-filter-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pipe-caller-banner-name {
  color: var(--rc-blue);
  font-weight: 700;
}

#pipeline-board {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: calc(100vh - 235px);
  padding: 2px 2px 16px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-color: var(--rc-line-strong) transparent;
}

.pipeline-col {
  flex: 0 0 294px;
  width: 294px;
  max-height: calc(100vh - 238px);
  overflow: hidden;
  background: color-mix(in srgb, var(--rc-surface-muted) 66%, var(--rc-surface));
  border: 1px solid var(--rc-line);
  border-radius: 14px;
  box-shadow: var(--rc-shadow-sm);
  scroll-snap-align: start;
}

.pipeline-col:hover {
  border-color: var(--rc-line-strong);
}

.pipeline-col-header,
.pipe-col-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 11px 12px;
  background: color-mix(in srgb, var(--rc-surface) 94%, transparent);
  border-bottom: 1px solid var(--rc-line);
  backdrop-filter: blur(10px);
}

.pipe-stage-name,
.stage-name {
  color: var(--rc-ink);
  font-size: 11px;
  font-weight: 780;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.pipe-stage-count,
.stage-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 7px;
  color: var(--rc-muted);
  background: var(--rc-surface-muted);
  border: 1px solid var(--rc-line);
  border-radius: 999px;
  font-family: var(--rc-font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.pipeline-cards {
  max-height: calc(100vh - 288px);
  padding: 9px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rc-line-strong) transparent;
}

.pipeline-card {
  position: relative;
  padding: 12px;
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--rc-surface);
  border: 1px solid var(--rc-line);
  border-radius: 11px;
  box-shadow: 0 1px 2px rgba(15, 21, 36, .04);
  cursor: grab;
  transition: transform var(--rc-motion-fast), border-color var(--rc-motion-fast), box-shadow var(--rc-motion-fast), background var(--rc-motion-fast);
}

.pipeline-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--rc-line-strong);
  transition: width var(--rc-motion-fast), background var(--rc-motion-fast);
}

.pipeline-card:hover {
  background: color-mix(in srgb, var(--rc-blue-soft) 22%, var(--rc-surface));
  border-color: color-mix(in srgb, var(--rc-blue) 30%, var(--rc-line));
  box-shadow: 0 8px 20px rgba(15, 21, 36, .08);
  transform: translateY(-2px);
}

.pipeline-card:hover::before {
  width: 3px;
  background: var(--rc-blue);
}

.pipeline-card:active {
  cursor: grabbing;
  transform: scale(.992);
}

.pipe-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.pipe-card-name,
.biz-name {
  overflow: hidden;
  color: var(--rc-ink);
  font-size: 13px;
  font-weight: 720;
  letter-spacing: -.018em;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipe-card-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 6px;
  color: var(--rc-ink);
  background: var(--rc-surface-muted);
  border: 1px solid var(--rc-line);
  border-radius: 999px;
  font-family: var(--rc-font-mono);
  font-size: 10px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.pipe-card-location {
  overflow: hidden;
  margin-bottom: 9px;
  color: var(--rc-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipe-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--rc-line) 75%, transparent);
}

.pipe-card-phone-icon {
  color: var(--rc-blue);
}

.pipe-card-meta-right {
  color: var(--rc-muted);
  font-family: var(--rc-font-mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.pipe-card-outcome {
  display: inline-flex;
  max-width: 100%;
  padding: 3px 7px;
  overflow: hidden;
  color: var(--rc-muted);
  background: var(--rc-surface-muted);
  border: 1px solid var(--rc-line);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Semantic stage hooks, without relying on rainbow cards */
.pipeline-col[id*="BOOKED"] .pipeline-col-header,
.pipeline-col:has([id*="BOOKED"]) .pipeline-col-header {
  box-shadow: inset 3px 0 0 var(--rc-booked);
}

.pipeline-col[id*="BOOKED"] .pipe-stage-count {
  color: var(--rc-booked);
  background: var(--rc-booked-soft);
}

.pipeline-col[id*="WON"] .pipeline-col-header,
.pipeline-col:has([id*="WON"]) .pipeline-col-header {
  box-shadow: inset 3px 0 0 var(--rc-won);
}

.pipeline-col[id*="WON"] .pipe-stage-count {
  color: var(--rc-won);
  background: var(--rc-won-soft);
}

.pipeline-col[id*="DEAD"] .pipeline-col-header,
.pipeline-col:has([id*="DEAD"]) .pipeline-col-header {
  box-shadow: inset 3px 0 0 var(--rc-danger);
}

.pipe-col-empty {
  display: grid;
  place-items: center;
  min-height: 96px;
  padding: 18px;
  color: var(--rc-muted);
  border: 1px dashed var(--rc-line-strong);
  border-radius: 10px;
  font-size: 11px;
  text-align: center;
}

.pipe-cards-loading,
.pipe-cards-loading-full {
  display: grid;
  place-items: center;
  min-height: 84px;
  color: var(--rc-muted);
}

.pipe-load-more {
  width: 100%;
  min-height: 34px;
  color: var(--rc-blue);
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--rc-blue) 32%, var(--rc-line));
  border-radius: 9px;
  font-size: 11px;
  font-weight: 650;
}

.pipe-load-more:hover {
  background: var(--rc-blue-soft);
  border-style: solid;
}

.pipe-load-more-count {
  font-family: var(--rc-font-mono);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1100px) {
  .pipe-filters-bar,
  .filters-bar:has(#pipe-search) {
    flex-wrap: wrap;
  }

  .pipe-filter-search-zone { flex-basis: 100%; }
  .pipe-filter-group { flex: 1 1 150px; }
}

@media (max-width: 700px) {
  .pipe-filters-bar,
  .filters-bar:has(#pipe-search) {
    align-items: stretch;
    padding: 10px;
  }

  .pipe-filter-group,
  .pipe-filter-search-zone {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  .pipe-filter-search-zone { flex-basis: 100%; }
  .pipe-filter-actions { flex: 1 1 100%; }
  .pipe-filter-actions .btn { flex: 1; }

  #pipeline-board {
    min-height: calc(100dvh - 250px);
    margin-inline: -4px;
    padding-inline: 4px;
  }

  .pipeline-col {
    flex-basis: min(86vw, 310px);
    width: min(86vw, 310px);
    max-height: calc(100dvh - 252px);
  }

  .pipeline-cards {
    max-height: calc(100dvh - 304px);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .pipeline-col {
    animation: rc-pipeline-enter 220ms ease-out both;
  }

  .pipeline-col:nth-child(2) { animation-delay: 25ms; }
  .pipeline-col:nth-child(3) { animation-delay: 50ms; }
  .pipeline-col:nth-child(4) { animation-delay: 75ms; }
  .pipeline-col:nth-child(n+5) { animation-delay: 100ms; }

  @keyframes rc-pipeline-enter {
    from { opacity: .72; transform: translateX(5px); }
    to { opacity: 1; transform: translateX(0); }
  }
}

/* -------------------------------------------------------------------------
   Ownership rail
   The renderer already supplies assignee_name or the honest "—" fallback.
   This layout guarantees that ownership remains visible beside activity
   indicators instead of collapsing when cards become narrow.
   ------------------------------------------------------------------------- */

.pipe-card-footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.pipe-card-footer > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipe-card-footer > span:nth-child(1) {
  color: var(--rc-muted);
  flex-shrink: 0;
}

.pipe-card-footer > span:nth-child(2) {
  min-width: 0;
  color: var(--rc-blue);
  font-weight: 650;
  text-align: left;
}

.pipe-card-footer > span:nth-child(3),
.pipe-card-footer > span:nth-child(4) {
  justify-self: end;
  overflow: visible;
  text-overflow: clip;
}

@media (max-width: 700px) {
  .pipe-card-footer {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
  }

  .pipe-card-footer > span:nth-child(4) {
    display: none;
  }
}
