/**
 * BBT Design System - Choices.js Override Styles
 *
 * This file contains all Choices.js customizations for BBT Design System.
 * Include this file in your project to apply BBT styling to Choices.js selects.
 *
 * Usage:
 * 1. Include Choices.js CSS: <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/choices.js/public/assets/styles/choices.min.css" />
 * 2. Include this override file: <link rel="stylesheet" href="path/to/choices-override.css" />
 * 3. Include Choices.js JS: <script src="https://cdn.jsdelivr.net/npm/choices.js/public/assets/scripts/choices.min.js"></script>
 */

/* ========================================
   CHOICES.JS - SINGLE SELECT
   ======================================== */

/* Main container */
.choices {
  margin-bottom: 0;
  font-size: 0.9375rem;
}

/* Inner wrapper (the trigger / input area) */
.choices__inner {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 1rem;
  background-color: var(--bbt-white);
  border: 1px solid var(--bbt-neutral-200);
  border-radius: 24px !important;
  font-size: 0.9375rem;
  color: var(--bbt-text-default);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

/* Focus state */
.is-focused .choices__inner,
.is-open .choices__inner {
  border-color: var(--bbt-primary-300);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--bbt-primary-light) 40%, transparent);
}

/* Disabled state */
.choices[data-type*='select-one'].is-disabled .choices__inner,
.choices[data-type*='select-multiple'].is-disabled .choices__inner {
  background-color: var(--bbt-neutral-50);
  border-color: var(--bbt-neutral-100);
  color: var(--bbt-neutral-200);
  cursor: not-allowed;
}

/* Error state */
.choices.is-invalid .choices__inner {
  border-color: var(--bbt-error);
}

.choices.is-invalid.is-focused .choices__inner,
.choices.is-invalid.is-open .choices__inner {
  box-shadow: 0 0 0 0.2rem rgba(189, 0, 0, 0.25);
}

/* Placeholder text */
.choices__placeholder {
  color: var(--bbt-neutral-base);
  opacity: 1;
}

/* Selected item text (single select) */
.choices[data-type*='select-one'] .choices__item--selectable {
  color: var(--bbt-text-default);
}

.choices[data-type*='select-one'].is-disabled .choices__item--selectable {
  color: var(--bbt-neutral-200);
}

/* ========================================
   CHOICES.JS - DROPDOWN ARROW
   ======================================== */

/* Override default arrow with BBT chevron */
.choices[data-type*='select-one']::after {
  content: '';
  border: none;
  width: 16px;
  height: 16px;
  position: absolute;
  right: 1rem;
  top: 50%;
  margin-top: -8px;
  background-image: url('themes/base/icons/chevron-down.svg');
  background-size: contain;
  background-repeat: no-repeat;
  transition: transform 0.2s ease;
}

.choices[data-type*='select-one'].is-open::after {
  transform: rotate(180deg);
  margin-top: -8px;
}

.choices[data-type*='select-one'].is-disabled::after {
  opacity: 0.4;
}

/* ========================================
   CHOICES.JS - DROPDOWN LIST
   ======================================== */

/* Dropdown container */
.choices__list--dropdown,
.choices .choices__list[aria-expanded] {
  border: 1px solid var(--bbt-neutral-100);
  border-radius: 16px;
  box-shadow: var(--bbt-shadow-lg);
  margin-top: 0.25rem;
  padding: 0.5rem 0;
  background-color: var(--bbt-white);
  z-index: 1055;
  word-break: break-word;
  overflow: hidden;
}

/* Individual dropdown item */
.choices__list--dropdown .choices__item,
.choices .choices__list[aria-expanded] .choices__item {
  padding: 0.625rem 1rem;
  font-size: 0.9375rem;
  color: var(--bbt-text-default);
  transition: background-color 0.15s ease;
}

/* Hover state for dropdown items */
.choices__list--dropdown .choices__item--selectable.is-highlighted,
.choices .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
  background-color: var(--bbt-primary-100);
  color: var(--bbt-text-default);
}

/* Selected item in dropdown (with checkmark effect) */
.choices__list--dropdown .choices__item--selectable.is-selected,
.choices .choices__list[aria-expanded] .choices__item--selectable.is-selected {
  background-color: transparent;
  color: var(--bbt-text-default);
  position: relative;
  padding-right: 2.5rem;
}

/* Checkmark for selected item */
  .choices__list--dropdown .choices__item--selectable.is-selected::after,
  .choices .choices__list[aria-expanded] .choices__item--selectable.is-selected::after {
    content: '';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background-image: url('themes/base/icons/chevron-down.svg');
    background-size: contain;
    background-repeat: no-repeat;
  }

/* Selected + highlighted */
.choices__list--dropdown .choices__item--selectable.is-selected.is-highlighted,
.choices .choices__list[aria-expanded] .choices__item--selectable.is-selected.is-highlighted {
  background-color: var(--bbt-primary-100);
}

/* Disabled dropdown item */
.choices__list--dropdown .choices__item--disabled,
.choices .choices__list[aria-expanded] .choices__item--disabled {
  color: var(--bbt-neutral-300);
  cursor: not-allowed;
}

/* ========================================
   CHOICES.JS - SEARCH INPUT
   ======================================== */

.choices__list--dropdown .choices__input,
.choices .choices__list[aria-expanded] .choices__input {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--bbt-neutral-100);
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  color: var(--bbt-text-default);
  background-color: var(--bbt-white);
}

.choices__list--dropdown .choices__input:focus,
.choices .choices__list[aria-expanded] .choices__input:focus {
  outline: none;
}

/* ========================================
   CHOICES.JS - MULTIPLE SELECT
   ======================================== */

/* Multiple select inner */
.choices[data-type*='select-multiple'] .choices__inner {
  padding: 0.375rem 0.75rem;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* Selected tags/pills in multiple select (in trigger area only) */
.choices[data-type*='select-multiple'] .choices__inner .choices__item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background-color: var(--bbt-primary-600);
  border: none;
  border-radius: 16px;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  margin: 0;
}

/* Remove button (×) on tags */
  .choices[data-type*='select-multiple'] .choices__inner .choices__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: none;
    border-left: none;
    background: transparent;
    padding: 0;
    margin-left: 0.25rem;
    color: #fff;
    opacity: 0.8;
    cursor: pointer;
    /* Override default Choices.js button image */
    background-image: url('themes/base/icons/chevron-down.svg');
    background-size: 12px 12px;
    background-repeat: no-repeat;
    background-position: center;
  }

.choices[data-type*='select-multiple'] .choices__inner .choices__button:hover {
  opacity: 1;
}

/* Multiple select dropdown items - transparent background by default */
.choices[data-type*='select-multiple'] .choices__list--dropdown .choices__item {
  background-color: transparent;
  border: none;
  border-radius: 0;
  color: var(--bbt-text-default);
  font-weight: 400;
}

/* Multiple select dropdown items - highlight only on hover */
.choices[data-type*='select-multiple'] .choices__list--dropdown .choices__item.is-highlighted {
  background-color: var(--bbt-primary-100);
}

/* Multiple select input */
.choices[data-type*='select-multiple'] .choices__input {
  background-color: transparent;
  margin-bottom: 0;
  padding: 0.25rem 0;
  font-size: 0.9375rem;
  color: var(--bbt-text-default);
}

/* ========================================
   CHOICES.JS - SIZE VARIATIONS
   ======================================== */

/* Small select */
.choices.choices-sm .choices__inner {
  min-height: 36px;
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  border-radius: 16px;
}

.choices.choices-sm .choices__list--dropdown .choices__item,
.choices.choices-sm .choices__list[aria-expanded] .choices__item {
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
}

/* Large select */
.choices.choices-lg .choices__inner {
  min-height: 52px;
  padding: 0.625rem 1.25rem;
  font-size: 1.125rem;
  border-radius: 24px;
}

.choices.choices-lg .choices__list--dropdown .choices__item,
.choices.choices-lg .choices__list[aria-expanded] .choices__item {
  padding: 0.625rem 1.25rem;
  font-size: 1.125rem;
}

/* ========================================
   CHOICES.JS - ICONS, AVATARS, FLAGS
   ======================================== */

/* Dropdown items with custom content: flex layout */
.choices__list--dropdown .choices__item--selectable,
.choices .choices__list[aria-expanded] .choices__item--selectable {
  display: flex !important;
  align-items: center;
  gap: 0.75rem;
}

/* Ensure trigger area with icon/avatar/flag uses flex */
.choices[data-type*='select-one'] .choices__item[data-item] {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
}

/* Icon in dropdown and trigger */
.choice-icon {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--bbt-neutral-base);
  line-height: 0;
}

.choice-icon svg {
  width: 20px !important;
  height: 20px !important;
  display: block;
}

/* Avatar in dropdown and trigger */
.choice-avatar {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1;
}

/* Avatar in the selected trigger area (smaller size) */
.choices__item[data-item] .choice-avatar,
.choice-avatar.choice-avatar-sm {
  width: 24px;
  height: 24px;
  min-width: 24px;
  font-size: 0.625rem;
}

/* Flag emoji in dropdown and trigger */
.choice-flag {
  display: inline-flex !important;
  align-items: center;
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 1;
}

/* Item label next to icon/avatar/flag */
.item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Checkmark for selected items in custom templates */
.choice-checkmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
  line-height: 0;
}

.choice-checkmark svg {
  width: 18px;
  height: 18px;
}

/* Hide the CSS ::after checkmark when using custom checkmark element */
.choices__list--dropdown .choices__item.is-selected .choice-checkmark ~ *,
.choices__list--dropdown .choices__item.is-selected:has(.choice-checkmark)::after {
  display: none;
}

/* Ensure custom template selected items don't get double checkmarks */
.choices__list--dropdown .choices__item--selectable.is-selected:has(.choice-checkmark)::after {
  content: none;
}

/* ========================================
   CHOICES.JS - NO RESULTS / LOADING
   ======================================== */

.choices__list--dropdown .has-no-results,
.choices .choices__list[aria-expanded] .has-no-results {
  color: var(--bbt-neutral-base);
  font-size: 0.875rem;
  padding: 0.625rem 1rem;
}

.choices__list--dropdown .has-no-choices,
.choices .choices__list[aria-expanded] .has-no-choices {
  color: var(--bbt-neutral-base);
  font-size: 0.875rem;
  padding: 0.625rem 1rem;
}
