/* ==========================================================================
   Shared dropdown — the ONE dropdown for the whole admin (see js/modules/
   dropdown.js). A styled trigger (.dd-trigger) replaces every native <select>;
   the option panel (.dd-pop) is portalled onto <body> with position:fixed, so
   it is never clipped and rides the anchor on scroll. Mirrors the /#users
   combobox 1:1. All colours are tokens → both themes work automatically.
   The native <select> stays in the DOM (hidden) as the value source.
   ========================================================================== */

/* ---- Trigger (lives inside .admin-main, replaces the select visually) ---- */
.admin-main .dd-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-strong);
  font: 500 13px/1.25 var(--font-ui);
  cursor: pointer;
  text-align: left;
  vertical-align: middle;
  background-image: none;          /* kill any inherited native-select arrow */
  transition: border-color .15s ease, background-color .15s ease;
}
.admin-main .dd-trigger--auto { width: auto; min-width: 96px; max-width: 260px; }
.admin-main .dd-trigger--block { width: 100%; }
.admin-main .dd-trigger:hover:not([disabled]) { border-color: var(--border-hover); background: var(--card-bg); }
.admin-main .dd-trigger[aria-expanded="true"] { border-color: var(--accent); }
.admin-main .dd-trigger[disabled] { opacity: .45; cursor: default; }
.admin-main .dd-trigger[hidden] { display: none !important; }
.admin-main .dd-trigger__label {
  flex: 1 1 auto;
  min-width: 0;
  /* Never truncate the selected value — wrap long labels instead. */
  white-space: normal;
  overflow: visible;
  line-height: 1.25;
}
.admin-main .dd-trigger__caret { flex: 0 0 auto; display: inline-flex; color: var(--text-muted); }
.admin-main .dd-trigger__caret svg { width: 16px; height: 16px; }

/* the native <select> is kept for value/change/submit, just hidden */
.admin-main select.dd-native { display: none !important; }

/* ---- Portal panel (direct child of <body>, outside .admin-main) ---------- */
.dd-pop,
body > .dd-pop {
  position: fixed;
  z-index: 1000000;                /* above every admin modal/overlay (<=99999) */
  display: flex;
  flex-direction: column;
  max-height: 380px;
  padding: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: ddPopIn .14s ease;
}
@keyframes ddPopIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
/* Flex pass-through: keeps `.dd-pop`'s column layout flowing to the list so its
   overflow-y scroll actually engages inside the 380px panel (see dropdown.js). */
.dd-pop__inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}
.dd-pop__search {
  position: relative;
  flex: 0 0 auto;               /* fixed header — never compresses when the list scrolls */
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--border);
}
.dd-pop__search-ic { display: inline-flex; color: var(--text-muted); }
.dd-pop__search-ic svg { width: 15px; height: 15px; }
.dd-pop__search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font: 500 13.5px var(--font-ui);
  color: var(--text-strong);
}
.dd-pop__list {
  flex: 1 1 auto;
  min-height: 0;                /* allow the list to shrink below its content so
                                   its own overflow-y scroll engages inside the
                                   max-height:380px panel (long account lists). */
  overflow-y: auto;
  overscroll-behavior: contain; /* wheel/touch at the list edges never chains to
                                   the page (paired with the JS wheel-capture in
                                   dropdown.js openPopover). */
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
}
.dd-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-strong);
  font: 500 12.5px/1.3 var(--font-ui);
  text-align: left;
  cursor: pointer;
  transition: background-color .12s ease;
}
/* Show the full option text — wrap onto a second line rather than clip it. */
.dd-option__label { flex: 1 1 auto; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.dd-option__check { flex: 0 0 auto; display: inline-flex; color: var(--accent); }
.dd-option__check svg { width: 14px; height: 14px; }
.dd-option:hover,
.dd-option.is-active,
.dd-option.is-selected { background: var(--bg-surface); }
.dd-option.is-disabled { opacity: .4; cursor: default; }
.dd-option[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .dd-pop, body > .dd-pop { animation: none; }
  .admin-main .dd-trigger, .dd-option { transition: none; }
}
