/* ========================================
   ESTILOS GLOBALES PARA SELECT2
   Corrección de colores y apariencia
   Fecha: 2025-08-26
   ======================================== */

/* Corregir el dropdown de Select2 - Fondo blanco con texto negro */
.select2-dropdown {
    background-color: #ffffff !important;
    border: 1px solid #ced4da !important;
    border-radius: 0.25rem !important;
}

/* Resultados de búsqueda - Fondo blanco */
.select2-results {
    background-color: #ffffff !important;
}

/* Opciones del dropdown - Texto negro sobre fondo blanco */
.select2-results__option {
    background-color: #ffffff !important;
    color: #212529 !important;
    padding: 6px 12px !important;
}

/* Opción hover - Fondo gris claro */
.select2-results__option--highlighted[aria-selected] {
    background-color: #f8f9fa !important;
    color: #212529 !important;
}

/* Opción seleccionada - Fondo azul claro */
.select2-results__option--selected {
    background-color: #e7f1ff !important;
    color: #0056b3 !important;
}

/* Opción al pasar el mouse */
.select2-results__option:hover {
    background-color: #e9ecef !important;
    color: #212529 !important;
    cursor: pointer;
}

/* Campo de búsqueda dentro del dropdown */
.select2-search--dropdown {
    background-color: #ffffff !important;
    padding: 4px !important;
}

.select2-search--dropdown .select2-search__field {
    background-color: #ffffff !important;
    border: 1px solid #ced4da !important;
    color: #495057 !important;
    padding: 6px 12px !important;
    border-radius: 0.25rem !important;
}

/* Select2 container - El campo principal */
.select2-container--default .select2-selection--single {
    background-color: #ffffff !important;
    border: 1px solid #ced4da !important;
    border-radius: 0.25rem !important;
    height: calc(1.5em + 0.75rem + 2px) !important;
    padding: 0.375rem 0.75rem !important;
}

/* Texto seleccionado en el campo principal */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #495057 !important;
    padding-left: 0 !important;
    padding-right: 20px !important;
}

/* Placeholder */
.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #6c757d !important;
}

/* Flecha del dropdown */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: calc(1.5em + 0.75rem) !important;
    right: 10px !important;
}

/* Select2 múltiple */
.select2-container--default .select2-selection--multiple {
    background-color: #ffffff !important;
    border: 1px solid #ced4da !important;
    border-radius: 0.25rem !important;
}

/* Opciones seleccionadas en select múltiple */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #007bff !important;
    border: 1px solid #007bff !important;
    color: #ffffff !important;
    border-radius: 0.25rem !important;
    padding: 0 10px !important;
    margin: 5px 5px 0 0 !important;
}

/* Botón de eliminar en select múltiple */
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #ffffff !important;
    margin-right: 5px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #ff0000 !important;
    background-color: transparent !important;
}

/* Estado focus del Select2 */
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #80bdff !important;
    outline: 0 !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
}

/* Select2 deshabilitado */
.select2-container--default.select2-container--disabled .select2-selection--single {
    background-color: #e9ecef !important;
    cursor: not-allowed !important;
}

.select2-container--default.select2-container--disabled .select2-selection__rendered {
    color: #6c757d !important;
}

/* Mensaje de "No se encontraron resultados" */
.select2-results__message {
    color: #6c757d !important;
    padding: 12px !important;
    background-color: #ffffff !important;
}

/* Grupo de opciones */
.select2-results__group {
    color: #6c757d !important;
    font-weight: bold !important;
    padding: 6px 12px !important;
    background-color: #f8f9fa !important;
}

/* Estilos específicos para modales Bootstrap con Select2 */
.modal .select2-dropdown {
    z-index: 10056 !important; /* Mayor que el z-index del modal */
}

.modal .select2-container--open .select2-dropdown {
    background-color: #ffffff !important;
}

/* Fix para Select2 en modales - Evitar que se cierre al hacer click */
.select2-container--open .select2-dropdown {
    z-index: 9999 !important;
}

/* Asegurar que el texto sea legible en todos los temas */
.select2-results__option[aria-selected="true"] {
    background-color: #e7f1ff !important;
    color: #0056b3 !important;
}

/* Loading/Cargando */
.select2-results__option--loading {
    background-color: #ffffff !important;
    color: #6c757d !important;
}

/* Ajustes para que coincida con Bootstrap 4/5 */
.select2-container {
    width: 100% !important;
}

/* Fix para altura consistente con inputs de Bootstrap */
.select2-container .select2-selection--single {
    height: 38px !important;
    line-height: 38px !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px !important;
}

/* Asegurar que los dropdowns en modales se vean correctamente */
body.modal-open .select2-container--open {
    z-index: 10050 !important;
}

body.modal-open .select2-dropdown {
    z-index: 10051 !important;
}

/* Fix específico para el modal de Nueva Avería */
#modalNuevaAveria .select2-dropdown,
#modalVerAveria .select2-dropdown {
    background-color: #ffffff !important;
}

#modalNuevaAveria .select2-results__option,
#modalVerAveria .select2-results__option {
    background-color: #ffffff !important;
    color: #212529 !important;
}

/* Responsive - Ajustes para móviles */
@media (max-width: 768px) {
    .select2-container--default .select2-selection--single {
        height: calc(1.5em + 1rem + 2px) !important;
        font-size: 1rem !important;
    }
    
    .select2-dropdown {
        font-size: 1rem !important;
    }
    
    .select2-results__option {
        padding: 10px 12px !important;
    }
}

/* Modo oscuro - Si el proyecto tiene tema oscuro */
[data-theme="dark"] .select2-dropdown {
    background-color: #343a40 !important;
    border-color: #495057 !important;
}

[data-theme="dark"] .select2-results__option {
    background-color: #343a40 !important;
    color: #f8f9fa !important;
}

[data-theme="dark"] .select2-results__option--highlighted[aria-selected] {
    background-color: #495057 !important;
    color: #ffffff !important;
}

[data-theme="dark"] .select2-search__field {
    background-color: #495057 !important;
    color: #f8f9fa !important;
    border-color: #6c757d !important;
}
