/*!
 * Select2 v4 Bootstrap 5 Theme - Vibrant Pastel & Liquid Glass
 * Customized to match Keponet UI
 */

.select2-container--bootstrap-5 {
  display: block;
}

select + .select2-container--bootstrap-5 {
  z-index: 1;
}

.select2-container--bootstrap-5 :focus {
  outline: 0;
}

/* Base Selection */
.select2-container--bootstrap-5 .select2-selection {
  width: 100%;
  min-height: calc(1.5em + 0.75rem + 2px);
  padding: 0.375rem 0.75rem;
  font-family: "Questrial", sans-serif;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--kep-text-primary, #1e293b);
  background-color: var(--kep-bg-surface, #ffffff);
  border: 1px solid var(--kep-border, #e8eaed);
  border-radius: 0.625rem;
  transition: border-color 150ms cubic-bezier(0.4, 0, 0.2, 1), 
              background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Focus State */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
  border-color: var(--kep-primary, #5b8def);
}

/* Open States */
.select2-container--bootstrap-5.select2-container--open.select2-container--below .select2-selection {
  border-bottom: 0 solid transparent;
  border-bottom-right-radius: 0   !important;
  border-bottom-left-radius: 0 !important;
}

.select2-container--bootstrap-5.select2-container--open.select2-container--above .select2-selection {
  border-top: 0 solid transparent;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Search */
.select2-container--bootstrap-5 .select2-search {
  width: 100%;
}

.select2-container--bootstrap-5 .select2-search--inline .select2-search__field {
  vertical-align: top;
}

/* Clear Button */
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__clear,
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear {
  position: absolute;
  top: 50%;
  right: 2.25rem;
  width: 0.75rem;
  height: 0.75rem;
  padding: 0.25em;
  overflow: hidden;
  text-indent: 100%;
  white-space: nowrap;
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236b7280'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") no-repeat center center;
  background-size: contain;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  transform: translateY(-50%);
}

.select2-container--bootstrap-5 .select2-selection__clear:hover {
  opacity: 1;
}

/* Single Selection */
.select2-container--bootstrap-5 .select2-selection--single {
  min-height: calc(2.125rem + 8.5px);
  padding-right: 2.5rem;
  align-content: center;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
  display: block;
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--kep-text-primary, #1e293b);
  min-width: 85px;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder {
  color: var(--kep-text-muted, #94a3b8);
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
  position: absolute;
  top: 50%;
  right: 0.625rem;
  width: 1.5rem;
  height: 100%;
  transform: translateY(-50%);
  transition: transform 0.2s ease-in-out;
  background: transparent no-repeat center center url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/></svg>");
  background-size: 0.75rem;
  border: 0;
  margin: 0;
  pointer-events: none;
}

.select2-container--bootstrap-5.select2-container--open .select2-selection--single .select2-selection__arrow {
  transform: translateY(-50%) rotate(180deg);
}

/* Multiple Selection */
.select2-container--bootstrap-5 .select2-selection--multiple {
  min-height: calc(2.125rem + 2px);
  padding: 0.1875rem;
  cursor: text;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-search {
  padding: 0.1875rem;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-search--inline {
  padding: 0;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-search__field {
  font-family: "Questrial", sans-serif;
  font-size: 0.9375rem;
  color: var(--kep-text-primary, #1e293b);
  background: transparent;
  border: 0;
  outline: 0;
  box-shadow: none;
  margin: 0;
  padding: 0.25rem 0.375rem;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-search__field::placeholder {
  color: var(--kep-text-muted, #94a3b8);
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1875rem;
  padding: 0.125rem 0.375rem;
  margin: 0;
  list-style: none;
  width: 100%;
  box-sizing: border-box;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
  display: flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.1875rem 0.5625rem;
  font-family: "Questrial", sans-serif;
  font-size: 0.75rem;
  font-weight: 400;
  color: #ffffff;
  background-color: var(--kep-primary, #5b8def);
  border: none;
  border-radius: 9999px;
  cursor: default;
  margin: 0;
  float: none;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.875rem;
  height: 0.875rem;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 150ms;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove:hover {
  opacity: 1;
}

/* Dropdown - Liquid Glass */
.select2-container--bootstrap-5 .select2-dropdown {
  background: var(--glass-bg-solid, rgba(255, 255, 255, 0.95));
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.65));
  border-radius: 0.875rem;
  overflow: hidden;
  z-index: 1056;
}

.select2-container--bootstrap-5 .select2-dropdown--above {
  border: 1px solid var(--kep-primary);
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.select2-container--bootstrap-5 .select2-dropdown--below {
  border: 1px solid var(--kep-primary);
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Search in dropdown */
.select2-container--bootstrap-5 .select2-dropdown .select2-search {
  padding: 0.3125rem;
  border-bottom: 1px solid var(--kep-border, #e8eaed);
}

.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field {
  display: block;
  width: 100%;
  padding: 0.4375rem 0.6875rem;
  font-family: "Questrial", sans-serif;
  font-size: 0.875rem;
  color: var(--kep-text-primary, #1e293b);
  background-color: var(--kep-bg-surface, #ffffff);
  border: 1px solid var(--kep-border, #e8eaed);
  border-radius: 0.625rem;
  outline: 0;
  transition: border-color 150ms;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field:focus {
  border-color: var(--kep-primary, #5b8def);
}

.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field::placeholder {
  color: var(--kep-text-muted, #94a3b8);
}

/* Results */
.select2-container--bootstrap-5 .select2-dropdown .select2-results {
  padding: 0.3125rem;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-results > .select2-results__options {
  max-height: 250px;
  overflow-y: auto;
  padding: 0.125rem;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-results__option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6875rem;
  font-family: "Questrial", sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--kep-text-secondary, #475569);
  background-color: transparent;
  border-radius: 0.625rem;
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
  user-select: none;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-results__option[role=group] {
  padding: 0;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-results__option[aria-disabled=true] {
  color: var(--kep-text-muted, #94a3b8);
  background-color: transparent;
  cursor: not-allowed;
  opacity: 0.6;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-results__option[aria-selected=true] {
  background-color: var(--kep-primary-light, #e8f0fe);
  color: var(--kep-primary-dark, #2563eb);
}

.select2-container--bootstrap-5 .select2-dropdown .select2-results__option--highlighted {
  background-color: var(--kep-primary, #5b8def);
  color: #ffffff;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-results__option--highlighted[aria-selected=true] {
  background-color: var(--kep-primary-hover, #3a73e5);
  color: #ffffff;
}

/* Grouped options */
.select2-container--bootstrap-5 .select2-results__group {
  display: block;
  padding: 0.5rem 0.6875rem;
  font-family: "Questrial", sans-serif;
  font-size: 0.6875rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--kep-text-muted, #94a3b8);
  cursor: default;
}

.select2-container--bootstrap-5 .select2-results__option--message {
  color: var(--kep-text-muted, #94a3b8);
  background-color: transparent;
  cursor: default;
}

/* No results */
.select2-container--bootstrap-5 .select2-results__option--no-results {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  color: var(--kep-text-muted, #94a3b8);
  background-color: transparent;
  font-size: 0.875rem;
}

/* Loading results */
.select2-container--bootstrap-5 .select2-results__option--loading {
  color: var(--kep-text-secondary, #475569);
  background-color: transparent;
  cursor: default;
}

.select2-container--bootstrap-5 .select2-progress {
  height: 0.5rem;
  margin: 0.25rem 0;
  background-color: var(--kep-gray-100, #f3f4f6);
  border-radius: 9999px;
  overflow: hidden;
}

.select2-container--bootstrap-5 .select2-progress .select2-progress-bar {
  height: 100%;
  background-color: var(--kep-primary, #5b8def);
  border-radius: 9999px;
  transition: width 200ms;
}

/* Disabled state */
.select2-container--bootstrap-5.select2-container--disabled .select2-selection {
  background-color: var(--kep-gray-100, #f3f4f6);
  border-color: var(--kep-gray-200, #e5e7eb);
  cursor: not-allowed;
  opacity: 0.7;
}

.select2-container--bootstrap-5.select2-container--disabled .select2-selection__clear,
.select2-container--bootstrap-5.select2-container--disabled .select2-selection__choice__remove {
  display: none;
}

/* RTL Support */
.select2-container--bootstrap-5[dir=rtl] .select2-selection--single {
  padding-right: 0.75rem;
  padding-left: 2.5rem;
}

.select2-container--bootstrap-5[dir=rtl] .select2-selection--single .select2-selection__arrow {
  right: auto;
  left: 0.625rem;
}

.select2-container--bootstrap-5[dir=rtl] .select2-selection--single .select2-selection__clear {
  right: auto;
  left: 2.25rem;
}

.select2-container--bootstrap-5[dir=rtl] .select2-selection--multiple .select2-selection__choice {
  float: right;
  margin-right: 0;
  margin-left: 0.375rem;
}

.select2-container--bootstrap-5[dir=rtl] .select2-selection--multiple .select2-search--inline {
  float: right;
}

.select2-container--bootstrap-5[dir=rtl] .select2-selection--multiple .select2-selection__choice__remove {
  margin-right: 0.375rem;
  margin-left: 0;
}

/* Responsive */
@media (max-width: 575.98px) {
  .select2-container--bootstrap-5 .select2-selection {
    font-size: 0.875rem;
  }
  
  .select2-container--bootstrap-5 .select2-dropdown .select2-results__option {
    font-size: 0.8125rem;
    padding: 0.4375rem 0.5625rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .select2-container--bootstrap-5 .select2-selection {
    transition: none;
  }
  
  .select2-container--bootstrap-5.select2-container--focus .select2-selection,
  .select2-container--bootstrap-5.select2-container--open .select2-selection {
    transition: none;
  }
  
  .select2-container--bootstrap-5 .select2-progress .select2-progress-bar {
    transition: none;
  }
}
