/* Select2-style Searchable Select Component */

.select2-container {
  position: relative;
  display: inline-block;
  width: 100%;
}

.select2-container--default .select2-selection--single {
  background-color: #fff;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  cursor: pointer;
  display: block;
  height: 2.5rem;
  user-select: none;
  position: relative;
}

.select2-container--default .select2-selection--single:focus,
.select2-container--default .select2-selection--single:hover {
  border-color: #6b7280;
}

.select2-container--open .select2-selection--single {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
  outline: none;
}

.select2-selection__rendered {
  color: #374151;
  display: block;
  padding-left: 0.75rem;
  padding-right: 1.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 2.25rem;
}

.select2-selection__placeholder {
  color: #9ca3af;
}

.select2-selection__clear {
  background: none;
  border: none;
  cursor: pointer;
  float: right;
  font-size: 1.125rem;
  font-weight: bold;
  margin-right: 1.5rem;
  margin-top: 0.375rem;
  position: absolute;
  right: 0;
  top: 0;
  color: #9ca3af;
  z-index: 10;
}

.select2-selection__clear:hover {
  color: #ef4444;
}

.select2-selection__arrow {
  height: 2.25rem;
  position: absolute;
  right: 0.75rem;
  top: 0.125rem;
  width: 1.25rem;
}

.select2-selection__arrow b {
  border-color: #6b7280 transparent transparent transparent;
  border-style: solid;
  border-width: 5px 4px 0 4px;
  height: 0;
  left: 50%;
  margin-left: -4px;
  margin-top: -2px;
  position: absolute;
  top: 50%;
  width: 0;
}

.select2-container--open .select2-selection__arrow b {
  border-color: transparent transparent #6b7280 transparent;
  border-width: 0 4px 5px 4px;
}

/* Dropdown Styles */
.select2-dropdown {
  background-color: white;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  display: block;
  position: absolute;
  left: 0;
  margin-top: 0.25rem;
  right: 0;
  z-index: 1001;
}

.select2-dropdown--hidden {
  display: none !important;
}

.select2-dropdown--below {
  top: 100%;
}

.select2-search--dropdown {
  display: block;
  padding: 0.5rem;
}

.select2-search__field {
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  color: #374151;
  outline: 0;
  padding: 0.5rem 0.75rem;
  width: 100%;
}

.select2-search__field:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.select2-results {
  display: block;
  max-height: 200px;
  overflow-y: auto;
}

.select2-results__options {
  list-style: none;
  margin: 0;
  padding: 0;
}

.select2-results__option {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  user-select: none;
  color: #374151;
}

.select2-results__option--highlighted {
  background-color: #3b82f6;
  color: white;
}

.select2-results__option:hover {
  background-color: #f3f4f6;
}

.select2-results__option--highlighted:hover {
  background-color: #2563eb;
}

.select2-results__message {
  color: #6b7280;
  cursor: default;
  font-style: italic;
}

.select2-results__option--create {
  border-top: 1px solid #e5e7eb;
  background-color: #f9fafb;
}

.select2-results__option--create:hover {
  background-color: #3b82f6;
  color: white;
}

.select2-results__option--create:hover .select2-results__option__create {
  color: white;
}

.select2-results__option__create {
  color: #3b82f6;
  font-weight: 600;
}

/* Theme Integration */
[data-theme="dark"] .select2-container--default .select2-selection--single {
  background-color: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

[data-theme="dark"] .select2-selection__rendered {
  color: #f9fafb;
}

[data-theme="dark"] .select2-selection__placeholder {
  color: #9ca3af;
}

[data-theme="dark"] .select2-dropdown {
  background-color: #374151;
  border-color: #4b5563;
}

[data-theme="dark"] .select2-search__field {
  background-color: #4b5563;
  border-color: #6b7280;
  color: #f9fafb;
}

[data-theme="dark"] .select2-results__option {
  color: #f9fafb;
}

[data-theme="dark"] .select2-results__option:hover {
  background-color: #4b5563;
}

[data-theme="dark"] .select2-results__option--highlighted {
  background-color: #3b82f6;
}

[data-theme="dark"] .select2-results__message {
  color: #9ca3af;
}

[data-theme="dark"] .select2-results__option--create {
  border-top-color: #4b5563;
  background-color: #4b5563;
}

[data-theme="dark"] .select2-results__option--create:hover {
  background-color: #3b82f6;
}

[data-theme="dark"] .select2-results__option__create {
  color: #60a5fa;
}

/* Error State */
.select2-selection--single.select2-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 1px #ef4444;
}

.select2-selection--single.select2-error:focus,
.select2-selection--single.select2-error:hover {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

[data-theme="dark"] .select2-selection--single.select2-error {
  border-color: #f87171 !important;
  box-shadow: 0 0 0 1px #f87171;
}

[data-theme="dark"] .select2-selection--single.select2-error:focus,
[data-theme="dark"] .select2-selection--single.select2-error:hover {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.2);
}

/* Compact Style */
.select2-compact .select2-selection--single {
  height: 1.625rem;
}

.select2-compact .select2-selection__rendered {
  font-size: 0.75rem;
  line-height: 1.375rem;
  padding-left: 0.5rem;
  padding-right: 1rem;
}

.select2-compact .select2-selection__arrow {
  height: 1.375rem;
  right: 0.5rem;
  top: 0.125rem;
}

.select2-compact .select2-selection__clear {
  font-size: 0.875rem;
  margin-right: 1rem;
  margin-top: 0.125rem;
}

.select2-compact .select2-search__field {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

.select2-compact .select2-results__option {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

.select2-compact .select2-dropdown {
  min-width: 280px;
}

/* Mini Style - for inline filters */
.select2-mini {
  width: auto !important;
  min-width: 100px;
}

.select2-mini .select2-selection--single {
  height: 1.5rem;
  border-radius: 0.25rem;
}

.select2-mini .select2-selection__rendered {
  font-size: 0.625rem;
  line-height: 1.25rem;
  padding-left: 0.375rem;
  padding-right: 0.875rem;
}

.select2-mini .select2-selection__arrow {
  height: 1.25rem;
  right: 0.25rem;
  top: 0.125rem;
  width: 0.75rem;
}

.select2-mini .select2-selection__arrow b {
  border-width: 3px 3px 0 3px;
  margin-left: -3px;
}

.select2-mini .select2-selection__clear {
  font-size: 0.75rem;
  margin-right: 0.75rem;
  margin-top: 0.125rem;
}

.select2-mini .select2-dropdown {
  min-width: 180px;
  position: fixed;
  left: auto !important;
  right: auto !important;
}

.select2-mini .select2-search--dropdown {
  padding: 0.25rem;
}

.select2-mini .select2-search__field {
  font-size: 0.625rem;
  padding: 0.25rem 0.375rem;
}

.select2-mini .select2-results__option {
  font-size: 0.625rem;
  padding: 0.25rem 0.375rem;
}

/* Option with balance column */
.select2-results__option--with-balance {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.select2-results__option--with-balance .option-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 12px;
}

.select2-results__option--with-balance .option-balance {
  flex-shrink: 0;
  text-align: right;
  min-width: 90px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  opacity: 0.8;
}

.select2-results__option--highlighted .option-balance {
  opacity: 1;
}

/* Group header styles */
.select2-results__group {
  font-weight: 600 !important;
  font-size: 0.625rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em;
  color: #6b7280 !important;
  padding: 8px 8px 4px !important;
  cursor: default !important;
  background: transparent !important;
}

.select2-results__group:hover {
  background: transparent !important;
}

[data-theme="dark"] .select2-results__group {
  color: #9ca3af !important;
}