/* SearchSelect fields: the selected pill (single mode) and selection chips
   (multiple mode). See Inputs::FieldSearch::SearchSelectComponent. */

/* Fill the field's row/input-group container by default, same as a plain text
   input — otherwise a selected single-mode pill (e.g. Role) hugs its own
   content and reads as narrower than the other fields in the form. */
.search-select {
  width: 100%;
}

.search-select--selected-container {
  display: flex;
  width: 100%;
  flex-direction: row;
  justify-content: space-between;
  padding: 0.25rem 0.75rem;
  align-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-secondary);
  /* Solid fill like .search-select--field, so the pill doesn't show a grey surface
     behind it (e.g. inside the doc-review modal) and read as disabled/greyed. */
  background-color: white;

  span {
    color: var(--text-body);
    font-size: var(--rem-14);
    line-height: var(--rem-20);
  }
}

.search-select--selected-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

/* Multiple mode: the chips render inside the input box, the type-in area flows
   after them (wrapping below once a row fills), and the field grows with its
   chips up to a cap, then scrolls. */
.search-select--field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-height: 7.5rem;
  overflow-y: auto;
  /* Vertical padding matches .inputs--custom-search so the empty field sits at
     the standard input height; chips make it grow from there. */
  padding: 0.5rem 1rem 0.5rem 0.5rem;
  border-radius: var(--radius-sm);
  background-color: white;
  outline: solid 1px var(--neutral-200);
  box-shadow: 0 2px 3px -2px rgba(169, 179, 188, 0.2);
  cursor: text;

  &:has(input[type="search"]:focus) {
    outline: solid 1px var(--border-focus);
    box-shadow: 0 0 0 2px #D8F4E6;
  }

  /* With chips present the magnifier yields its spot (per the design). */
  &:has(.search-select--selection) [data-field-search-target="searchIcon"] {
    display: none;
  }
}

.search-select--field-icon {
  display: flex;
  align-items: center;
}

/* Typed as input[type="search"] to out-specify the global search input rules —
   inside the field box the input is bare (the box carries the chrome). */
input[type="search"].search-select--field-input {
  flex: 1 0 8rem;
  border: none;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  padding: 0;
  background: none;
  font-size: var(--rem-13);
  line-height: var(--rem-17);

  &:focus {
    outline: none;
    box-shadow: none;
  }
}

/* With chips present, the type-in area always takes its own line below them. */
.search-select--field:has(.search-select--selection) input[type="search"].search-select--field-input {
  flex-basis: 100%;
}

/* Chips participate directly in the field's flex-wrap (display: contents), so an
   empty selections container occupies no space. */
.search-select--selections {
  display: contents;
}

.search-select--selection {
  display: flex;

  /* The selection chip per the design: bordered and roomier than the base chip. */
  .chips--chip {
    border: 1px solid var(--border-secondary);
    padding: 0.25rem 0.5rem;
  }
}
