/* ============================================================
   Select2 Custom Theme — WorkFlow Suite
   Matches admin.css / auth.css color tokens.
   NO backdrop-filter anywhere.
   ============================================================ */

/* CSS vars fallback (in case Select2 is loaded outside admin layout) */
:root {
	--s2-primary: var(--adm-primary, #00a1ff);
	--s2-primary-dark: var(--adm-primary-dark, #0086d6);
	--s2-ink: var(--adm-ink, #0f2746);
	--s2-ink-soft: var(--adm-ink-soft, #4b5b75);
	--s2-muted: var(--adm-muted, #8a9bb1);
	--s2-line: var(--adm-line, #e3edf5);
	--s2-bg: #ffffff;
	--s2-hover: #f3f8fd;
	--s2-radius: 8px;
}

/* -----------------------------------------------------------
   1. Closed select (the "selection" box)
   ----------------------------------------------------------- */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
	min-height: 40px;
	border: 1px solid var(--s2-line) !important;
	border-radius: var(--s2-radius) !important;
	background: var(--s2-bg);
	transition: border-color .15s ease, box-shadow .15s ease;
	padding: 2px 4px;
	font-family: inherit;
}

.select2-container--default .select2-selection--single:hover,
.select2-container--default .select2-selection--multiple:hover {
	border-color: var(--s2-primary) !important;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--multiple {
	border-color: var(--s2-primary) !important;
	box-shadow: 0 0 0 3px rgba(0, 161, 255, 0.15) !important;
	outline: none !important;
}

/* Single select - text alignment */
.select2-container--default .select2-selection--single {
	height: 40px;
	display: flex;
	align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
	color: var(--s2-ink);
	font-weight: 500;
	line-height: 36px;
	padding-left: 12px;
	padding-right: 32px;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder {
	color: var(--s2-muted);
	font-weight: 500;
}

/* Single select - arrow */
.select2-container--default .select2-selection--single .select2-selection__arrow {
	height: 38px;
	top: 1px;
	right: 6px;
	width: 24px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b {
	border-color: var(--s2-ink-soft) transparent transparent transparent;
	border-width: 6px 5px 0 5px;
	margin-left: -5px;
	margin-top: -3px;
}
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
	border-color: transparent transparent var(--s2-primary) transparent;
	border-width: 0 5px 6px 5px;
}

/* Single select - clear (x) button */
.select2-container--default .select2-selection--single .select2-selection__clear {
	color: var(--s2-muted);
	font-weight: 700;
	margin-right: 20px;
	padding: 0 4px;
	border-radius: 4px;
	transition: all .15s;
}
.select2-container--default .select2-selection--single .select2-selection__clear:hover {
	color: var(--s2-primary, #c81e3f);
	background: rgba(200, 30, 63, 0.08);
}

/* -----------------------------------------------------------
   2. Multi-select pills (polished)
   ----------------------------------------------------------- */
.select2-container--default .select2-selection--multiple {
	padding: 4px 6px;
	min-height: 40px;
}
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	align-items: center;
}

/* Default pill — primary blue gradient */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
	background: linear-gradient(135deg, var(--s2-primary), var(--s2-primary-dark));
	color: #fff;
	border: 0 !important;
	border-radius: 999px !important;
	padding: 4px 12px 4px 4px !important;
	margin: 2px 0 !important;
	font-size: 12.5px;
	font-weight: 600;
	line-height: 1.4;
	display: inline-flex !important;
	align-items: center;
	gap: 6px;
	cursor: default;
	user-select: none;
	box-shadow:
		0 2px 5px rgba(0, 134, 214, 0.28),
		inset 0 1px 0 rgba(255, 255, 255, 0.18),
		inset 0 -1px 0 rgba(0, 0, 0, 0.06);
	transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
	animation: s2-pill-in .22s cubic-bezier(.22, 1, .36, 1);
	position: relative;
	overflow: hidden;
}

@keyframes s2-pill-in {
	0%   { opacity: 0; transform: scale(.75) translateY(2px); }
	60%  { opacity: 1; transform: scale(1.04) translateY(0); }
	100% { opacity: 1; transform: scale(1); }
}

/* Subtle inner shimmer on hover */
.select2-container--default .select2-selection--multiple .select2-selection__choice:hover {
	transform: translateY(-1px);
	filter: brightness(1.06);
	box-shadow:
		0 5px 12px rgba(0, 134, 214, 0.36),
		inset 0 1px 0 rgba(255, 255, 255, 0.22),
		inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

/* Display text inside choice (Select2 v4 uses __display) */
.select2-container--default .select2-selection--multiple .select2-selection__choice__display {
	padding: 0 !important;
	margin: 0 !important;
}

/* × remove button — circular, rotate on hover */
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
	color: #fff !important;
	font-weight: 700;
	font-size: 13px;
	line-height: 1;
	width: 18px;
	height: 18px;
	min-width: 18px;
	border-radius: 50% !important;
	margin: 0 !important;
	border: 0 !important;
	background: rgba(255, 255, 255, 0.22) !important;
	padding: 0 !important;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	transition: background .18s ease, transform .25s ease, box-shadow .18s ease;
	cursor: pointer;
	flex-shrink: 0;
	order: -1;   /* keep × on the left, before text */
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
	background: rgba(255, 255, 255, 0.45) !important;
	color: #fff !important;
	transform: rotate(90deg) scale(1.08);
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:active {
	transform: rotate(90deg) scale(0.95);
}

/* Pill leaving (added by JS before removal, optional) */
.select2-container--default .select2-selection--multiple .select2-selection__choice.s2-pill-leaving {
	animation: s2-pill-out .18s ease forwards;
}
@keyframes s2-pill-out {
	to { opacity: 0; transform: scale(.7) translateY(-2px); }
}

/* Inline search field (typing more values) */
.select2-container--default .select2-search--inline .select2-search__field {
	color: var(--s2-ink);
	font-family: inherit;
	font-size: 14px;
	margin-top: 4px;
	margin-left: 4px;
	min-width: 60px;
}

/* ------------------------------------------------------------
   2b. Semantic color variants — driven by data-s2-val
        (auto-applied by select2-init.js based on option value)
   ------------------------------------------------------------ */

/* Reusable mixin via attribute selectors */

/* ---- GREEN (success / active / won / service) ---- */
.select2-selection__choice[data-s2-val="active"],
.select2-selection__choice[data-s2-val="won"],
.select2-selection__choice[data-s2-val="service"] {
	background: linear-gradient(135deg, #2ddca0, #00b07a) !important;
	box-shadow:
		0 2px 5px rgba(0, 176, 122, 0.30),
		inset 0 1px 0 rgba(255, 255, 255, 0.20),
		inset 0 -1px 0 rgba(0, 0, 0, 0.08) !important;
}
.select2-selection__choice[data-s2-val="active"]:hover,
.select2-selection__choice[data-s2-val="won"]:hover,
.select2-selection__choice[data-s2-val="service"]:hover {
	box-shadow:
		0 5px 12px rgba(0, 176, 122, 0.42),
		inset 0 1px 0 rgba(255, 255, 255, 0.25),
		inset 0 -1px 0 rgba(0, 0, 0, 0.10) !important;
}

/* ---- RED (danger / suspended / lost / urgent) ---- */
.select2-selection__choice[data-s2-val="suspended"],
.select2-selection__choice[data-s2-val="lost"],
.select2-selection__choice[data-s2-val="urgent"] {
	background: linear-gradient(135deg, #ef5b7d, #c81e3f) !important;
	box-shadow:
		0 2px 5px rgba(200, 30, 63, 0.30),
		inset 0 1px 0 rgba(255, 255, 255, 0.20),
		inset 0 -1px 0 rgba(0, 0, 0, 0.08) !important;
}
.select2-selection__choice[data-s2-val="suspended"]:hover,
.select2-selection__choice[data-s2-val="lost"]:hover,
.select2-selection__choice[data-s2-val="urgent"]:hover {
	box-shadow:
		0 5px 12px rgba(200, 30, 63, 0.42),
		inset 0 1px 0 rgba(255, 255, 255, 0.25),
		inset 0 -1px 0 rgba(0, 0, 0, 0.10) !important;
}

/* ---- AMBER (warning / pending / proposal / high) — dark ink for contrast ---- */
.select2-selection__choice[data-s2-val="pending"],
.select2-selection__choice[data-s2-val="proposal"],
.select2-selection__choice[data-s2-val="high"] {
	background: linear-gradient(135deg, #ffc578, #ff9f43) !important;
	color: #432200 !important;
	box-shadow:
		0 2px 5px rgba(255, 159, 67, 0.35),
		inset 0 1px 0 rgba(255, 255, 255, 0.30),
		inset 0 -1px 0 rgba(0, 0, 0, 0.06) !important;
}
.select2-selection__choice[data-s2-val="pending"]:hover,
.select2-selection__choice[data-s2-val="proposal"]:hover,
.select2-selection__choice[data-s2-val="high"]:hover {
	box-shadow:
		0 5px 12px rgba(255, 159, 67, 0.48),
		inset 0 1px 0 rgba(255, 255, 255, 0.35),
		inset 0 -1px 0 rgba(0, 0, 0, 0.08) !important;
}
.select2-selection__choice[data-s2-val="pending"] .select2-selection__choice__remove,
.select2-selection__choice[data-s2-val="proposal"] .select2-selection__choice__remove,
.select2-selection__choice[data-s2-val="high"] .select2-selection__choice__remove {
	color: #432200 !important;
	background: rgba(67, 34, 0, 0.18) !important;
}
.select2-selection__choice[data-s2-val="pending"] .select2-selection__choice__remove:hover,
.select2-selection__choice[data-s2-val="proposal"] .select2-selection__choice__remove:hover,
.select2-selection__choice[data-s2-val="high"] .select2-selection__choice__remove:hover {
	background: rgba(67, 34, 0, 0.32) !important;
}

/* ---- BLUE (info / contacted / business / normal / manufacturing) ---- */
.select2-selection__choice[data-s2-val="contacted"],
.select2-selection__choice[data-s2-val="business"],
.select2-selection__choice[data-s2-val="normal"],
.select2-selection__choice[data-s2-val="manufacturing"] {
	background: linear-gradient(135deg, #5cb7ee, #3498db) !important;
	box-shadow:
		0 2px 5px rgba(52, 152, 219, 0.32),
		inset 0 1px 0 rgba(255, 255, 255, 0.20),
		inset 0 -1px 0 rgba(0, 0, 0, 0.08) !important;
}
.select2-selection__choice[data-s2-val="contacted"]:hover,
.select2-selection__choice[data-s2-val="business"]:hover,
.select2-selection__choice[data-s2-val="normal"]:hover,
.select2-selection__choice[data-s2-val="manufacturing"]:hover {
	box-shadow:
		0 5px 12px rgba(52, 152, 219, 0.42),
		inset 0 1px 0 rgba(255, 255, 255, 0.25),
		inset 0 -1px 0 rgba(0, 0, 0, 0.10) !important;
}

/* ---- PURPLE (demo / enterprise) ---- */
.select2-selection__choice[data-s2-val="demo"],
.select2-selection__choice[data-s2-val="enterprise"] {
	background: linear-gradient(135deg, #c084ff, #8b5cf6) !important;
	box-shadow:
		0 2px 5px rgba(139, 92, 246, 0.32),
		inset 0 1px 0 rgba(255, 255, 255, 0.20),
		inset 0 -1px 0 rgba(0, 0, 0, 0.08) !important;
}
.select2-selection__choice[data-s2-val="demo"]:hover,
.select2-selection__choice[data-s2-val="enterprise"]:hover {
	box-shadow:
		0 5px 12px rgba(139, 92, 246, 0.45),
		inset 0 1px 0 rgba(255, 255, 255, 0.25),
		inset 0 -1px 0 rgba(0, 0, 0, 0.10) !important;
}

/* ---- TEAL (trading) ---- */
.select2-selection__choice[data-s2-val="trading"] {
	background: linear-gradient(135deg, #5dd3e8, #1c97ad) !important;
	box-shadow:
		0 2px 5px rgba(28, 151, 173, 0.30),
		inset 0 1px 0 rgba(255, 255, 255, 0.20),
		inset 0 -1px 0 rgba(0, 0, 0, 0.08) !important;
}

/* ---- NEUTRAL GREY (new / low / starter / mixed / pending stage) ---- */
.select2-selection__choice[data-s2-val="new"],
.select2-selection__choice[data-s2-val="low"],
.select2-selection__choice[data-s2-val="starter"],
.select2-selection__choice[data-s2-val="mixed"] {
	background: linear-gradient(135deg, #aab8cb, #748598) !important;
	box-shadow:
		0 2px 5px rgba(116, 133, 152, 0.30),
		inset 0 1px 0 rgba(255, 255, 255, 0.18),
		inset 0 -1px 0 rgba(0, 0, 0, 0.08) !important;
}
.select2-selection__choice[data-s2-val="new"]:hover,
.select2-selection__choice[data-s2-val="low"]:hover,
.select2-selection__choice[data-s2-val="starter"]:hover,
.select2-selection__choice[data-s2-val="mixed"]:hover {
	box-shadow:
		0 5px 12px rgba(116, 133, 152, 0.40),
		inset 0 1px 0 rgba(255, 255, 255, 0.22),
		inset 0 -1px 0 rgba(0, 0, 0, 0.10) !important;
}

/* Focus ring boost for the multi container */
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open  .select2-selection--multiple {
	border-color: var(--s2-primary) !important;
	box-shadow:
		0 0 0 3px rgba(0, 161, 255, 0.18),
		0 1px 2px rgba(15, 39, 70, 0.04) !important;
}

/* -----------------------------------------------------------
   3. Dropdown panel
   ----------------------------------------------------------- */
.select2-container--default .select2-dropdown {
	border: 1px solid var(--s2-line);
	border-radius: var(--s2-radius);
	box-shadow: 0 12px 32px rgba(15, 39, 70, 0.12), 0 4px 8px rgba(15, 39, 70, 0.06);
	background: var(--s2-bg);
	overflow: hidden;
}

/* Search box inside dropdown */
.select2-container--default .select2-search--dropdown {
	padding: 8px;
	background: #f9fcff;
	border-bottom: 1px solid var(--s2-line);
}
.select2-container--default .select2-search--dropdown .select2-search__field {
	border: 1px solid var(--s2-line);
	border-radius: 6px;
	padding: 8px 10px;
	font-size: 13.5px;
	background: white;
	color: var(--s2-ink);
	outline: none;
	transition: border-color .15s, box-shadow .15s;
	font-family: inherit;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
	border-color: var(--s2-primary);
	box-shadow: 0 0 0 3px rgba(0, 161, 255, 0.15);
}

/* Result options */
.select2-container--default .select2-results__option {
	padding: 9px 12px;
	font-size: 13.5px;
	color: var(--s2-ink);
	font-weight: 500;
	cursor: pointer;
	transition: background .1s;
	border-radius: 4px;
	margin: 2px 4px;
}
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted {
	background-color: var(--s2-primary) !important;
	color: white !important;
}
.select2-container--default .select2-results__option[aria-selected=true] {
	background-color: var(--s2-hover) !important;
	color: var(--s2-ink) !important;
	font-weight: 700;
}
.select2-container--default .select2-results__option--highlighted[aria-selected=true] {
	background-color: var(--s2-primary) !important;
	color: white !important;
}

/* No-results / loading messages */
.select2-container--default .select2-results__option--disabled {
	color: var(--s2-muted);
	cursor: default;
	font-style: italic;
}
.select2-container--default .select2-results__option.loading-results {
	color: var(--s2-muted);
	font-style: italic;
}

/* Scrollbar inside dropdown */
.select2-container--default .select2-results__options {
	max-height: 280px;
	padding: 4px 0;
}
.select2-container--default .select2-results__options::-webkit-scrollbar { width: 8px; }
.select2-container--default .select2-results__options::-webkit-scrollbar-track { background: transparent; }
.select2-container--default .select2-results__options::-webkit-scrollbar-thumb {
	background: var(--s2-line);
	border-radius: 4px;
}
.select2-container--default .select2-results__options::-webkit-scrollbar-thumb:hover {
	background: var(--s2-muted);
}

/* -----------------------------------------------------------
   4. Rich option formatter (avatar + email/sub-text)
   ----------------------------------------------------------- */
.s2-opt {
	display: flex;
	align-items: center;
	gap: 10px;
}
.s2-opt-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--s2-primary), var(--s2-primary-dark));
	color: white;
	font-weight: 700;
	font-size: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.s2-opt-body {
	display: flex;
	flex-direction: column;
	min-width: 0;
}
.s2-opt-title {
	font-weight: 600;
	color: inherit;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.s2-opt-sub {
	font-size: 11.5px;
	color: var(--s2-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.select2-results__option--highlighted .s2-opt-sub {
	color: rgba(255, 255, 255, 0.85);
}

/* -----------------------------------------------------------
   5. Size variants
   ----------------------------------------------------------- */
.s2-sm + .select2-container .select2-selection--single,
.s2-sm + .select2-container .select2-selection--multiple {
	min-height: 32px;
	height: 32px;
}
.s2-sm + .select2-container .select2-selection--single .select2-selection__rendered {
	line-height: 28px;
	font-size: 13px;
	padding-left: 10px;
}
.s2-sm + .select2-container .select2-selection--single .select2-selection__arrow {
	height: 30px;
}

/* -----------------------------------------------------------
   6. Inside specific contexts
   ----------------------------------------------------------- */
/* Inside admin form grid */
.adm-form-grid .select2-container,
.inline-edit .select2-container {
	width: 100% !important;
}

/* Inside topbar / filter bars */
.adm-filter-bar .select2-container {
	min-width: 180px;
}

/* Auth form (register) */
.auth-field .select2-container--default .select2-selection--single {
	height: 44px;
}
.auth-field .select2-container--default .select2-selection--single .select2-selection__rendered {
	line-height: 40px;
	font-size: 14.5px;
}
.auth-field .select2-container--default .select2-selection--single .select2-selection__arrow {
	height: 42px;
}

/* -----------------------------------------------------------
   7. Filter bar layout helpers
   ----------------------------------------------------------- */
.adm-filter-bar {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
	padding: 12px 16px;
	background: white;
	border: 1px solid var(--s2-line);
	border-radius: var(--s2-radius);
	margin-bottom: 14px;
}
.adm-filter-bar label {
	font-size: 12px;
	font-weight: 700;
	color: var(--s2-ink-soft);
	letter-spacing: 0.2px;
}
.adm-filter-bar .filter-group {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 180px;
}
.adm-filter-bar .filter-group.grow { flex: 1; min-width: 220px; }
.adm-filter-bar .filter-actions {
	margin-left: auto;
	display: flex;
	gap: 8px;
	align-items: flex-end;
}
.adm-filter-bar .filter-actions .adm-btn {
	height: 40px;
}

/* Mobile */
@media (max-width: 760px) {
	.adm-filter-bar { flex-direction: column; align-items: stretch; }
	.adm-filter-bar .filter-group { min-width: 0; width: 100%; }
	.adm-filter-bar .filter-actions { margin-left: 0; }
}
