/* =========================================================================
   Genealore People Search  (assets/js/genealore_people_search.js)
   A reusable people picker that replaces Select2. Modelled on the family-tree
   search. Uses the shared --gl-* admin tokens when present, with literal
   fallbacks so it also works on the front end (e.g. the tree page).
   ========================================================================= */
.gl-ps {
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.gl-ps-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--gl-fh, 40px);
  padding: 4px 10px;
  border: 0.5px solid var(--gl-bd, rgba(0, 0, 0, 0.18));
  border-radius: var(--gl-r, 6px);
  background: var(--gl-wh, #fff);
  cursor: text;
}
.gl-ps-control:focus-within {
  border-color: var(--gl-ac, #2c6fad);
  box-shadow: 0 0 0 2px rgba(44, 111, 173, 0.12);
}

.gl-ps-icon {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--gl-mu, #9aa092);
}

.gl-ps-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
  color: var(--gl-tx, #1a1a1a);
  padding: 4px 0;
  box-shadow: none;
  min-height: 0;
}
.gl-ps-input:focus { outline: 0; box-shadow: none; }

/* Selected value pill */
.gl-ps-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  background: var(--gl-acl, #e8f1f8);
  color: var(--gl-acm, #185fa5);
  font-size: 13px;
  font-weight: 500;
}
.gl-ps-chip-new {
  background: var(--gl-amb, #fef3c7);
  color: var(--gl-am, #92400e);
}
.gl-ps-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gl-ps-chip-label em { font-style: normal; opacity: 0.7; }
.gl-ps-clear {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.gl-ps-clear:hover { background: rgba(0, 0, 0, 0.18); }

/* Results dropdown */
.gl-ps-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 70;
  display: none;
  max-height: 320px;
  overflow-y: auto;
  background: var(--gl-wh, #fff);
  border: 0.5px solid var(--gl-bd, #e0dac9);
  border-radius: var(--gl-rl, 10px);
  box-shadow: 0 18px 40px rgba(40, 55, 46, 0.18);
}
.gl-ps-menu.is-open { display: block; }

.gl-ps-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
}
.gl-ps-opt:last-child { border-bottom: 0; }
.gl-ps-opt:hover,
.gl-ps-opt.is-active { background: var(--gl-acl, #e8f1f8); }

.gl-ps-opt-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.gl-ps-opt-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gl-tx, #26302a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gl-ps-opt-id {
  font-size: 11px;
  font-weight: 600;
  color: var(--gl-mu, #8a8473);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}
.gl-ps-opt-dates {
  font-size: 12px;
  color: var(--gl-mu, #8a8473);
  margin-left: auto;
  flex: 0 0 auto;
}

/* Member id appended to the selected pill (e.g. "Anna Smith #7352"). */
.gl-ps-chip-id {
  opacity: 0.65;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Avatar */
.gl-ps-avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #9aa092;
}
.gl-ps-avatar img { width: 100%; height: 100%; object-fit: cover; }
.gl-ps-avatar-m { background: #6c8ebf; }
.gl-ps-avatar-f { background: #c98aa6; }
.gl-ps-avatar-u { background: #9aa092; }

/* Create-new row */
.gl-ps-create { color: var(--gl-ac, #2c6fad); font-weight: 600; }
.gl-ps-create .gl-ps-opt-name { color: inherit; }
.gl-ps-create-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--gl-acl, #e8f1f8);
  color: var(--gl-ac, #2c6fad);
  font-size: 18px;
  font-weight: 700;
  flex: 0 0 auto;
}

.gl-ps-empty {
  padding: 12px;
  font-size: 13px;
  color: var(--gl-mu, #8a8473);
}
