/**
 * Select2 Custom Styles
 * Estilos personalizados para Select2 integrados con el diseño de Astarloa
 * Colores basados en el dashboard: #0f172a (sidebar), #3b82f6 (primary), #60a5fa (accent)
 */

/* ========================================
   Contenedor principal
   ======================================== */
.select2-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
}

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #ffffff;
    min-height: 38px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.select2-container--default .select2-selection--single {
    padding: 4px 12px;
}

.select2-container--default .select2-selection--multiple {
    padding: 2px 8px;
}

/* ========================================
   Focus state
   ======================================== */
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* ========================================
   Texto renderizado
   ======================================== */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #374151;
    line-height: 28px;
    padding-left: 0;
    padding-right: 20px;
}

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

/* ========================================
   Flecha del dropdown
   ======================================== */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
    right: 8px;
}

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

.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;
}

/* ========================================
   Dropdown
   ======================================== */
.select2-dropdown {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background-color: #ffffff;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    margin-top: 4px;
}

.select2-container--default .select2-search--dropdown {
    padding: 8px;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 14px;
    color: #374151;
    outline: none;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ========================================
   Resultados
   ======================================== */
.select2-container--default .select2-results__option {
    padding: 10px 12px;
    color: #374151;
    font-size: 14px;
    transition: background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: #3b82f6;
    color: #ffffff;
}

.select2-container--default .select2-results__option--highlighted[aria-selected=true] {
    background-color: #2563eb;
    color: #ffffff;
}

.select2-container--default .select2-results__option[aria-disabled=true] {
    color: #9ca3af;
    cursor: not-allowed;
}

/* ========================================
   Multiple select - Tags
   ======================================== */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #3b82f6;
    border: none;
    border-radius: 4px;
    color: #ffffff;
    padding: 4px 8px;
    margin: 4px 4px 4px 0;
    font-size: 13px;
    transition: background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.select2-container--default .select2-selection--multiple .select2-selection__choice:hover {
    background-color: #2563eb;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: rgba(255, 255, 255, 0.8);
    margin-right: 6px;
    font-weight: 600;
    transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ========================================
   Campo de búsqueda en múltiple
   ======================================== */
.select2-container--default .select2-search--inline .select2-search__field {
    color: #374151;
    font-size: 14px;
    margin-top: 6px;
    padding: 0;
    outline: none;
}

.select2-container--default .select2-search--inline .select2-search__field::placeholder {
    color: #9ca3af;
}

/* ========================================
   Clear button
   ======================================== */
.select2-container--default .select2-selection__clear {
    color: #6b7280;
    font-size: 18px;
    font-weight: 600;
    margin-right: 8px;
    transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ========================================
   Loading
   ======================================== */
.select2-container--default .select2-results__message {
    color: #6b7280;
    padding: 12px;
    text-align: center;
    font-size: 14px;
}

.select2-container--default .select2-results__option--loading {
    color: #6b7280;
}

/* ========================================
   Estados disabled
   ======================================== */
.select2-container--default.select2-container--disabled .select2-selection--single,
.select2-container--default.select2-container--disabled .select2-selection--multiple {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
    cursor: not-allowed;
}

.select2-container--default.select2-container--disabled .select2-selection__choice {
    background-color: #9ca3af;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .select2-container--default .select2-selection--single,
    .select2-container--default .select2-selection--multiple {
        min-height: 42px;
    }
    
    .select2-container--default .select2-results__option {
        padding: 12px;
    }
}

/* ========================================
   Integración con form-group de Bootstrap
   ======================================== */
.form-group .select2-container {
    display: block;
    width: 100% !important;
}

/* ========================================
   Validación - estados de error/éxito
   ======================================== */
.has-error .select2-container--default .select2-selection--single,
.has-error .select2-container--default .select2-selection--multiple {
    border-color: #ef4444;
}

.has-error .select2-container--default.select2-container--focus .select2-selection--single,
.has-error .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

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

.has-success .select2-container--default.select2-container--focus .select2-selection--single,
.has-success .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Fallback fuerte: asegurar que el borde de Select2 sea visible
   (diagnóstico / override si otras reglas lo ocultan) */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid #d1d5db !important;
    box-shadow: none !important;
}

/* En caso de focus/open forzamos color de borde más contrastado */
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12) !important;
}

.select2-container--open,
.select2-dropdown {
  z-index: 99999 !important;
}
