/* 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(--md-sys-color-on-surface-variant);
  font: var(--md-sys-typescale-body-large);
  letter-spacing: var(--md-sys-typescale-body-large-tracking);
}

/* 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: var(--md-sys-typescale-label-medium);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

/* Top-aligned next to the picker inputs (below the labels). */
.merge-select-amp {
  margin-top: 2rem;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
}

/* 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 {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  font: var(--md-sys-typescale-body-large);
  letter-spacing: var(--md-sys-typescale-body-large-tracking);
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container-lowest);
  outline: none;
  transition:
    border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
    box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.record-picker-input:hover {
  border-color: var(--md-sys-color-on-surface);
}

.record-picker-input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
}

/* A committed pick reads as locked-in until the text is edited again. */
.record-picker--selected .record-picker-input {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 500;
}

/* Search results: an M3 menu floating over the page. */
.record-picker-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0.25rem 0 0;
  padding: 0.5rem 0;
  list-style: none;
  background: var(--md-sys-color-surface-container);
  border: none;
  border-radius: var(--md-sys-shape-corner-extra-small);
  box-shadow: var(--md-sys-elevation-level2);
  max-height: 18rem;
  overflow-y: auto;
}

.record-picker-result {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0;
  cursor: pointer;
}

.record-picker-result.is-active,
.record-picker-result:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.record-picker-result-label {
  font: var(--md-sys-typescale-body-large);
  letter-spacing: var(--md-sys-typescale-body-large-tracking);
  color: var(--md-sys-color-on-surface);
}

.record-picker-result-sublabel {
  font: var(--md-sys-typescale-body-small);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

.record-picker-empty {
  padding: 0.5rem 0.75rem;
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  font-style: italic;
  color: var(--md-sys-color-on-surface-variant);
}

/* Browsable mini-index under each picker: the first records, one click to
   select — the search input is only needed beyond these. A filled card. */
.record-picker-index {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0;
  list-style: none;
  background: var(--md-sys-color-surface-container-low);
  border: none;
  border-radius: var(--md-sys-shape-corner-small);
  max-height: 22rem;
  overflow-y: auto;
}

.record-picker-index .record-picker-result.is-selected {
  background: var(--md-sys-color-secondary-container);
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: -2px;
}

.record-picker-index-hint {
  display: block;
  margin-top: 0.35rem;
  font: var(--md-sys-typescale-body-small);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

/* Survivor chooser (review) */
.merge-survivor-help {
  margin: 0 0 0.75rem;
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

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

/* Outlined selectable card; the checked one fills with secondary-container. */
.merge-survivor-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 0;
  min-width: 12rem;
  padding: 0.75rem 1rem;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  font: var(--md-sys-typescale-title-small);
  letter-spacing: var(--md-sys-typescale-title-small-tracking);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition:
    background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
    border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.merge-survivor-option:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, var(--md-sys-color-surface-container-lowest));
}

.merge-survivor-option:has(input:checked) {
  background: var(--md-sys-color-secondary-container);
  border-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

/* 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(--md-sys-color-primary);
  outline-offset: -2px;
}
