/* Base Select2 Styles */
.select2-container {
    box-sizing: border-box;
    display: inline-block;
    margin: 0;
    position: relative;
    vertical-align: middle
}

.select2-container .select2-selection--single {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    height: 38px;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.2s ease;
}

.select2-container .select2-selection--single .select2-selection__rendered {
    display: block;
    padding-left: 12px;
    padding-right: 30px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 36px;
    font-size: 14px;
}

.select2-container .select2-selection--single .select2-selection__clear {
    background-color: transparent;
    border: none;
    font-size: 1em;
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
}

.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered {
    padding-right: 12px;
    padding-left: 30px
}

.select2-container .select2-selection--multiple {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    min-height: 38px;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.2s ease;
}

.select2-container .select2-selection--multiple .select2-selection__rendered {
    display: inline;
    list-style: none;
    padding: 0
}

.select2-container .select2-selection--multiple .select2-selection__clear {
    background-color: transparent;
    border: none;
    font-size: 1em
}

.select2-container .select2-search--inline .select2-search__field {
    box-sizing: border-box;
    border: none;
    font-size: 14px;
    margin-top: 5px;
    margin-left: 5px;
    padding: 4px 0;
    max-width: 100%;
    resize: none;
    height: 24px;
    vertical-align: bottom;
    font-family: inherit;
    overflow: hidden;
    word-break: keep-all;
    background: transparent;
}

.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button {
    -webkit-appearance: none
}

/* Dropdown Styles */
.select2-dropdown {
    border-radius: 8px;
    box-sizing: border-box;
    display: block;
    position: absolute;
    left: -100000px;
    width: 100%;
    z-index: 1051;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid;
    transition: all 0.2s ease;
}

.select2-results {
    display: block;
    max-height: 250px;
    overflow-y: auto;
}

.select2-results__options {
    list-style: none;
    margin: 0;
    padding: 4px 0
}

.select2-results__option {
    padding: 10px 12px;
    user-select: none;
    -webkit-user-select: none;
    font-size: 14px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.select2-results__option--selectable {
    cursor: pointer
}

.select2-container--open .select2-dropdown {
    left: 0
}

.select2-container--open .select2-dropdown--above {
    border-bottom: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0
}

.select2-container--open .select2-dropdown--below {
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0
}

/* Search Dropdown */
.select2-search--dropdown {
    display: block;
    padding: 8px
}

.select2-search--dropdown .select2-search__field {
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
    border-radius: 6px;
    font-size: 14px;
    border: 1px solid;
    transition: all 0.2s ease;
}

.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button {
    -webkit-appearance: none
}

.select2-search--dropdown.select2-search--hide {
    display: none
}

.select2-close-mask {
    border: 0;
    margin: 0;
    padding: 0;
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    min-height: 100%;
    min-width: 100%;
    height: auto;
    width: auto;
    opacity: 0;
    z-index: 99;
    background-color: transparent;
    filter: alpha(opacity=0)
}

.select2-hidden-accessible {
    border: 0 !important;
    clip: rect(0 0 0 0) !important;
    -webkit-clip-path: inset(50%) !important;
    clip-path: inset(50%) !important;
    height: 1px !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    width: 1px !important;
    white-space: nowrap !important
}

/* LIGHT MODE THEME */
.select2-container--default .select2-selection--single {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #111827;
}

.select2-container--default .select2-selection--single:hover {
    border-color: #d1d5db;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #111827;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #9ca3af;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
    position: absolute;
    top: 1px;
    right: 1px;
    width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #6b7280 transparent transparent transparent;
    border-style: solid;
    border-width: 5px 4px 0 4px;
    height: 0;
    width: 0;
    transition: transform 0.2s ease;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent #6b7280 transparent;
    border-width: 0 4px 5px 4px;
    transform: rotate(180deg);
}

.select2-container--default .select2-selection--multiple {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: text;
    padding: 4px 8px;
    position: relative;
    min-height: 38px;
}

.select2-container--default .select2-selection--multiple:hover {
    border-color: #d1d5db;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #374151;
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 4px 8px 4px 24px;
    position: relative;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
    font-size: 13px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    background-color: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    padding: 0;
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #ef4444;
}

/* Light Mode Dropdown */
.select2-dropdown {
    background-color: #ffffff;
    border-color: #e5e7eb;
}

.select2-search--dropdown .select2-search__field {
    background-color: #ffffff;
    border-color: #e5e7eb;
    color: #111827;
}

.select2-search--dropdown .select2-search__field:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.select2-results__option {
    color: #374151;
}

.select2-results__option--highlighted {
    background-color: #f3f4f6 !important;
    color: #111827 !important;
}

.select2-results__option--selected {
    background-color: #eff6ff !important;
    color: #1d4ed8 !important;
}

.select2-results__option--disabled {
    color: #9ca3af !important;
    cursor: not-allowed !important;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.select2-container--default.select2-container--disabled .select2-selection--single,
.select2-container--default.select2-container--disabled .select2-selection--multiple {
    background-color: #f9fafb;
    border-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

/* DARK MODE THEME */
html.dark .select2-container--default .select2-selection--single,
.dark .select2-container--default .select2-selection--single {
    background-color: #04041d;
    border: 1px solid #374151;
    color: #f9fafb;
}

html.dark .select2-container--default .select2-selection--single:hover,
.dark .select2-container--default .select2-selection--single:hover {
    border-color: #4b5563;
}

html.dark .select2-container--default .select2-selection--single .select2-selection__rendered,
.dark .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #f9fafb;
}

html.dark .select2-container--default .select2-selection--single .select2-selection__placeholder,
.dark .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #9ca3af;
}

html.dark .select2-container--default .select2-selection--single .select2-selection__arrow b,
.dark .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #9ca3af transparent transparent transparent;
}

html.dark .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b,
.dark .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent #9ca3af transparent;
}

html.dark .select2-container--default .select2-selection--multiple,
.dark .select2-container--default .select2-selection--multiple {
    background-color: #04041d;
    border: 1px solid #374151;
}

html.dark .select2-container--default .select2-selection--multiple:hover,
.dark .select2-container--default .select2-selection--multiple:hover {
    border-color: #4b5563;
}

html.dark .select2-container--default .select2-selection--multiple .select2-selection__choice,
.dark .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #1f2937;
    border: 1px solid #374151;
    color: #f9fafb;
}

html.dark .select2-container--default .select2-selection--multiple .select2-selection__choice__remove,
.dark .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #9ca3af;
}

html.dark .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover,
.dark .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #ef4444;
}

/* Dark Mode Dropdown */
html.dark .select2-dropdown,
.dark .select2-dropdown {
    background-color: #04041d;
    border-color: #374151;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

html.dark .select2-search--dropdown .select2-search__field,
.dark .select2-search--dropdown .select2-search__field {
    background-color: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

html.dark .select2-search--dropdown .select2-search__field:focus,
.dark .select2-search--dropdown .select2-search__field:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

html.dark .select2-search--dropdown .select2-search__field::placeholder,
.dark .select2-search--dropdown .select2-search__field::placeholder {
    color: #9ca3af;
}

html.dark .select2-results__option,
.dark .select2-results__option {
    color: #f9fafb;
}

html.dark .select2-results__option--highlighted,
.dark .select2-results__option--highlighted {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
}

html.dark .select2-results__option--selected,
.dark .select2-results__option--selected {
    background-color: #1e40af !important;
    color: #ffffff !important;
}

html.dark .select2-results__option--disabled,
.dark .select2-results__option--disabled {
    color: #6b7280 !important;
}

html.dark .select2-container--default.select2-container--focus .select2-selection--single,
html.dark .select2-container--default.select2-container--focus .select2-selection--multiple,
.dark .select2-container--default.select2-container--focus .select2-selection--single,
.dark .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

html.dark .select2-container--default.select2-container--disabled .select2-selection--single,
html.dark .select2-container--default.select2-container--disabled .select2-selection--multiple,
.dark .select2-container--default.select2-container--disabled .select2-selection--single,
.dark .select2-container--default.select2-container--disabled .select2-selection--multiple {
    background-color: #111827;
    border-color: #374151;
    color: #6b7280;
}

/* Search field in multiple select for dark mode */
html.dark .select2-container .select2-search--inline .select2-search__field,
.dark .select2-container .select2-search--inline .select2-search__field {
    color: #f9fafb;
}

html.dark .select2-container .select2-search--inline .select2-search__field::placeholder,
.dark .select2-container .select2-search--inline .select2-search__field::placeholder {
    color: #9ca3af;
}

/* Scrollbar styling for dark mode */
html.dark .select2-results::-webkit-scrollbar,
.dark .select2-results::-webkit-scrollbar {
    width: 6px;
}

html.dark .select2-results::-webkit-scrollbar-track,
.dark .select2-results::-webkit-scrollbar-track {
    background: #1f2937;
}

html.dark .select2-results::-webkit-scrollbar-thumb,
.dark .select2-results::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
}

html.dark .select2-results::-webkit-scrollbar-thumb:hover,
.dark .select2-results::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Light mode scrollbar */
.select2-results::-webkit-scrollbar {
    width: 6px;
}

.select2-results::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.select2-results::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.select2-results::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive improvements */
@media (max-width: 640px) {
    .select2-container .select2-selection--single {
        height: 42px;
    }
    
    .select2-container .select2-selection--single .select2-selection__rendered {
        line-height: 40px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .select2-container .select2-selection--multiple {
        min-height: 42px;
    }
    
    .select2-dropdown {
        max-height: 50vh;
    }
    
    .select2-results {
        max-height: 40vh;
    }
    
    .select2-results__option {
        padding: 12px;
        font-size: 16px;
    }
    
    .select2-search--dropdown .select2-search__field {
        font-size: 16px;
        padding: 10px 12px;
    }
}