/* ==========================================================================
   SELECT2 : BASE & CHAMP PRINCIPAL (Look SaaS Moderne)
   ========================================================================== */

/* 1. Reset Global et Largeur */
.select2-container--bootstrap-5 {
    width: 100% !important;
    font-size: 0.8rem;
}

/* 2. Le Champ (Fermé) - Style harmonisé avec vos form-control */
.select2-container--bootstrap-5 .select2-selection {
    display: flex;
    align-items: center;
    min-height: 48px !important; /* Respiration SaaS */
    padding: 6px 16px !important;
    background-color: var(--bs-tertiary-bg, #f8f9fa) !important;
    border: 1px solid #cbd5e1 !important; /* Gris très doux (Slate 300) */
    border-radius: 8px !important; /* Arrondi généreux */
    box-shadow: 0 1px 2px rgba(0,0,0,0.03) !important;
    transition: all 0.2s ease !important;
}

/* 3. Texte du champ sélectionné et placeholder */
.select2-container--bootstrap-5 .select2-selection__rendered {
    color: #334155 !important;
    font-weight: 500;
    font-size: 0.8rem !important;
    padding-left: 0 !important;
    line-height: 1.5 !important;
}

.select2-container--bootstrap-5 .select2-selection__placeholder {
    color: #94a3b8 !important; /* Gris neutre */
}

/* 4. Flèche (Chevron) */
.select2-container--bootstrap-5 .select2-selection__arrow {
    height: 100% !important;
    right: 16px !important;
}

/* 5. État Focus (Ouvert) - Halo #044a56 */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    background-color: #ffffff !important;
    border-color: #044a56 !important;
    box-shadow: 0 0 0 4px rgba(4, 74, 86, 0.15) !important; /* Halo doux personnalisé */
}


/* ==========================================================================
   SELECT2 : MENU FLOTTANT (Dropdown SaaS)
   ========================================================================== */

/* 1. Conteneur principal du menu (L'ombre flottante) */
.select2-dropdown {
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    background-color: #ffffff !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
    margin-top: 8px !important; /* Détache le menu du champ */
    padding-bottom: 8px !important;
    overflow: hidden !important;
    z-index: 1060 !important; /* Au-dessus de l'offcanvas */
}

/* 2. Barre de recherche dans le menu */
.select2-search--dropdown {
    padding: 12px !important;
    background-color: #f8fafc !important;
    border-bottom: 1px solid #f1f5f9 !important;
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    padding: 8px 14px !important;
    font-size: 0.8rem !important;
    transition: all 0.2s ease !important;
}

.select2-search--dropdown .select2-search__field:focus {
    border-color: #044a56 !important;
    box-shadow: 0 0 0 3px rgba(4, 74, 86, 0.1) !important;
    outline: none !important;
}

.select2-container .select2-results__options {
    max-height: 250px !important;
    overflow-y: auto !important;
}

/* 3. Les options (Bulles flottantes) */
.select2-results__option {
    padding: 10px 16px !important;
    margin: 2px 8px !important; /* Crée l'effet bulle détachée des bords */
    font-size: 0.85rem !important;
    color: #475569 !important;
    border-radius: 6px !important;
    border: none !important;
    transition: all 0.15s ease !important;
}

/* Option au survol (Gris perle) */
.select2-results__option--highlighted {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

/* Option déjà sélectionnée (Votre couleur #044a56 mais très clair pour le fond) */
.select2-results__option[aria-selected=true] {
    background-color: rgba(4, 74, 86, 0.08) !important; /* Fond teinté à 8% */
    color: #044a56 !important;
    font-weight: 700 !important;
}


/* ==========================================================================
   SELECT2 : MULTI-SELECT (Numéros d'équipement)
   ========================================================================== */

/* Ajustement du champ pour le multiselect */
.select2-container--bootstrap-5 .select2-selection--multiple {
    padding: 4px 10px !important;
    min-height: 48px !important;
}

/* Les "Pilules" (Tags) */
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 12px 0 34px !important; /* Espace pour la croix */
    margin: 4px 6px 4px 0;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px !important; /* Très arrondi */
    font-size: 0.8rem !important;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

/* La croix de suppression sur la pilule */
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 28px !important;
    height: 100% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    border-right: 1px solid #f1f5f9;
    color: #94a3b8;
    font-size: 1.1rem !important;
    transition: color 0.15s ease;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove:hover {
    background-color: transparent;
    color: #ef4444; /* Rouge doux (Tailwind Red-500) */
}

/* 1. Survol d'une option classique (Non sélectionnée) */
.select2-container--bootstrap-5 .select2-results__option--highlighted:not([aria-selected="true"]) {
    background-color: #f1f5f9 !important; /* Gris perle doux */
    color: #0f172a !important;
}

/* 2. Option déjà sélectionnée (Au repos) */
.select2-container--bootstrap-5 .select2-results__option[aria-selected="true"],
.select2-container--bootstrap-5 .select2-results__option--selected {
    background-color: rgba(4, 74, 86, 0.08) !important; /* Fond teinté à 8% de votre couleur */
    color: #044a56 !important;
    font-weight: 600 !important;
}

/* 3. Option déjà sélectionnée (Au survol) - Élimine le flash bleu vif */
.select2-container--bootstrap-5 .select2-results__option[aria-selected="true"].select2-results__option--highlighted,
.select2-container--bootstrap-5 .select2-results__option--selected.select2-results__option--highlighted {
    background-color: #044a56 !important; /* Votre couleur en plein */
    color: #ffffff !important; /* Texte en blanc pour un contraste parfait */
}

/* ==========================================================================
   SELECT2 : VARIANTE "GRILLE" (Équipements)
   ========================================================================== */

.select2-dropdown--grid .select2-results__options {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px !important;
}

.select2-dropdown--grid .select2-results__option {
    margin: 0 !important; /* Enlève la marge bulle pour la grille */
    text-align: center !important;
    border: 1px solid #e2e8f0 !important;
    background-color: #f8fafc !important;
}

.select2-dropdown--grid .select2-results__option--highlighted {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
}

.select2-container .select2-search--inline .select2-search__field {
    padding: .2rem .25rem !important;
    font-size: 0.8rem !important;
    font-weight: 400 !important;
    color: #000000 !important;
}

/* ==========================================================================
   SELECT2 : VARIANTE "RICH" (Catégories avec description)
   ========================================================================== */

.select2-dropdown--rich .select2-results__options {
    display: block !important;
    padding: 8px 0 !important;
    max-height: 400px;
}

.select2-dropdown--rich .select2-results__option {
    display: block !important;
    margin: 4px 12px !important; /* Bulles plus larges */
    padding: 12px 16px !important;
    border: 1px solid transparent !important;
}

/* Effet sélectionné spécifique au Rich pour bien voir le bloc */
.select2-dropdown--rich .select2-results__option[aria-selected=true] {
    border-color: rgba(4, 74, 86, 0.2) !important;
    background-color: rgba(4, 74, 86, 0.04) !important;
}