/* Select2 aligned with Bootstrap form controls + Arsema brand (#00556E) */
:root {
  --ad-brand: #00556E;
  --ad-brand-rgb: 0, 85, 110;
  --ad-brand-focus: #3CACB0;
}

.select2-container {
  width: 100% !important;
  max-width: 100%;
  vertical-align: middle;
}

.select2-container--default .select2-selection--single {
  position: relative;
  box-sizing: border-box;
  display: block;
  height: calc(1.6em + 0.75rem + 2px);
  min-height: calc(1.6em + 0.75rem + 2px);
  padding: 0;
  border: 1px solid var(--bs-border-color, #ced4da);
  border-radius: var(--bs-border-radius, 0.375rem);
  background-color: var(--bs-body-bg, #fff);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  display: block;
  line-height: calc(1.6em + 0.75rem);
  padding-left: 0.75rem;
  padding-right: 2rem;
  color: var(--bs-body-color, #212529);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: #6c757d;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  position: absolute;
  top: 0;
  right: 0.35rem;
  height: 100%;
  width: 1.5rem;
}

.select2-container--default .select2-selection--single .select2-selection__clear {
  position: absolute;
  right: 1.75rem;
  top: 0;
  height: 100%;
  margin: 0;
  font-weight: 700;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--ad-brand-focus);
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(var(--ad-brand-rgb), 0.2);
}

.select2-dropdown {
  border: 1px solid var(--bs-border-color, #ced4da);
  border-radius: var(--bs-border-radius, 0.375rem);
  overflow: hidden;
  z-index: 1060;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--bs-border-color, #ced4da);
  border-radius: var(--bs-border-radius, 0.375rem);
  padding: 0.375rem 0.75rem;
  font-size: 0.9rem;
  outline: 0;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
  border-color: var(--ad-brand-focus);
  box-shadow: 0 0 0 0.25rem rgba(var(--ad-brand-rgb), 0.2);
}

.select2-container--default .select2-results__option {
  font-size: 0.9rem;
  padding: 0.375rem 0.75rem;
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable,
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--ad-brand);
  color: #fff;
}

.select2-container--default .select2-results__option--selected {
  background-color: rgba(var(--ad-brand-rgb), 0.12);
  color: var(--ad-brand);
}

.select2-container--default .select2-results__option--selected.select2-results__option--highlighted {
  background-color: var(--ad-brand);
  color: #fff;
}

/* Spacing when original select had mb-2 / mb-3 */
select.mb-2 + .select2-container {
  margin-bottom: 0.5rem !important;
}

select.mb-3 + .select2-container {
  margin-bottom: 1rem !important;
}

/*
 * Filter bars only (.search-box). Do NOT target .input-group globally —
 * forms wrap fields in .input-group.flex-col; flex:1 there stretches the
 * container and pulls the arrow out of the control.
 */
.search-box .input-group:not(.flex-col) > .select2-container {
  min-width: 10rem;
  max-width: 100%;
  flex: 1 1 10rem;
}

.search-box .input-group:not(.flex-col) > #stock_card_item_id + .select2-container,
.search-box .input-group:not(.flex-col) > select#stock_card_item_id + .select2-container {
  min-width: 22rem;
  flex: 2 1 22rem;
}

.search-box .input-group:not(.flex-col) > .select2-container .select2-selection--single {
  border-radius: var(--bs-border-radius, 0.375rem);
}
