/* Select2 hierarchy option spacing (organization dropdown only) */
.organization-select2-dropdown .select2-results__option {
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.5;
    transition: background-color 0.15s ease;
}

/* --------------------------------------------------------------------------
   Header organization Select2 — layout + fallbacks (no org theme / no vars)
   -------------------------------------------------------------------------- */
#select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single,
.organization-select2.select2-container--default .select2-selection--single,
.select2-container--default.organization-select2 .select2-selection--single,
.fi-topbar #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single,
.fi-topbar .organization-select2.select2-container--default .select2-selection--single,
.fi-topbar .select2-container--default.organization-select2 .select2-selection--single {
    height: 36px !important;
    border-radius: 0.5rem !important;
    border: 1px solid rgb(209 213 219) !important;
    background-color: transparent !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
    box-shadow: none !important;
}

#select2-headerOrganizationSelector-container.select2-container--default.select2-container--focus .select2-selection--single,
#select2-headerOrganizationSelector-container.select2-container--default.select2-container--open .select2-selection--single,
.organization-select2.select2-container--default.select2-container--focus .select2-selection--single,
.organization-select2.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.organization-select2.select2-container--focus .select2-selection--single,
.select2-container--default.organization-select2.select2-container--open .select2-selection--single,
.fi-topbar #select2-headerOrganizationSelector-container.select2-container--default.select2-container--focus .select2-selection--single,
.fi-topbar #select2-headerOrganizationSelector-container.select2-container--default.select2-container--open .select2-selection--single,
.fi-topbar .organization-select2.select2-container--default.select2-container--focus .select2-selection--single,
.fi-topbar .organization-select2.select2-container--default.select2-container--open .select2-selection--single,
.fi-topbar .select2-container--default.organization-select2.select2-container--focus .select2-selection--single,
.fi-topbar .select2-container--default.organization-select2.select2-container--open .select2-selection--single {
    outline: none !important;
}

#select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single .select2-selection__rendered,
.organization-select2.select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-container--default.organization-select2 .select2-selection--single .select2-selection__rendered,
.fi-topbar #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single .select2-selection__rendered,
.fi-topbar .organization-select2.select2-container--default .select2-selection--single .select2-selection__rendered,
.fi-topbar .select2-container--default.organization-select2 .select2-selection--single .select2-selection__rendered {
    line-height: 34px !important;
    padding-left: 12px !important;
    color: rgb(17 24 39) !important;
    font-weight: 500 !important;
}

#select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single .select2-selection__arrow,
.organization-select2.select2-container--default .select2-selection--single .select2-selection__arrow,
.select2-container--default.organization-select2 .select2-selection--single .select2-selection__arrow,
.fi-topbar #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single .select2-selection__arrow,
.fi-topbar .organization-select2.select2-container--default .select2-selection--single .select2-selection__arrow,
.fi-topbar .select2-container--default.organization-select2 .select2-selection--single .select2-selection__arrow {
    height: 34px !important;
}

/* --------------------------------------------------------------------------
   Branded topbar: transparent surface; label/chevron use org foreground tokens.
   -------------------------------------------------------------------------- */
.fi-topbar.organization-theme #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single,
.fi-topbar.organization-theme .organization-select2.select2-container--default .select2-selection--single,
.fi-topbar.organization-theme .select2-container--default.organization-select2 .select2-selection--single {
    background-color: transparent !important;
    border-color: rgb(var(--primary-800)) !important;
}

.fi-topbar.organization-theme
    #select2-headerOrganizationSelector-container.select2-container--default:hover
    .select2-selection--single,
.fi-topbar.organization-theme
    .organization-select2.select2-container--default:hover
    .select2-selection--single,
.fi-topbar.organization-theme
    .select2-container--default.organization-select2:hover
    .select2-selection--single {
    border-color: rgb(var(--primary-900)) !important;
}

.fi-topbar.organization-theme #select2-headerOrganizationSelector-container.select2-container--default.select2-container--focus .select2-selection--single,
.fi-topbar.organization-theme #select2-headerOrganizationSelector-container.select2-container--default.select2-container--open .select2-selection--single,
.fi-topbar.organization-theme .organization-select2.select2-container--default.select2-container--focus .select2-selection--single,
.fi-topbar.organization-theme .organization-select2.select2-container--default.select2-container--open .select2-selection--single,
.fi-topbar.organization-theme .select2-container--default.organization-select2.select2-container--focus .select2-selection--single,
.fi-topbar.organization-theme .select2-container--default.organization-select2.select2-container--open .select2-selection--single {
    border-color: rgb(var(--primary-500)) !important;
    box-shadow: 0 0 0 3px var(--org-focus-ring) !important;
}

/* Topbar surface is primary-600; Select2 selection is transparent, so use on-600 (not on-700). */
.fi-topbar.organization-theme #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single .select2-selection__rendered,
.fi-topbar.organization-theme .organization-select2.select2-container--default .select2-selection--single .select2-selection__rendered,
.fi-topbar.organization-theme .select2-container--default.organization-select2 .select2-selection--single .select2-selection__rendered {
    color: rgb(var(--org-on-600, 15, 23, 42)) !important;
}

.fi-topbar.organization-theme #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single .select2-selection__arrow b,
.fi-topbar.organization-theme .organization-select2.select2-container--default .select2-selection--single .select2-selection__arrow b,
.fi-topbar.organization-theme .select2-container--default.organization-select2 .select2-selection--single .select2-selection__arrow b {
    border-color: rgb(var(--org-on-600, 15, 23, 42)) transparent transparent transparent !important;
}

/* Dropdown shell (org selector): layout + default neutrals */
.organization-select2 ~ .select2-dropdown,
.organization-select2 + .select2-dropdown,
.select2-container.organization-select2 ~ .select2-dropdown,
.select2-container.organization-select2 + .select2-dropdown,
.fi-topbar .organization-select2 ~ .select2-dropdown,
.fi-topbar .select2-container.organization-select2 ~ .select2-dropdown {
    border-radius: 0.5rem !important;
    border: 1px solid rgb(209 213 219) !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    z-index: 40 !important;
}

.organization-select2-dropdown.select2-dropdown {
    border-radius: 0.5rem !important;
    border: 1px solid rgb(var(--primary-300)) !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    z-index: 40 !important;
    background-color: rgb(255 255 255) !important;
}

.organization-select2-dropdown .select2-search--dropdown {
    padding: 8px;
}

.organization-select2-dropdown .select2-search--dropdown .select2-search__field {
    border-radius: 0.375rem;
    border: 1px solid rgb(var(--primary-300));
    padding: 8px 12px;
    font-size: 14px;
    transition: border-color 0.15s ease;
}

.organization-select2-dropdown .select2-search--dropdown .select2-search__field:focus {
    outline: none !important;
    border-color: rgb(var(--primary-500)) !important;
    box-shadow: 0 0 0 3px var(--org-focus-ring) !important;
}

.organization-select2-dropdown .select2-results__option--highlighted[aria-selected] {
    background-color: rgb(var(--primary-600)) !important;
    color: rgb(var(--org-on-600)) !important;
}

.organization-select2-dropdown .select2-results__option[aria-selected="true"] {
    background-color: rgb(var(--primary-100)) !important;
    color: rgb(var(--primary-900)) !important;
    font-weight: 500;
}

/* Dark: org dropdown only (do not target every Select2 on the page) */
.dark .organization-select2-dropdown.select2-dropdown {
    background-color: rgb(31 41 55) !important;
    border-color: rgb(var(--primary-700)) !important;
}

.dark .organization-select2-dropdown .select2-results__option {
    color: rgb(243 244 246);
}

.dark .organization-select2-dropdown .select2-results__option--highlighted[aria-selected] {
    background-color: rgb(var(--primary-600)) !important;
    color: rgb(var(--org-on-600)) !important;
}

.dark .organization-select2-dropdown .select2-results__option[aria-selected="true"] {
    background-color: rgb(55 65 81) !important;
    color: rgb(var(--primary-200)) !important;
}

.dark .organization-select2-dropdown .select2-search--dropdown .select2-search__field {
    background-color: rgb(55 65 81);
    border-color: rgb(75 85 99);
    color: rgb(243 244 246);
}

.dark .organization-select2-dropdown .select2-search--dropdown .select2-search__field:focus {
    border-color: rgb(var(--primary-500)) !important;
    box-shadow: 0 0 0 3px var(--org-focus-ring) !important;
}

.dark .organization-select2-dropdown .select2-search--dropdown .select2-search__field::placeholder {
    color: rgb(156 163 175);
}

/* Legacy: search field focus when dropdown has no custom class (input id match) */
body > .select2-dropdown:has(.select2-search--dropdown input[data-select2-id*="headerOrganizationSelector"]) .select2-search--dropdown .select2-search__field:focus,
#select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus,
.organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus,
.select2-container.organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus,
.fi-topbar #select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus,
.fi-topbar .organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus,
.fi-topbar .select2-container.organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus {
    outline: none !important;
    border-color: rgb(var(--primary-500)) !important;
    box-shadow: 0 0 0 3px var(--org-focus-ring) !important;
}


html:not(.dark) .organization-select2 ~ .select2-dropdown .select2-results__option--highlighted[aria-selected],
html:not(.dark) .select2-container.organization-select2 ~ .select2-dropdown .select2-results__option--highlighted[aria-selected],
html:not(.dark) #select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-results__option--highlighted[aria-selected],
html:not(.dark) .fi-topbar .organization-select2 ~ .select2-dropdown .select2-results__option--highlighted[aria-selected],
html:not(.dark) .fi-topbar .select2-container.organization-select2 ~ .select2-dropdown .select2-results__option--highlighted[aria-selected] {
    background-color: rgb(79 70 229) !important;
    color: #ffffff !important;
}

.organization-select2 ~ .select2-dropdown .select2-results__option[aria-selected='true'],
.select2-container.organization-select2 ~ .select2-dropdown .select2-results__option[aria-selected='true'],
#select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-results__option[aria-selected='true'],
.fi-topbar .organization-select2 ~ .select2-dropdown .select2-results__option[aria-selected='true'],
.fi-topbar .select2-container.organization-select2 ~ .select2-dropdown .select2-results__option[aria-selected='true'] {
    background-color: rgb(238 242 255);
    color: #a25a73;
    font-weight: 500;
}

/* Style pour le mode sombre */
.dark #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single,
.dark .organization-select2.select2-container--default .select2-selection--single,
.dark .select2-container--default.organization-select2 .select2-selection--single,
.dark .fi-topbar #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single,
.dark .fi-topbar .organization-select2.select2-container--default .select2-selection--single,
.dark .fi-topbar .select2-container--default.organization-select2 .select2-selection--single {
    background-color: rgb(55 65 81) !important;
    border-color: rgb(75 85 99) !important;
    box-shadow: none !important;
}

/* Note: Dark mode hover state for organization selector uses Select2 default styles */
/* No custom hover rules - keeping Select2 default behavior */

.dark #select2-headerOrganizationSelector-container.select2-container--default.select2-container--focus .select2-selection--single,
.dark #select2-headerOrganizationSelector-container.select2-container--default.select2-container--open .select2-selection--single,
.dark .organization-select2.select2-container--default.select2-container--focus .select2-selection--single,
.dark .organization-select2.select2-container--default.select2-container--open .select2-selection--single,
.dark .select2-container--default.organization-select2.select2-container--focus .select2-selection--single,
.dark .select2-container--default.organization-select2.select2-container--open .select2-selection--single,
.dark .fi-topbar #select2-headerOrganizationSelector-container.select2-container--default.select2-container--focus .select2-selection--single,
.dark .fi-topbar #select2-headerOrganizationSelector-container.select2-container--default.select2-container--open .select2-selection--single,
.dark .fi-topbar .organization-select2.select2-container--default.select2-container--focus .select2-selection--single,
.dark .fi-topbar .organization-select2.select2-container--default.select2-container--open .select2-selection--single,
.dark .fi-topbar .select2-container--default.organization-select2.select2-container--focus .select2-selection--single,
.dark .fi-topbar .select2-container--default.organization-select2.select2-container--open .select2-selection--single {
    border-color: #16A34A !important;
    outline: none !important;
    box-shadow: 0 0 0 1px #16A34A !important;
}

.dark #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single .select2-selection__rendered,
.dark .organization-select2.select2-container--default .select2-selection--single .select2-selection__rendered,
.dark .select2-container--default.organization-select2 .select2-selection--single .select2-selection__rendered,
.dark .fi-topbar #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single .select2-selection__rendered,
.dark .fi-topbar .organization-select2.select2-container--default .select2-selection--single .select2-selection__rendered,
.dark .fi-topbar .select2-container--default.organization-select2 .select2-selection--single .select2-selection__rendered {
    color: white !important;
}

.dark #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single .select2-selection__arrow b,
.dark .organization-select2.select2-container--default .select2-selection--single .select2-selection__arrow b,
.dark .select2-container--default.organization-select2 .select2-selection--single .select2-selection__arrow b,
.dark .fi-topbar #select2-headerOrganizationSelector-container.select2-container--default .select2-selection--single .select2-selection__arrow b,
.dark .fi-topbar .organization-select2.select2-container--default .select2-selection--single .select2-selection__arrow b,
.dark .fi-topbar .select2-container--default.organization-select2 .select2-selection--single .select2-selection__arrow b {
    border-color: white transparent transparent transparent !important;
}

/* Organization dropdown only — do not use .dark .select2-dropdown alone (it hijacked every Select2 list) */
.dark .organization-select2 ~ .select2-dropdown,
.dark .select2-container.organization-select2 ~ .select2-dropdown,
.dark #select2-headerOrganizationSelector-container ~ .select2-dropdown,
.dark .fi-topbar .organization-select2 ~ .select2-dropdown,
.dark .fi-topbar .select2-container.organization-select2 ~ .select2-dropdown {
    background-color: rgb(55 65 81) !important;
    border-color: rgb(75 85 99) !important;
}

.dark .organization-select2 ~ .select2-dropdown .select2-results__option,
.dark .select2-container.organization-select2 ~ .select2-dropdown .select2-results__option,
.dark #select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-results__option,
.dark .fi-topbar .organization-select2 ~ .select2-dropdown .select2-results__option,
.dark .fi-topbar .select2-container.organization-select2 ~ .select2-dropdown .select2-results__option {
    color: white;
}

.dark .organization-select2 ~ .select2-dropdown .select2-results__option--highlighted[aria-selected],
.dark .select2-container.organization-select2 ~ .select2-dropdown .select2-results__option--highlighted[aria-selected],
.dark #select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-results__option--highlighted[aria-selected],
.dark .fi-topbar .organization-select2 ~ .select2-dropdown .select2-results__option--highlighted[aria-selected],
.dark .fi-topbar .select2-container.organization-select2 ~ .select2-dropdown .select2-results__option--highlighted[aria-selected] {
    background-color: rgb(99 102 241);
    color: white;
}

.dark .organization-select2 ~ .select2-dropdown .select2-results__option[aria-selected='true'],
.dark .select2-container.organization-select2 ~ .select2-dropdown .select2-results__option[aria-selected='true'],
.dark #select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-results__option[aria-selected='true'],
.dark .fi-topbar .organization-select2 ~ .select2-dropdown .select2-results__option[aria-selected='true'],
.dark .fi-topbar .select2-container.organization-select2 ~ .select2-dropdown .select2-results__option[aria-selected='true'] {
    background-color: rgb(75 85 99);
    color: rgb(167 139 250);
}

.dark .organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field,
.dark .select2-container.organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field,
.dark #select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-search--dropdown .select2-search__field,
.dark .fi-topbar .organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field,
.dark .fi-topbar .select2-container.organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field {
    background-color: rgb(75 85 99);
    border-color: rgb(107 114 128);
    color: white;
}

/* Dark mode - Focus state for organization selector dropdown search field - Filament color */
.dark body > .select2-dropdown:has(.select2-search--dropdown input[data-select2-id*="headerOrganizationSelector"]) .select2-search--dropdown .select2-search__field:focus,
.dark #select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus,
.dark .organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus,
.dark .select2-container.organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus,
.dark .fi-topbar #select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus,
.dark .fi-topbar .organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus,
.dark .fi-topbar .select2-container.organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field:focus {
    border-color: #16A34A !important;
    box-shadow: 0 0 0 1px #16A34A !important;
}

.dark .organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field::placeholder,
.dark .select2-container.organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field::placeholder,
.dark #select2-headerOrganizationSelector-container ~ .select2-dropdown .select2-search--dropdown .select2-search__field::placeholder,
.dark .fi-topbar .organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field::placeholder,
.dark .fi-topbar .select2-container.organization-select2 ~ .select2-dropdown .select2-search--dropdown .select2-search__field::placeholder {
    color: rgb(156 163 175);
}

/* Ensure organization selector dropdown stays above other elements (in topbar) */
/* Target by ID and class for maximum specificity */
#select2-headerOrganizationSelector-container,
.organization-select2.select2-container,
.select2-container.organization-select2,
.fi-topbar #select2-headerOrganizationSelector-container,
.fi-topbar .organization-select2.select2-container,
.fi-topbar .select2-container.organization-select2 {
    z-index: 40 !important;
}

#select2-headerOrganizationSelector-container.select2-container--open,
.organization-select2.select2-container--open,
.select2-container--open.organization-select2,
.fi-topbar #select2-headerOrganizationSelector-container.select2-container--open,
.fi-topbar .organization-select2.select2-container--open,
.fi-topbar .select2-container--open.organization-select2 {
    z-index: 40 !important;
}

#select2-headerOrganizationSelector-container.select2-container--open .select2-dropdown,
.organization-select2.select2-container--open .select2-dropdown,
.select2-container--open.organization-select2 .select2-dropdown,
.fi-topbar #select2-headerOrganizationSelector-container.select2-container--open .select2-dropdown,
.fi-topbar .organization-select2.select2-container--open .select2-dropdown,
.fi-topbar .select2-container--open.organization-select2 .select2-dropdown {
    z-index: 40 !important;
}
