/* Systematic Select2 Styling */
/* This provides consistent styling and easy identification of Select2 elements */

/* Base Select2 styling */
.select2-container {
  width: 100% !important;
}

.select2-container--default .select2-selection--single {
  height: 38px;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.select2-container--default .select2-selection--single:hover {
  border-color: #9ca3af;
}

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

.select2-container--default .select2-selection--multiple {
  min-height: 38px;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.select2-container--default .select2-selection--multiple:hover {
  border-color: #9ca3af;
}

.select2-container--default.select2-container--focus
  .select2-selection--multiple {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  outline: none;
}

/* Dropdown styling */
.select2-dropdown {
  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);
}

.select2-container--default .select2-results__option {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.select2-container--default
  .select2-results__option--highlighted[aria-selected] {
  background-color: #3b82f6;
  color: white;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
  background-color: #f3f4f6;
  color: #374151;
}

/* Search box styling */
.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  margin: 0.5rem;
  width: calc(100% - 1rem);
}

/* Preset-specific styling */

/* Searchable selects */
.select2-searchable .select2-container {
  min-width: 200px;
}

/* Multi-select styling */
.select2-multi .select2-selection--multiple .select2-selection__choice {
  background-color: #3b82f6;
  border: 1px solid #2563eb;
  color: white;
  border-radius: 0.25rem;
  padding: 0.125rem 0.5rem;
  margin: 0.125rem;
  font-size: 0.75rem;
}

.select2-multi .select2-selection--multiple .select2-selection__choice__remove {
  color: white;
  margin-right: 0.25rem;
}

.select2-multi
  .select2-selection--multiple
  .select2-selection__choice__remove:hover {
  color: #fbbf24;
}

/* Tags styling */
.select2-tags .select2-selection--multiple .select2-selection__choice {
  background-color: #10b981;
  border: 1px solid #059669;
  color: white;
  border-radius: 0.25rem;
  padding: 0.125rem 0.5rem;
  margin: 0.125rem;
  font-size: 0.75rem;
}

.select2-tags .select2-selection--multiple .select2-selection__choice__remove {
  color: white;
  margin-right: 0.25rem;
}

.select2-tags
  .select2-selection--multiple
  .select2-selection__choice__remove:hover {
  color: #fbbf24;
}

/* Required field styling */
.select2-required .select2-container--default .select2-selection--single {
  border-color: #dc2626;
}

.select2-required .select2-container--default .select2-selection--single:hover {
  border-color: #b91c1c;
}

.select2-required
  .select2-container--default.select2-container--focus
  .select2-selection--single {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Compact styling */
.select2-compact .select2-container {
  width: 200px !important;
}

/* Disabled styling */
.select2-disabled .select2-container--default .select2-selection--single {
  background-color: #f9fafb;
  color: #6b7280;
  cursor: not-allowed;
}

.select2-disabled .select2-container--default .select2-selection--multiple {
  background-color: #f9fafb;
  color: #6b7280;
  cursor: not-allowed;
}

/* Loading state */
.select2-loading .select2-container--default .select2-selection--single::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid #d1d5db;
  border-top: 2px solid #3b82f6;
  border-radius: 50%;
  animation: select2-spin 1s linear infinite;
}

@keyframes select2-spin {
  0% {
    transform: translateY(-50%) rotate(0deg);
  }
  100% {
    transform: translateY(-50%) rotate(360deg);
  }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .select2-container {
    width: 100% !important;
  }

  .select2-compact .select2-container {
    width: 100% !important;
  }
}

/* Form integration */
.form-group .select2-container {
  margin-bottom: 0;
}

.form-group .select2-container + .invalid-feedback {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #dc2626;
}

/* Error state */
.is-invalid .select2-container--default .select2-selection--single {
  border-color: #dc2626;
}

.is-invalid .select2-container--default .select2-selection--multiple {
  border-color: #dc2626;
}

.is-invalid
  .select2-container--default.select2-container--focus
  .select2-selection--single,
.is-invalid
  .select2-container--default.select2-container--focus
  .select2-selection--multiple {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}
