/* Dropdown dùng chung (xem static/js/ui-select.js). */
.ui-select {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}
.ui-select[hidden] { display: none; }

/* Select thật vẫn submit và nhận validate, nhưng không được vẽ.
   iPad bỏ qua opacity:0 nếu select còn kích thước thật, nên thu về 1px. */
.ui-select > select.ui-select__native {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  z-index: 0;
  width: 1px !important;
  min-width: 0 !important;
  max-width: none;
  height: 1px !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  opacity: 0 !important;
  appearance: none;
  pointer-events: none;
}

.ui-select__trigger {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-width: 0;
  text-align: left;
  cursor: pointer;
}
.ui-select__trigger:disabled { cursor: not-allowed; }
.ui-select__value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ui-select__trigger.is-placeholder .ui-select__value { color: #6b85a0; }

/* Ảnh của lựa chọn đang chọn, nằm trước nhãn trên nút. */
.ui-select__trigger.has-thumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding-left: .375rem;
}
.ui-select__trigger.has-thumb .ui-select__value { flex: 1 1 auto; min-width: 0; }
.ui-select__thumb {
  flex: 0 0 auto;
  width: 1.625em;
  height: 1.625em;
  margin: -.25em 0;
  overflow: hidden;
  border-radius: 6px;
  background: #eef4fa;
  box-shadow: inset 0 0 0 1px rgba(23, 53, 74, .08);
}
.ui-select__thumb > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ui-select__thumb.is-blank { display: none; }
.ui-select.is-open > .ui-select__trigger {
  border-color: #7fb8e0;
  background-color: #fff;
  box-shadow: 0 0 0 0.2rem rgba(58, 160, 222, 0.2);
}

.input-group > .ui-select {
  flex: 1 1 auto;
  width: 1%;
}
.input-group > .ui-select:not(:last-child) > .ui-select__trigger {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.input-group > .ui-select:not(:first-child) > .ui-select__trigger {
  margin-left: calc(var(--bs-border-width) * -1);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.ui-select-popup {
  position: fixed;
  inset: auto;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d3e3f1;
  border-radius: 12px;
  background: #fff;
  color: #17354a;
  font-size: .875rem;
  box-shadow: 0 2px 6px rgba(23, 53, 74, .06), 0 14px 32px rgba(23, 53, 74, .16);
}
.ui-select-popup:popover-open { animation: ui-select-in .12s ease-out; }
@keyframes ui-select-in {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
}
@media (prefers-reduced-motion: reduce) {
  .ui-select-popup:popover-open { animation: none; }
}

.ui-select-popup__search {
  position: relative;
  flex: 0 0 auto;
  padding: .5rem;
  border-bottom: 1px solid #e9f0f6;
}
.ui-select-popup__search > .bi {
  position: absolute;
  top: 50%;
  left: 1.125rem;
  pointer-events: none;
  color: #6b85a0;
  font-size: .8125rem;
  transform: translateY(-50%);
}
.ui-select-popup__search-input {
  width: 100%;
  padding: .375rem .625rem .375rem 2rem;
  border: 1px solid #d6e5f1;
  border-radius: 8px;
  background: #f7fbff;
  color: inherit;
  font: inherit;
}
.ui-select-popup__search-input:focus {
  border-color: #7fb8e0;
  outline: 0;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(58, 160, 222, .15);
}

.ui-select-popup__list {
  flex: 1 1 auto;
  min-height: 0;
  padding: .3125rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #c9d9e7 transparent;
}
.ui-select-popup__list:empty { display: none; }

.ui-select-popup__group + .ui-select-popup__group,
.ui-select-popup__option + .ui-select-popup__group {
  margin-top: .25rem;
  padding-top: .25rem;
  border-top: 1px solid #eef3f8;
}
.ui-select-popup__group-title {
  padding: .375rem .625rem .25rem;
  color: #6b85a0;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.ui-select-popup__option {
  display: flex;
  align-items: center;
  gap: .625rem;
  min-height: 2.125rem;
  padding: .375rem .625rem;
  border-radius: 8px;
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
  transition: background-color .08s ease;
}
.ui-select-popup__option + .ui-select-popup__option { margin-top: 1px; }
.ui-select-popup__text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: .0625rem;
  min-width: 0;
}
.ui-select-popup__label { overflow-wrap: anywhere; }
.ui-select-popup__desc {
  overflow: hidden;
  color: #6b85a0;
  font-size: .78em;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ui-select-popup__option > .bi-check2 {
  flex: 0 0 auto;
  margin-left: auto;
  color: #0b82c4;
  font-size: 1.05rem;
  line-height: 1;
}
.ui-select-popup__option.is-empty-choice { color: #52667a; }
.ui-select-popup__option.is-active { background: #f0f7fd; }
.ui-select-popup__option[aria-selected="true"] { background: #e3f1fc; color: #0b6fa8; font-weight: 600; }
.ui-select-popup__option[aria-selected="true"].is-active { background: #d8ebfa; }

/* Danh sách có ảnh: dòng cao hơn, ảnh vuông bo góc cạnh nhãn. */
.ui-select-popup.has-thumbs .ui-select-popup__option { min-height: 3rem; padding-left: .375rem; }
.ui-select-popup__thumb {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  overflow: hidden;
  border-radius: 8px;
  background: #eef4fa;
  box-shadow: inset 0 0 0 1px rgba(23, 53, 74, .08);
}
.ui-select-popup__thumb > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ui-select-popup__thumb.is-blank { color: #9db3c7; font-size: 1.05rem; }
.ui-select-popup__option[aria-selected="true"] .ui-select-popup__thumb { box-shadow: 0 0 0 2px #7fb8e0; }
.ui-select-popup__option[aria-disabled="true"] .ui-select-popup__thumb { opacity: .5; }
.ui-select-popup__option[aria-disabled="true"] { color: #a2b3c2; cursor: not-allowed; }
.ui-select-popup__option[aria-disabled="true"].is-active { background: transparent; }
.ui-select-popup__option.is-empty-choice + .ui-select-popup__option:not(.is-empty-choice) {
  margin-top: .25rem;
  position: relative;
}
.ui-select-popup__option.is-empty-choice + .ui-select-popup__option:not(.is-empty-choice)::before {
  content: '';
  position: absolute;
  top: calc(-.125rem - 1px);
  right: .375rem;
  left: .375rem;
  border-top: 1px solid #eef3f8;
}

.ui-select-popup__empty {
  padding: .625rem .75rem;
  color: #6b85a0;
  text-align: center;
}
.ui-select-popup__empty[hidden] { display: none; }

/* Màn cảm ứng: tăng vùng bấm của từng dòng, phần còn lại vẫn gọn. */
@media (hover: none) {
  .ui-select-popup__option { min-height: 2.5rem; padding-top: .5rem; padding-bottom: .5rem; }
}
