/* The shared organisation picker: chip and search modal.
 *
 * Phase 4C.26A-visual-2. Values taken from the source estate's
 * `_entity_picker.html`, measured in the browser rather than read off the
 * stylesheet: chip 10px/14px padding on a 10px radius at 14px/600, modal
 * `min(560px, 92vw)` at `clamp(110px, 16vh, 200px)` from the top, 14px radius,
 * results capped at 46vh.
 *
 * Phase 4C.26A-picker withdrew the one departure this file used to make. It
 * had swapped the source's teal `#16a085` for the shell's blue, and the owner's
 * side-by-side said the result was a weaker version of the same control. The
 * teal is the picker's accent in the source on every dashboard that carries
 * one, so it is the accent here: the chosen chip's border, the header glyph,
 * a result's code, the active row's tint and its arrow.
 *
 * Versioned in the filename. No @import, no external origin, no web font.
 */

:root {
  --epick-accent: #16a085;
  /* The accent is 3.1:1 on the active row, too faint for 11px text; this is the same hue, dark enough (4.8:1) for words. */
  --epick-accent-text: #0e7c66;
  --epick-active: #f0faf8;
}

.epick-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #d1d9e0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: #5a6b7b;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
  max-width: 22rem;
}
.epick-chip:hover { border-color: #b6c2cd; }
.epick-chip.is-set { color: #1a2a3b; border-color: var(--epick-accent); }
.epick-chip-value { font-weight: 700; min-width: 0; }
.epick-chip-icon { flex: 0 0 auto; display: flex; color: var(--epick-accent); }
.epick-chip-icon svg { width: 18px; height: 18px; }
.epick-chip-chevron { flex: 0 0 auto; display: flex; margin-left: auto; color: #aab4be; }
.epick-chip-chevron svg { width: 14px; height: 14px; }

/* The modal. `inset: 0` with `align-items: flex-start` is the source's, so the
   box sits near the top rather than centred vertically — a centred dialog whose
   results grow downward moves under the cursor as you type. */
.epick-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.epick-modal[hidden] { display: none; }
.epick-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 30, 42, 0.45);
  backdrop-filter: blur(2px);
}
.epick-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 92vw);
  max-height: 80vh;
  margin-top: clamp(110px, 16vh, 200px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: epick-pop 0.14s ease-out;
}
@keyframes epick-pop {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.epick-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 18px;
  border-bottom: 1px solid #eef1f4;
}
.epick-head-icon { display: flex; color: var(--epick-accent); }
.epick-head-icon svg { width: 17px; height: 17px; }
.epick-title {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #1a2a3b;
}
.epick-close {
  display: flex;
  padding: 4px;
  background: none;
  border: 0;
  border-radius: 6px;
  color: #b6bfc8;
  cursor: pointer;
}
.epick-close:hover { color: #1a2a3b; }
.epick-close svg { width: 18px; height: 18px; }

.epick-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
}
.epick-search-icon { display: flex; color: #b6bfc8; }
.epick-search-icon svg { width: 16px; height: 16px; }
.epick-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  font: inherit;
  font-size: 16px;
  color: #1a2a3b;
}
.epick-hint {
  margin: 0;
  padding: 0 18px 10px;
  font-size: 11.5px;
  color: #5b6672;
}

.epick-results {
  flex: 1;
  min-height: 0;
  max-height: 46vh;
  overflow-y: auto;
  border-top: 1px solid #f0f3f6;
}
.epick-list { list-style: none; margin: 0; padding: 0; }
.epick-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 18px;
  border: 0;
  border-bottom: 1px solid #f5f7f9;
  background: none;
  font: inherit;
  text-align: left;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.epick-item:hover,
.epick-item.is-active { background: var(--epick-active); }
.epick-code {
  flex: 0 0 auto;
  min-width: 62px;
  font-size: 11px;
  font-weight: 700;
  color: var(--epick-accent-text);
  font-variant-numeric: tabular-nums;
}
.epick-name { flex: 1; min-width: 0; font-size: 13.5px; color: #1a2a3b; }
.epick-sub { display: block; font-size: 11.5px; font-weight: 600; color: #5b6672; }
.epick-go { flex: 0 0 auto; display: flex; color: #cdd3da; }
.epick-go svg { width: 15px; height: 15px; }
.epick-item.is-active .epick-go { color: var(--epick-accent); }

.epick-empty {
  margin: 0;
  padding: 24px 18px;
  text-align: center;
  font-size: 13px;
  color: #b6bfc8;
}
.epick-empty.is-error { color: #a4262c; }

/* The focus ring has to clear the row's own background and the box's edge. */
/* Not the search field. It is the only text input in an open dialog and holds
   the caret from the moment the dialog opens, and the source draws no box
   round it; a 3px outline there was the heaviest thing in the modal. */
.epick-input:focus,
.epick-input:focus-visible { outline: none; }
.epick-input { caret-color: var(--epick-accent); }

.epick-chip:focus-visible,
.epick-close:focus-visible,
.epick-item:focus-visible {
  outline: 3px solid var(--epick-accent);
  outline-offset: -3px;
}
.epick-chip:focus-visible { outline-offset: 2px; }

/* The page behind a dialog does not scroll. */
body.picker-open { overflow: hidden; }

@media (max-width: 575px) {
  .epick-box { margin-top: 64px; width: 96vw; max-height: 86vh; }
  .epick-results { max-height: 60vh; }
  .epick-chip { max-width: none; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .epick-chip { transition: none; }
  .epick-box { animation: none; }
}
