/* Reusable entity picker widget.  Loaded alongside entity-picker.js.
   Uses CSS custom properties from cgj_base.html — no hardcoded colors. */

.entity-picker {
  display: grid;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--ink);
}

/* --- Label --- */
.entity-picker__label {
  font-size: 0.8125rem;
  color: var(--ink-soft);
  font-weight: 600;
}

/* --- Chip strip (selected tokens + empty pill) --- */
.entity-picker__chip-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  min-height: 1.75rem;
}

.entity-picker__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8125rem;
  line-height: 1.4;
  white-space: nowrap;
}

.entity-picker__chip--selected {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
}

.entity-picker__chip--empty {
  background: transparent;
  color: var(--ink-soft);
  border: 1px dashed var(--rule);
  font-style: italic;
}

.entity-picker__chip-remove {
  appearance: none;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0 0.1rem;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.75;
  transition: opacity 0.1s;
}
.entity-picker__chip-remove:hover {
  opacity: 1;
}
.entity-picker__chip-remove:focus {
  outline: 2px solid var(--ochre);
  outline-offset: 1px;
}

/* --- Search input --- */
.entity-picker__search {
  width: 100%;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.entity-picker__search:focus {
  outline: 2px solid var(--ochre);
  outline-offset: 1px;
  border-color: var(--ochre-soft);
}
.entity-picker__search::placeholder {
  color: var(--ink-mute);
}

/* --- Scrollable option list (search mode) --- */
.entity-picker__list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper);
}

/* --- Option rows (both modes) --- */
.entity-picker__option {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  color: var(--ink);
  border-radius: 3px;
  transition: background 0.1s;
  outline: none;
}

/* Chip-only mode: options render inline */
.entity-picker__chips .entity-picker__option {
  display: inline-flex;
  border: 1px solid var(--rule);
  background: var(--leaf);
  margin: 0;
  font-size: 0.8125rem;
}

/* List-mode options */
.entity-picker__list .entity-picker__option {
  border-radius: 0;
  border-bottom: 1px solid var(--rule-soft);
}
.entity-picker__list .entity-picker__option:last-child {
  border-bottom: none;
}

.entity-picker__option:hover:not([aria-disabled="true"]),
.entity-picker__option:focus:not([aria-disabled="true"]) {
  background: var(--rule-soft);
}

.entity-picker__option--selected {
  background: var(--ink) !important;
  color: var(--paper) !important;
  border-color: var(--ink) !important;
}

.entity-picker__option--selected:hover,
.entity-picker__option--selected:focus {
  background: var(--ink-soft) !important;
}

.entity-picker__option--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Checkmark in list-mode selected rows */
.entity-picker__check {
  flex-shrink: 0;
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.9;
}

/* --- Notices (limit reached, no matches) --- */
.entity-picker__notice {
  font-size: 0.8125rem;
  color: var(--ink-mute);
  padding: 0.4rem 0.6rem;
  font-style: italic;
}

.entity-picker__notice--cap {
  color: var(--ochre);
  font-style: normal;
  font-weight: 500;
}
