/**
 * Select2 RTL Custom Styles
 * Custom styling for Select2 dropdown to match Manaaqla design
 */

/* RTL Support */
.select2-container {
    direction: rtl;
    text-align: right;
}

/* Main select box */
.select2-container--default .select2-selection--single {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    height: 48px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single:focus,
.select2-container--default.select2-container--open .select2-selection--single {
    outline: none;
    border-color: #0071E3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

/* Arrow */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 48px;
    left: 1rem;
    right: auto;
}

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

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

/* Selected value */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #374151;
    line-height: 48px;
    padding-right: 0;
    padding-left: 2rem;
    font-size: 0.875rem;
}

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

/* Dropdown */
.select2-container--default .select2-results__option {
    padding: 0.75rem 1rem;
    text-align: right;
    font-size: 0.875rem;
    color: #374151;
}

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

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: #eff6ff;
    color: #1e40af;
}

.select2-container--default .select2-results__option--highlighted[aria-selected=true] {
    background-color: #0071E3;
    color: white;
}

/* Dropdown container */
.select2-dropdown {
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    margin-top: 0.25rem;
}

.select2-container--default .select2-results > .select2-results__options {
    max-height: 250px;
    overflow-y: auto;
    padding: 0.25rem;
}

/* Search box */
.select2-container--default .select2-search--dropdown {
    padding: 0.5rem;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    text-align: right;
    direction: rtl;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    outline: none;
    border-color: #0071E3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

/* No results */
.select2-container--default .select2-results__message {
    color: #6b7280;
    padding: 1rem;
    text-align: center;
    font-size: 0.875rem;
}

/* Multiple select */
.select2-container--default .select2-selection--multiple {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    min-height: 48px;
    padding: 0.25rem 0.5rem;
}

.select2-container--default .select2-selection--multiple:focus,
.select2-container--default.select2-container--open .select2-selection--multiple {
    outline: none;
    border-color: #0071E3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

/* Selected tags in multiple */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #0071E3;
    border: none;
    border-radius: 0.5rem;
    color: white;
    padding: 0.25rem 0.75rem;
    margin: 0.25rem;
    font-size: 0.875rem;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: white;
    margin-left: 0.5rem;
    margin-right: 0;
    order: 1;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #fee;
}

/* Search in multiple */
.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
    margin: 0.25rem;
    padding: 0.25rem 0.5rem;
    text-align: right;
    direction: rtl;
}

/* Loading state */
.select2-container--default .select2-results__option--loading {
    text-align: center;
    color: #6b7280;
}

/* Disabled state */
.select2-container--default .select2-selection--single.select2-selection--disabled,
.select2-container--default .select2-selection--multiple.select2-selection--disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Clear button */
.select2-container--default .select2-selection__clear {
    color: #6b7280;
    font-size: 1.25rem;
    margin-left: 0.5rem;
    margin-right: 0;
    position: absolute;
    left: 2.5rem;
}

.select2-container--default .select2-selection__clear:hover {
    color: #374151;
}

/* Scrollbar styling */
.select2-results__options::-webkit-scrollbar {
    width: 8px;
}

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

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

.select2-results__options::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Match with form inputs */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    transition: all 0.15s ease-in-out;
}

/* Validation states */
.select2-container--default.is-invalid .select2-selection--single,
.select2-container--default.is-invalid .select2-selection--multiple {
    border-color: #ef4444;
}

.select2-container--default.is-valid .select2-selection--single,
.select2-container--default.is-valid .select2-selection--multiple {
    border-color: #10b981;
}

/* Focus visible for accessibility */
.select2-container--default .select2-selection--single:focus-visible,
.select2-container--default .select2-selection--multiple:focus-visible {
    outline: 2px solid #0071E3;
    outline-offset: 2px;
}
