/* Admin vendor / expert merge flow. Reuses the invoice vendor-match visual
   language (.vendor-match, .vendor-compare, .vendor-match-choices); this file
   adds only the bits specific to merging: the two-record picker, the survivor
   chooser, and the per-field cherry-pick radios inside the compare table. */

.merge-intro {
  max-width: 60ch;
  margin: 0 0 1.25rem;
  color: var(--gray-mid);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Two-record selection (new) */
.merge-select-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

.merge-select-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  align-self: stretch;
}

.merge-select-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.merge-select-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-mid);
}

/* Top-aligned next to the picker inputs (below the uppercase labels). */
.merge-select-amp {
  margin-top: 2rem;
  color: var(--gray-mid);
  font-weight: 600;
}

/* Type-ahead record picker (server-backed; replaces a plain select that can't
   scale to hundreds of vendors/experts). Input matches .filter-input. */
.record-picker {
  flex: 1 1 0;
  min-width: 20rem;
}

/* The search dropdown anchors to the input, not the whole picker (which also
   contains the mini-index below). */
.record-picker-search { position: relative; }

.record-picker .record-picker-input { width: 100%; box-sizing: border-box; }

.record-picker-input {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-input);
  border-radius: 4px;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--gray-dark);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.record-picker-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 153, 153, 0.12);
}

/* A committed pick reads as locked-in until the text is edited again. */
.record-picker--selected .record-picker-input {
  border-color: var(--teal);
  background: var(--teal-light);
  font-weight: 600;
}

.record-picker-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0.25rem 0 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--white);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  max-height: 18rem;
  overflow-y: auto;
}

.record-picker-result {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
}

.record-picker-result.is-active,
.record-picker-result:hover {
  background: var(--teal-light);
}

.record-picker-result-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-dark);
}

.record-picker-result-sublabel {
  font-size: 0.76rem;
  color: var(--gray-mid);
}

.record-picker-empty {
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--gray-mid);
}

/* Browsable mini-index under each picker: the first records, one click to
   select — the search input is only needed beyond these. */
.record-picker-index {
  margin: 0.5rem 0 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 22rem;
  overflow-y: auto;
}

.record-picker-index .record-picker-result.is-selected {
  background: var(--teal-light);
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.record-picker-index-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.76rem;
  color: var(--gray-mid);
}

/* Survivor chooser (review) */
.merge-survivor-help {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--gray-mid);
  line-height: 1.5;
}

.merge-survivor-choice {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.merge-survivor-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 0;
  min-width: 12rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 600;
  color: var(--gray-dark);
  cursor: pointer;
}

.merge-survivor-option:has(input:checked) {
  background: var(--teal-light);
  border-color: var(--teal);
}

/* Per-field cherry-pick radios inside the compare table */
.merge-compare-cell { padding: 0; }

.merge-field-option {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  word-break: break-word;
}

.merge-field-option input { margin-top: 0.15rem; }

.vendor-compare-row--diff .merge-compare-cell:has(input:checked) {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}
