/* ==========================================================================
   Thème Select2 - PIA Gestion
   Reproduit exactement le design des inputs Tailwind de l'application :
   h-10 rounded-lg border-gray-300 bg-white text-sm shadow-sm
   focus:border-primary focus:ring-2 focus:ring-primary/20
   ========================================================================== */

/* Conteneur Select2 */
.select2-container {
    width: 100% !important;
    font-family: 'Montserrat', Arial, Helvetica, sans-serif;
}

/* Bouton principal (le "select" visible) */
.select2-container--default .select2-selection--single {
    height: 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #171717;
    font-size: 0.875rem;
    line-height: 1.25rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

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

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: #006c3a;
    box-shadow: 0 0 0 2px rgba(0, 108, 58, 0.2);
}

/* Texte sélectionné */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #171717;
    line-height: 1.5rem;
    padding-right: 1.5rem;
}

/* Placeholder */
.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Flèche */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 2.5rem;
    width: 1.5rem;
    right: 0.5rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #6b7280 transparent transparent transparent;
    border-width: 5px 4px 0 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;
}

/* Bouton d'effacement (single) */
.select2-container--default .select2-selection--single .select2-selection__clear {
    color: #6b7280;
    font-size: 1rem;
    margin-right: 0.25rem;
    cursor: pointer;
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: #ef4444;
}

/* ==========================================================================
   Multi-select
   ========================================================================== */
.select2-container--default .select2-selection--multiple {
    min-height: 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #171717;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.select2-container--default .select2-selection--multiple:hover {
    border-color: #9ca3af;
}

.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: #006c3a;
    box-shadow: 0 0 0 2px rgba(0, 108, 58, 0.2);
}

/* Tags (items sélectionnés en multi) */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: rgba(0, 108, 58, 0.1);
    color: #006c3a;
    border: 1px solid rgba(0, 108, 58, 0.2);
    border-radius: 0.375rem;
    padding: 0.125rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-top: 0.25rem;
    margin-right: 0.25rem;
}

/* Bouton de suppression d'un tag */
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #006c3a;
    margin-right: 0.25rem;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    background: transparent;
}

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

/* Champ de recherche dans multi */
.select2-container--default .select2-search--inline .select2-search__field {
    color: #171717;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    min-width: 5rem;
}

.select2-container--default .select2-search--inline .select2-search__field::placeholder {
    color: #6b7280;
}

/* ==========================================================================
   Dropdown
   ========================================================================== */
.select2-container--default .select2-dropdown {
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #171717;
    font-size: 0.875rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    margin-top: 4px;
}

/* Dropdown au-dessus (quand pas de place en bas) */
.select2-container--default.select2-dropdown--above .select2-dropdown {
    margin-top: 0;
    margin-bottom: 4px;
}

/* Champ de recherche dans le dropdown */
.select2-container--default .select2-search--dropdown {
    padding: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background: #ffffff;
    color: #171717;
    font-size: 0.875rem;
    padding: 0.375rem 0.625rem;
    width: 100%;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #006c3a;
    box-shadow: 0 0 0 2px rgba(0, 108, 58, 0.2);
}

/* Options */
.select2-container--default .select2-results__option {
    padding: 0.5rem 0.75rem;
    color: #171717;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.1s;
    border-radius: 0.25rem;
    margin: 1px 0;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: rgba(0, 108, 58, 0.1);
    color: #006c3a;
    font-weight: 500;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: #006c3a;
    color: #ffffff;
    font-weight: 600;
}

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

/* Groupes d'options */
.select2-container--default .select2-results__group {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

/* Message "no results" */
.select2-container--default .select2-results__option.select2-results__message {
    color: #6b7280;
    font-style: italic;
    text-align: center;
    padding: 0.75rem;
}

/* ==========================================================================
   États spéciaux
   ========================================================================== */

/* Désactivé */
.select2-container--default.select2-container--disabled .select2-selection--single,
.select2-container--default.select2-container--disabled .select2-selection--multiple {
    background: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.7;
}

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

.select2-container--default.select2-container--focus .select2-selection--single.is-invalid,
.select2-container--default.select2-container--focus .select2-selection--multiple.is-invalid {
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 640px) {
    .select2-container--open .select2-dropdown {
        max-width: calc(100vw - 2rem);
    }
}

/* Cacher le select original (Select2 le fait par défaut, mais on s'assure) */
select[data-select2-id] {
    opacity: 0;
    position: absolute;
    pointer-events: none;
}
