/* ========================================
   SELECT2 - STYLES PERSONNALISÉS COHÉRENTS
   ======================================== */

/* ========================================
   CONTENEUR PRINCIPAL
   ======================================== */
.select2-container {
    width: 100% !important;
    box-shadow: none !important;
    font-family: inherit !important;
}

/* ========================================
   SÉLECTION SIMPLE - COHÉRENT AVEC LES INPUTS
   ======================================== */
.select2-container--default .select2-selection--single {
    border-radius: var(--border-radius) !important;
    border: 1px solid var(--border-color) !important;
    height: 50px !important;
    background-color: var(--white) !important;
    box-shadow: none !important;
    line-height: 50px !important;
    transition: all var(--transition-normal) !important;
}

.select2-container--default
    .select2-selection--single
    .select2-selection__rendered {
    line-height: 48px !important;
    padding-left: 15px !important;
    padding-right: 40px !important;
    color: #333 !important;
    font-size: var(--font-size-sm) !important;
    font-weight: var(--font-weight-normal) !important;
}

/* ========================================
   PLACEHOLDER
   ======================================== */
.select2-container--default
    .select2-selection--single
    .select2-selection__placeholder {
    color: #9ca3af !important;
    font-style: italic !important;
    line-height: 48px !important;
}

/* ========================================
   ÉTATS INTERACTIFS
   ======================================== */
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--bg-menu) !important;
    box-shadow: 0 0 0 3px rgba(38, 70, 83, 0.1) !important;
    outline: none !important;
    transform: translateY(-1px);
}

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

.select2-container--default.select2-container--disabled
    .select2-selection--single {
    background-color: #f9fafb !important;
    color: #6b7280 !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}

/* ========================================
   FLÈCHE PERSONNALISÉE
   ======================================== */
.select2-container--default
    .select2-selection--single
    .select2-selection__arrow {
    height: 48px !important;
    right: 15px !important;
    width: 20px !important;
}

.select2-container--default
    .select2-selection--single
    .select2-selection__arrow
    b {
    border: none !important;
    height: 0 !important;
    width: 0 !important;
}

.select2-container--default
    .select2-selection--single
    .select2-selection__arrow::after {
    content: "\f078";
    font-family: "Font Awesome 6 Free", "FontAwesome", sans-serif;
    font-weight: 900;
    font-size: 12px;
    color: #666;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform var(--transition-normal);
}

.select2-container--default.select2-container--open
    .select2-selection--single
    .select2-selection__arrow::after {
    content: "\f077";
    transform: translate(-50%, -50%) rotate(180deg);
}

/* ========================================
   SÉLECTION MULTIPLE
   ======================================== */
.select2-container--default .select2-selection--multiple {
    border-radius: var(--border-radius) !important;
    border: 1px solid var(--border-color) !important;
    min-height: 50px !important;
    background-color: var(--white) !important;
    padding: 5px 10px !important;
    transition: all var(--transition-normal) !important;
}

.select2-container--default.select2-container--focus
    .select2-selection--multiple,
.select2-container--default.select2-container--open
    .select2-selection--multiple {
    border-color: var(--bg-menu) !important;
    box-shadow: 0 0 0 3px rgba(38, 70, 83, 0.1) !important;
}

.select2-container--default
    .select2-selection--multiple
    .select2-selection__choice {
    background-color: var(--bg-menu) !important;
    border: 1px solid var(--bg-menu) !important;
    border-radius: var(--border-radius-small) !important;
    color: var(--white) !important;
    font-size: var(--font-size-xs) !important;
    padding: 4px 8px !important;
    margin: 2px !important;
}

.select2-container--default
    .select2-selection--multiple
    .select2-selection__choice__remove {
    color: var(--white) !important;
    margin-right: 5px !important;
    font-weight: bold !important;
}

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

/* ========================================
   DROPDOWN
   ======================================== */
.select2-dropdown {
    border-radius: var(--border-radius-small) !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--border-color) !important;
    overflow: hidden !important;
    background: var(--white) !important;
}

/* Connexion avec le champ parent */
.select2-container--open .select2-dropdown--below {
    border-top: none !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    margin-top: -1px !important;
}

.select2-container--open .select2-dropdown--above {
    border-bottom: none !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    margin-bottom: -1px !important;
}

/* ========================================
   RÉSULTATS ET OPTIONS
   ======================================== */
.select2-results {
    padding: 0 !important;
    margin: 0 !important;
    max-height: 300px !important;
}

.select2-results__options {
    max-height: 280px !important;
    overflow-y: auto !important;
}

.select2-results__option {
    padding: 12px 15px !important;
    font-size: var(--font-size-sm) !important;
    line-height: 1.4 !important;
    color: #374151 !important;
    cursor: pointer !important;
    transition: all var(--transition-fast) !important;
    border-bottom: 1px solid #f3f4f6;
}

.select2-results__option:last-child {
    border-bottom: none;
}

.select2-container--default
    .select2-results__option--highlighted[aria-selected] {
    background-color: var(--bg-menu) !important;
    color: var(--white) !important;
    transform: translateX(3px);
}

.select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: #f0f6f5 !important;
    color: var(--bg-menu) !important;
    font-weight: var(--font-weight-semibold) !important;
}

.select2-container--default
    .select2-results__option[aria-selected="true"]:hover {
    background-color: var(--bg-menu) !important;
    color: var(--white) !important;
}

/* ========================================
   GROUPES D'OPTIONS
   ======================================== */
.select2-results__group {
    padding: 8px 15px !important;
    font-size: var(--font-size-xs) !important;
    font-weight: var(--font-weight-bold) !important;
    color: #6b7280 !important;
    background-color: #f8fafc !important;
    border-bottom: 1px solid #e5e7eb !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

/* ========================================
   CHAMP DE RECHERCHE
   ======================================== */
.select2-search--dropdown {
    padding: var(--spacing-sm) !important;
    background: #f8fafc !important;
    border-bottom: 1px solid #e5e7eb !important;
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid #e5e7eb !important;
    padding: 8px 12px !important;
    border-radius: var(--border-radius-small) !important;
    margin: 0 !important;
    width: 100% !important;
    box-shadow: none !important;
    font-size: var(--font-size-sm) !important;
    background: var(--white) !important;
    transition: border-color var(--transition-fast) !important;
}

.select2-search--dropdown .select2-search__field:focus {
    border-color: var(--bg-menu) !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(38, 70, 83, 0.1) !important;
}

.select2-search--dropdown .select2-search__field::placeholder {
    color: #9ca3af !important;
    font-style: italic !important;
}

/* ========================================
   MESSAGES
   ======================================== */
.select2-results__message {
    color: #6b7280 !important;
    padding: 15px !important;
    font-style: italic !important;
    font-size: var(--font-size-sm) !important;
    text-align: center !important;
    background: #f8fafc !important;
}

/* Messages spécifiques */
.select2-results__option--loading-more,
.select2-results__option--loading {
    padding: 15px !important;
    text-align: center !important;
    color: var(--bg-menu) !important;
    font-style: italic !important;
}

/* ========================================
   ÉTATS D'ERREUR
   ======================================== */
.select2-container.error .select2-selection--single,
.select2-container.error .select2-selection--multiple {
    border-color: var(--error) !important;
    border-width: 2px !important;
    box-shadow: 0 0 0 3px rgba(231, 111, 81, 0.1) !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .select2-container--default .select2-selection--single {
        height: 45px !important;
        line-height: 45px !important;
    }

    .select2-container--default
        .select2-selection--single
        .select2-selection__rendered {
        line-height: 43px !important;
        font-size: 16px !important; /* Évite le zoom sur iOS */
    }

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

    .select2-container--default .select2-selection--multiple {
        min-height: 45px !important;
    }

    .select2-results__option {
        padding: 15px !important;
        font-size: 16px !important; /* Évite le zoom sur iOS */
    }

    .select2-search--dropdown .select2-search__field {
        font-size: 16px !important; /* Évite le zoom sur iOS */
        padding: 12px !important;
    }

    /* Dropdown plus grand sur mobile */
    .select2-dropdown {
        max-height: 50vh !important;
    }

    .select2-results {
        max-height: 45vh !important;
    }

    .select2-results__options {
        max-height: 40vh !important;
    }
}

@media (max-width: 480px) {
    .select2-container--default .select2-selection--single {
        height: 44px !important;
        line-height: 44px !important;
    }

    .select2-container--default
        .select2-selection--single
        .select2-selection__rendered {
        line-height: 42px !important;
        padding-left: 12px !important;
        font-size: 16px !important;
    }

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

    .select2-container--default .select2-selection--multiple {
        min-height: 44px !important;
        padding: 4px 8px !important;
    }
}

/* ========================================
   ANIMATIONS SPÉCIFIQUES
   ======================================== */
/* Animation supprimée - le transform dans l'animation créait un containing block
   qui cassait le positionnement absolu du dropdown Select2 */

/* ========================================
   SCROLLBAR PERSONNALISÉE POUR LES RÉSULTATS
   ======================================== */
.select2-results__options::-webkit-scrollbar {
    width: 6px;
}

.select2-results__options::-webkit-scrollbar-track {
    background: #f1f5f9;
}

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

.select2-results__options::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========================================
   ACCESSIBILITÉ
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .select2-dropdown,
    .select2-container--default .select2-selection--single,
    .select2-results__option {
        transition: none !important;
        animation: none !important;
    }
}

/* Focus visible pour la navigation clavier */
.select2-container--default .select2-selection--single:focus-visible,
.select2-container--default .select2-selection--multiple:focus-visible {
    outline: 2px solid var(--accent) !important;
    outline-offset: 2px !important;
}

/* Améliorer le contraste pour l'accessibilité */
@media (prefers-contrast: high) {
    .select2-container--default .select2-selection--single,
    .select2-container--default .select2-selection--multiple {
        border-width: 2px !important;
    }

    .select2-results__option {
        border-bottom-width: 2px !important;
    }
}
