/**
 * Custom styles for Select2 to match Tailwind CSS design
 */

/* Ensure Select2 dropdowns are scrollable */
.select2-dropdown-scrollable {
    max-height: none;
    overflow: visible;
}

.select2-results__options {
    max-height: 420px !important;
    overflow-y: auto !important;
}

/* Match Tailwind border radius and spacing - more compact */
.select2-container--bootstrap-5 .select2-selection {
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    min-height: 2.5rem;
    padding: 0.125rem 0.375rem;
    font-size: 0.875rem;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    padding-left: 0;
    padding-right: 0;
    line-height: 2.25rem;
    padding-top: 0;
    padding-bottom: 0;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 2.25rem;
    right: 0.5rem;
    top: 0;
}

/* Dropdown styling - more compact */
.select2-dropdown {
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    box-sizing: border-box;
    max-width: calc(100vw - 1rem);
}

.select2-results__option {
    padding: 0.375rem 0.625rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.select2-results__option--highlighted {
    background-color: #10b981;
    color: white;
}

.select2-results__option[aria-selected="true"] {
    background-color: #d1fae5;
    color: #065f46;
}

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

.select2-search--dropdown .select2-search__field:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Focus states */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Mobile responsiveness */
@media (max-width: 640px) {
    .select2-results__options {
        max-height: 55vh !important;
    }
    
    .select2-dropdown {
        font-size: 16px; /* Prevent zoom on iOS */
        max-width: calc(100vw - 0.75rem);
    }
}

/* Ensure Select2 doesn't break form layouts - but keep it compact */
.select2-container {
    width: 100% !important;
}

/* Make Select2 container more compact */
.select2-container--bootstrap-5 {
    font-size: 0.875rem;
}

/* Reduce padding in selection area */
.select2-container--bootstrap-5 .select2-selection--single {
    height: auto;
    min-height: 2.5rem;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    padding-left: 0.5rem;
    padding-right: 1.75rem;
}

/* Keep open dropdowns above nearby UI layers */
.select2-container--open .select2-dropdown {
    z-index: 1060;
}

/* Make sure Select2 container doesn't exceed parent */
.select2-container {
    max-width: 100%;
    box-sizing: border-box;
}

/* Reduce overall size */
.select2-container--bootstrap-5 .select2-selection {
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Compact results */
.select2-results__option {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Clear button styling */
.select2-selection__clear {
    margin-right: 0.5rem;
    cursor: pointer;
}

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