/**
 * Ajax entity-loader multiselect — only styled when the picker is actually open.
 * (bootstrap-select keeps class "open" on .dropdown-menu at all times; visibility is .bootstrap-select.open)
 *
 * .multiexpand lists (device edit → Users) stay visible. The theme hides their toggle
 * and shows the menu in place; treating them as closed dropdowns blanks the tab.
 */

.bootstrap-select.form-control:has(> select[data-ajax]):not(.open):not(.multiexpand) > .dropdown-menu,
.bootstrap-select.form-control.entity-loader-select:not(.open) > .dropdown-menu {
  display: none !important;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) > .dropdown-menu,
.bootstrap-select.form-control.open.entity-loader-select > .dropdown-menu {
  display: flex !important;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  min-width: 100%;
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  z-index: 1065;
}

.modal .bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) > .dropdown-menu,
.modal .bootstrap-select.form-control.open.entity-loader-select > .dropdown-menu {
  z-index: 1070;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-searchbox,
.bootstrap-select.form-control.open.entity-loader-select .bs-searchbox {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: inherit;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-searchbox .form-control,
.bootstrap-select.form-control.open.entity-loader-select .bs-searchbox .form-control {
  border-radius: 4px;
  height: 34px;
  box-shadow: none;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-actionsbox,
.bootstrap-select.form-control.open.entity-loader-select .bs-actionsbox {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: inherit;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-actionsbox .btn-group,
.bootstrap-select.form-control.open.entity-loader-select .bs-actionsbox .btn-group {
  display: flex;
  gap: 8px;
  width: 100%;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-actionsbox .btn-group button,
.bootstrap-select.form-control.open.entity-loader-select .bs-actionsbox .btn-group button {
  width: auto;
  flex: 1 1 50%;
  border-radius: 4px;
  font-size: 12px;
  padding: 7px 10px;
  float: none;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) > .dropdown-menu > .inner,
.bootstrap-select.form-control.open.entity-loader-select > .dropdown-menu > .inner {
  flex: 1 1 auto;
  position: relative;
  float: none;
  min-height: 140px;
  max-height: min(260px, 40vh);
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .dropdown-menu.inner > li.dropdown-header,
.bootstrap-select.form-control.open.entity-loader-select .dropdown-menu.inner > li.dropdown-header {
  padding: 10px 14px 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
  background: transparent;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin-top: 2px;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .dropdown-menu.inner > li:not(.dropdown-header) > a,
.bootstrap-select.form-control.open.entity-loader-select .dropdown-menu.inner > li:not(.dropdown-header) > a {
  padding: 8px 14px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .dropdown-menu.inner > li:not(.dropdown-header):hover > a,
.bootstrap-select.form-control.open.entity-loader-select .dropdown-menu.inner > li:not(.dropdown-header):hover > a {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Pagination footer */
.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination {
  flex: 0 0 auto;
  width: 100%;
  padding: 10px 12px;
  margin: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  background: inherit;
  clear: both;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination .nav-pagination,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination .nav-pagination {
  margin: 0;
  padding: 0;
  border-top: 0;
  text-align: center;
  float: none;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination .nav-pagination .pagination,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination .nav-pagination .pagination {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 0 auto !important;
  padding: 0;
  list-style: none;
  float: none !important;
  width: auto;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination .nav-pagination .pagination > li,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination .nav-pagination .pagination > li {
  display: inline-block !important;
  position: static !important;
  float: none !important;
  list-style: none;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination .nav-pagination .pagination > li > a,
.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination .nav-pagination .pagination > li > span,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination .nav-pagination .pagination > li > a,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination .nav-pagination .pagination > li > span {
  display: inline-block;
  float: none !important;
  min-width: 32px;
  text-align: center;
  padding: 6px 10px;
  line-height: 1.25;
  text-decoration: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
  margin: 0 0 0 -1px;
  border-radius: 0;
  cursor: pointer;
  user-select: none;
  background: inherit;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination .nav-pagination .pagination > li:first-child > a,
.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination .nav-pagination .pagination > li:first-child > span,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination .nav-pagination .pagination > li:first-child > a,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination .nav-pagination .pagination > li:first-child > span {
  margin-left: 0;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination .nav-pagination .pagination > li:last-child > a,
.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination .nav-pagination .pagination > li:last-child > span,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination .nav-pagination .pagination > li:last-child > a,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination .nav-pagination .pagination > li:last-child > span {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-pagination .nav-pagination .pagination > li.active > span,
.bootstrap-select.form-control.open.entity-loader-select .bs-pagination .nav-pagination .pagination > li.active > span {
  font-weight: 600;
  z-index: 1;
  position: relative;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-donebutton,
.bootstrap-select.form-control.open.entity-loader-select .bs-donebutton {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: inherit;
}

.bootstrap-select.form-control.open:has(> select[data-ajax]):not(.multiexpand) .bs-donebutton .btn,
.bootstrap-select.form-control.open.entity-loader-select .bs-donebutton .btn {
  width: 100%;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
}
