/**
 * Custom Select2 Theme - Matching Argon & Registani Achar Admin UI/UX
 */

/* Container reset & dimensions */
.select2-container {
    width: 100% !important;
    display: inline-block;
    vertical-align: middle;
    box-sizing: border-box;
}

.select2-container--default .select2-selection--single {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 0.5rem !important;
    padding: 0.45rem 2.25rem 0.45rem 0.85rem !important;
    display: flex !important;
    align-items: center !important;
    box-sizing: border-box !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
    outline: none !important;
    cursor: pointer;
}

/* Small variant .form-select-sm or .select2-sm */
.select2-container-sm .select2-selection--single,
.form-select-sm + .select2-container .select2-selection--single,
.select2-sm .select2-selection--single {
    height: 31px !important;
    min-height: 31px !important;
    max-height: 31px !important;
    font-size: 0.78rem !important;
    padding: 0.2rem 1.8rem 0.2rem 0.65rem !important;
    border-radius: 0.375rem !important;
}

/* Rendered selected label */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #1e293b !important;
    font-size: 0.88rem !important;
    font-weight: 500 !important;
    line-height: normal !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
}

.form-select-sm + .select2-container .select2-selection--single .select2-selection__rendered,
.select2-container-sm .select2-selection--single .select2-selection__rendered {
    font-size: 0.78rem !important;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #94a3b8 !important;
}

/* Custom SVG Dropdown Arrow (Identical to native .form-select) */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
    top: 0 !important;
    right: 0.75rem !important;
    width: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    display: none !important; /* Hide old default triangle */
}

.select2-container--default .select2-selection--single .select2-selection__arrow::after {
    content: '';
    display: block;
    width: 16px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 12px;
    transition: transform 0.2s ease;
}

/* Rotate arrow when open */
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow::after {
    transform: rotate(180deg);
}

/* Focus and Open States */
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #5e72e4 !important;
    box-shadow: 0 0 0 3px rgba(94, 114, 228, 0.15) !important;
    background-color: #ffffff !important;
}

/* Disabled State */
.select2-container--default.select2-container--disabled .select2-selection--single {
    background-color: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
    opacity: 0.7 !important;
    cursor: not-allowed !important;
}

/* Dropdown Menu Container */
.select2-dropdown {
    border: 1px solid #cbd5e1 !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
    background-color: #ffffff !important;
    z-index: 999999 !important;
    overflow: hidden !important;
    margin-top: 2px !important;
}

/* Search Box Container */
.select2-container--default .select2-search--dropdown {
    padding: 8px 10px !important;
    background-color: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
    box-sizing: border-box !important;
}

/* Search Input Field */
.select2-container--default .select2-search--dropdown .select2-search__field {
    height: 34px !important;
    padding: 6px 12px 6px 32px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 0.375rem !important;
    font-size: 0.85rem !important;
    color: #1e293b !important;
    outline: none !important;
    background-color: #ffffff !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='11' cy='11' r='8'%3e%3c/circle%3e%3cline x1='21' y1='21' x2='16.65' y2='16.65'%3e%3c/line%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: 8px center !important;
    background-size: 16px 16px !important;
    box-sizing: border-box !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #5e72e4 !important;
    box-shadow: 0 0 0 2px rgba(94, 114, 228, 0.15) !important;
}

/* Results List */
.select2-results__options {
    max-height: 230px !important;
    padding: 4px !important;
    overflow-y: auto !important;
}

.select2-results__options::-webkit-scrollbar {
    width: 6px;
}

.select2-results__options::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.select2-results__options::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.select2-results__options::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Option Items */
.select2-container--default .select2-results__option {
    padding: 8px 12px !important;
    font-size: 0.86rem !important;
    color: #1e293b !important;
    border-radius: 0.375rem !important;
    margin-bottom: 2px !important;
    cursor: pointer !important;
    transition: background-color 0.1s ease !important;
    user-select: none;
}

/* Hover / Highlighted */
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: rgba(94, 114, 228, 0.08) !important;
    color: #5e72e4 !important;
    font-weight: 500 !important;
}

/* Selected */
.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: rgba(94, 114, 228, 0.15) !important;
    color: #5e72e4 !important;
    font-weight: 600 !important;
}

/* No results state */
.select2-container--default .select2-results__option--no-results {
    color: #94a3b8 !important;
    padding: 12px !important;
    text-align: center;
    font-size: 0.84rem;
}

/* Support for Select2 inside Bootstrap .input-group */
.input-group > .select2-container {
    flex: 1 1 auto !important;
    width: 1% !important;
    min-width: 0 !important;
}

.input-group > .select2-container .select2-selection--single {
    height: 38px !important;
}

.input-group-sm > .select2-container .select2-selection--single {
    height: 31px !important;
}

.input-group:not(.has-validation) > .select2-container:not(:last-child) .select2-selection--single {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.input-group > .select2-container:not(:first-child) .select2-selection--single {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

