/* Styles for <DropdownNext>. Self-contained — the new dropdown emits no
   .select2-* class aliases and is independent of select2's stylesheet.
   The visual design (gray chips with × on the left, blue highlighted
   options, bold group headers, form-control 38px trigger) replicates
   select2's default theme but every rule below targets only .pd-dd-*
   classes our TSX emits. Verified visually against select2 via
   dev/validate-dropdown-parity.mjs. */

.pd-dd-root {
	position: relative;
	display: inline-block;
	width: 100%;
}

/* ── Trigger (single & multi-chip, non-tags) ─────────────────────────── */

/* Outer trigger shell — keeps the project's form-control look (Bootstrap-y,
 * #ced4da border, 38px min-height). Inner padding (8px left / 20px right)
 * matches select2's `.select2-selection__rendered`, so text and chips sit at
 * the same horizontal offset as in the legacy reference. */
.pd-dd-trigger {
	display: flex;
	align-items: center;
	min-height: 38px;
	padding: 4px 20px 4px 8px;
	background: #fff;
	border: 1px solid #ced4da;
	border-radius: 4px;
	cursor: pointer;
	user-select: none;
	position: relative;
	box-sizing: border-box;
	font-size: 14px;
	color: #212529;
	line-height: 1.4;
}

.pd-dd-trigger.pd-dd-disabled,
.pd-dd-trigger[aria-disabled="true"] {
	background: #e9ecef;
	cursor: not-allowed;
	color: #6c757d;
}

.pd-dd-trigger:focus-visible {
	outline: none;
	border-color: #3b82f6;
}

.pd-dd-root.pd-dd-open .pd-dd-trigger {
	border-bottom-left-radius: 0;
	border-bottom-right-radius: 0;
}

.pd-dd-trigger-text {
	flex: 1;
	min-width: 0;
	color: inherit;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.pd-dd-trigger-text.pd-dd-placeholder {
	color: #999;
}

.pd-dd-trigger-arrow {
	position: absolute;
	right: 1px;
	top: 1px;
	bottom: 1px;
	width: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

.pd-dd-trigger-arrow b {
	display: block;
	width: 0;
	height: 0;
	border: 5px solid transparent;
	border-top-color: #888;
	border-bottom: 0;
}

/* Single-select clear button (× shown when placeholder is set and a value
 * is selected; mirrors select2's allowClear behaviour). Sits on the right of
 * the trigger text, just before the arrow — matches select2's clear-button
 * placement. */
.pd-dd-trigger-clear {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-left: 4px;
	color: #999;
	cursor: pointer;
	font-weight: 700;
	font-size: 14px;
	line-height: 1;
	padding: 0 4px;
	flex-shrink: 0;
}

.pd-dd-trigger-clear:hover {
	color: #444;
}

/* ── Multi-chip selection inside a non-tags trigger ──────────────────── */

.pd-dd-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	flex: 1;
	min-width: 0;
	align-items: center;
}

/* Chip — replicates select2 `.select2-selection__choice` size & colours.
 * Order inside: <text>  <×>  — × on the right, opposite of older select2 but
 * matching modern select2 4.1+ and what users expect today.
 * `min-height: 24px` + `align-items: center` keeps chip content centered
 * vertically regardless of the typography of custom-rendered text. */
.pd-dd-chip {
	display: inline-flex;
	align-items: center;
	background: #e4e4e4;
	color: #212529;
	border: 1px solid #aaa;
	border-radius: 4px;
	padding: 0 5px;
	font-size: 16px;
	line-height: 24px;
	min-height: 24px;
	max-width: 100%;
}

.pd-dd-chip-remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-left: 4px;
	color: #999;
	cursor: pointer;
	font-weight: 700;
	font-size: 14px;
	line-height: 1;
}

.pd-dd-chip-remove:hover {
	color: #444;
}

/* ── Panel (popup over trigger or always-visible in inline mode) ─────── */

.pd-dd-panel {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	z-index: 1051;
	background: #fff;
	border: 1px solid #aaa;
	border-top: none;
	border-bottom-left-radius: 4px;
	border-bottom-right-radius: 4px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	min-width: 200px;
	box-sizing: border-box;
}

/* Viewport-aware drop-up: applied only when there is no room below the trigger
   and more room above (see updatePanelDirection). Mirrors the default panel but
   anchored above the trigger; the default (room-below) case is untouched. */
.pd-dd-panel.pd-dd-open-up {
	top: auto;
	bottom: 100%;
	border-top: 1px solid #aaa;
	border-bottom: none;
	border-top-left-radius: 4px;
	border-top-right-radius: 4px;
	border-bottom-left-radius: 0;
	border-bottom-right-radius: 0;
	box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.pd-dd-panel-inner {
	display: flex;
	flex-direction: column;
	max-height: 320px;
}

.pd-dd-search {
	padding: 4px;
	border-bottom: 1px solid #eee;
}

.pd-dd-search-input {
	width: 100%;
	padding: 4px;
	font-size: 14px;
	line-height: 1.4;
	border: 1px solid #aaa;
	border-radius: 0;
	box-sizing: border-box;
	outline: none;
	color: #212529;
}

.pd-dd-search-input:focus {
	border-color: #5897fb;
}

.pd-dd-results {
	overflow-y: auto;
	max-height: 240px;
}

.pd-dd-results-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* Option row — same look across single, multi, multi-checkboxes, inline,
 * and tags modes. Differences (checkbox prefix, etc.) are layered on top via
 * additional classes — never via parent-mode-specific CSS. */
.pd-dd-option {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px;
	cursor: pointer;
	font-size: 13px;
	line-height: 1.4;
	color: #212529;
	background: transparent;
}

.pd-dd-option--selected,
.pd-dd-option--focused {
	background: #5897fb;
	color: #fff;
}

.pd-dd-option-text {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pd-dd-no-results,
.pd-dd-error {
	padding: 6px;
	color: #6c757d;
	font-style: italic;
}

.pd-dd-error {
	color: #b91c1c;
	font-style: normal;
}

/* `<LoadingIndicator>` brings its own overlay + min-height; the wrapping <li>
 * just needs to be a positioned block so the absolute overlay anchors here
 * (LoadingIndicator's ensureMinHeight already adds `position: relative`). */
.pd-dd-loading {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* Group header — bold, slightly indented, non-interactive */
.pd-dd-group-header {
	padding: 6px;
	font-size: 13px;
	font-weight: 700;
	color: #212529;
	cursor: default;
	pointer-events: none;
}

/* Multi-checkboxes mode: each option row gets a Powerduck-style `form-check`
 * checkbox (NowUi skin, same markup as <CheckBox skin={NowUi} size={Small}>
 * everywhere else in the app). `pointer-events: none` makes the whole
 * checkbox visually-only — clicks pass through to the parent <li> which owns
 * the toggle path. The checkbox's `checked` attribute mirrors the row's
 * selection state via Vue's prop diffing on re-render. */
.pd-dd-cb {
	display: inline-flex;
	align-items: center;
	margin: 0;
	padding: 0;
	pointer-events: none;
	flex-shrink: 0;
}

.pd-dd-cb .form-check-label {
	margin: 0;
	padding: 0;
	min-height: 0;
	cursor: inherit;
}

/* "Add: <typed>" suggestion row appears at the end of the tag-mode option list
 * when nothing matches the typed query. Visually consistent with normal rows. */
.pd-dd-option-add {
	font-style: italic;
}

/* ── Header (OK button for Checkboxes mode) ──────────────────────────── */

/* Mirrors select2's `.s2-cb-btn` from the s2-multi-cb plugin — single
 * commit button anchored at the top of the panel. Used by Checkboxes mode
 * only; multi-chip mode keeps Done/Cancel in the footer below. */
.pd-dd-header {
	padding: 6px;
	border-bottom: 1px solid #eee;
	display: flex;
	justify-content: flex-end;
}

.pd-dd-header .btn {
	font-size: 13px;
	padding: 4px 12px;
}

/* ── Footer (Done button for chip-mode multi-select only) ────────────── */

.pd-dd-footer {
	display: flex;
	justify-content: flex-end;
	gap: 6px;
	padding: 6px;
	border-top: 1px solid #eee;
}

.pd-dd-footer .btn {
	font-size: 13px;
	padding: 4px 10px;
}

/* ── Tags mode ───────────────────────────────────────────────────────── */

.pd-dd-tags-root {
	width: 100%;
}

.pd-dd-tags-trigger {
	min-height: 38px;
	padding: 0;
	background: #fff;
	border: 1px solid #ced4da;
	border-radius: 4px;
	display: block;
	box-sizing: border-box;
}

/* Inner UL mirrors select2's `.select2-selection__rendered`:
 * horizontal padding 5px, no flex gap (each chip carries its own
 * `margin: 5px 5px 0 0` so chips align to the top of the trigger). */
.pd-dd-tags-chips {
	list-style: none;
	margin: 0;
	padding: 0 5px;
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	min-height: 24px;
}

/* Tag chip — matches select2 `.select2-selection__choice` (16px/24px font,
 * 26px effective height, 5px top margin so chips sit just below the trigger
 * border). The 5px top margin (plus chip border + padding) brings each chip
 * to ~32px overall height, near-flush with the trigger's bottom edge. */
.pd-dd-tag-chip {
	display: inline-flex;
	align-items: center;
	background: #e4e4e4;
	color: #212529;
	border: 1px solid #aaa;
	border-radius: 4px;
	padding: 0 5px;
	margin: 5px 5px 0 0;
	font-size: 16px;
	line-height: 24px;
	max-width: 100%;
	cursor: default;
}

.pd-dd-chip-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0 2px;
	color: #4b5563;
	cursor: pointer;
	font-size: 12px;
	padding: 0 2px;
	border-radius: 2px;
}

.pd-dd-chip-action:hover {
	background: #d9d9d9;
	color: #111827;
}

.pd-dd-tag-input-host {
	display: inline-flex;
	flex: 1 1 80px;
	min-width: 80px;
	margin-top: 5px;
}

/* Inline search input that doubles as the placeholder host when the chip
 * list is empty. Uses the same 16px/24px text size as chips so empty
 * placeholder text and any filled value sit on the same baseline. */
.pd-dd-tag-input {
	border: none;
	outline: none;
	background: transparent;
	font-size: 16px;
	line-height: 24px;
	flex: 1;
	min-width: 80px;
	padding: 0;
	margin: 0;
	color: #212529;
	height: 24px;
}

.pd-dd-tag-input:disabled {
	cursor: not-allowed;
}

/* Placeholder colour matches `.pd-dd-trigger-text.pd-dd-placeholder` so the
 * empty-state look in tags mode is identical to single-select. */
.pd-dd-tag-input::placeholder {
	color: #999;
	opacity: 1;
}

/* Sortable.js dragging affordance */
.pd-dd-tag-chip.sortable-ghost {
	opacity: 0.4;
}

.pd-dd-tag-chip.sortable-chosen {
	background: #cbd5e0;
	border-color: #5897fb;
}

/* ── Inline mode ─────────────────────────────────────────────────────── */

.pd-dd-inline {
	width: 100%;
}

.pd-dd-panel-inline {
	position: static;
	box-shadow: none;
	margin: 0;
	min-width: 0;
}

.pd-dd-panel-inline .pd-dd-panel-inner {
	max-height: none;
}

.pd-dd-panel-inline .pd-dd-results {
	max-height: none;
}

/* Migration sentinel: MIGRATION.md tells consumers to replace the deprecated
 * `afterBound` animation-disable hook with `cssClass="pd-dd-no-animation"`.
 * The base component currently has no open/close transitions, so the class
 * acts as a no-op marker today. Keep the selector here so any future
 * animation rules can opt out via `:not(.pd-dd-no-animation)` and the
 * promised migration target stays a real class. */
.pd-dd-root.pd-dd-no-animation,
.pd-dd-root.pd-dd-no-animation .pd-dd-panel {
	transition: none !important;
	animation: none !important;
}
