/**
 * Select2 Custom Styles for Front Registration
 * Adapts the admin Select2 styles with front-end colors
 */

/* Container */
.select2-container--bootstrap4 .select2-selection {
    min-height: 42px;
    border: 1px solid #d1d3e2;
    border-radius: 0.35rem;
    transition: all 0.15s ease-in-out;
}

.select2-container--bootstrap4 .select2-selection:focus,
.select2-container--bootstrap4 .select2-selection:active {
    border-color: #559dd3;
    box-shadow: none !important;
    outline: 0;
}

/* Single select */
.select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
    padding: 0.5rem 0.75rem;
    line-height: 1.5;
    color: #5a5c69;
}

/* Dropdown */
.select2-container--bootstrap4 .select2-dropdown {
    border-color: #d1d3e2;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

/* Search input in dropdown */
.select2-container--bootstrap4 .select2-search--dropdown .select2-search__field {
    border-color: #d1d3e2;
    padding: 0.5rem;
    font-size: 0.9rem;
}

.select2-container--bootstrap4 .select2-search--dropdown .select2-search__field:focus {
    border-color: #559dd3;
    outline: none;
}

/* Results */
.select2-container--bootstrap4 .select2-results__option {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

/* Highlighted (hover) */
.select2-container--bootstrap4 .select2-results__option--highlighted {
    background-color: #559dd3;
    color: white;
}

/* Selected options - keep style even on hover */
.select2-container--bootstrap4 .select2-results__option--selected {
    background-color: #fff !important;
    color: #5a5c69 !important;
    position: relative !important;
    padding-right: 30px !important;
}

/* Checkmark for selected options */
.select2-container--bootstrap4 .select2-results__option--selected::after {
    content: '\f00c' !important;
    font-family: 'Font Awesome 5 Free' !important;
    font-weight: 900 !important;
    position: absolute !important;
    right: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: #5CACDB !important;
    font-size: 0.85rem !important;
}

/* Multiple select with tags/badges - FRONT COLORS */
.select2-container--bootstrap4 .select2-selection--multiple {
    min-height: 42px;
    padding: 0.5rem;
}

.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    width: 100%;
    margin-bottom: 0 !important;
}

/* Tags container - appears first */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered li:not(.select2-search) {
    display: inline-block;
    vertical-align: middle;
    margin: 0 0.375rem 0.375rem 0;
}

/* Remove bottom margin when no tags (only search field) */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered:has(li.select2-search:only-child) {
    margin-bottom: 0;
}

/* Alternative: hide rendered container when empty and only show search */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered:has(li.select2-search:only-child) li:not(.select2-search) {
    display: none;
}

/* Search field - appears at the bottom */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered li.select2-search {
    display: inline-block;
    flex: 1 1 auto;
    margin: 0.25rem 0 0 0;
}

/* When search is the first and only child (no tags), no top margin */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered li.select2-search:first-child {
    margin-top: 0;
}

/* Tags/Badges styling - Style exact demandé */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice {
    color: #5B5E61;
    background-color: #FDEFE7;
    font-family: 'Nunito', sans-serif;
    font-weight: normal;
    border-radius: 20px;
    padding: 6px 12px;
    border: none;
    display: inline-flex;
    align-items: center;
    position: relative;
    padding-right: 28px;
    margin: 0;
    line-height: 1;
    transition: all 0.2s ease;
    max-width: 100%!important;
}

.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice:hover {
    background-color: #e0e0e0;
}

/* Remove button */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove {
    color: #6c757d;
    font-size: 1.1rem;
    line-height: 1;
    font-weight: 700;
    margin: 0;
    padding: 0;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    background: none !important;
    border: none !important;
}

.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #559dd3;
    opacity: 1;
    background: none !important;
}

/* Text content */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__display {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: flex;
    align-items: center;
    max-width: 100%;
    line-height: 1;
}

/* Search input */
.select2-container--bootstrap4 .select2-selection--multiple .select2-search--inline .select2-search__field {
    margin: 0;
    padding: 0;
    min-width: 150px;
    font-size: 0.9rem;
    box-sizing: border-box;
    border: none;
    outline: none;
    height: auto;
}

/* Override default Select2 height */
.select2-container .select2-search--inline .select2-search__field {
    height: auto !important;
    padding: 0 !important;
}

.select2-container--bootstrap4 .select2-selection--multiple .select2-search--inline .select2-search__field::placeholder {
    color: #adb5bd;
    opacity: 0.7;
}

.select2-container--bootstrap4 .select2-selection--multiple:focus,
.select2-container--bootstrap4 .select2-selection--multiple:active {
    border-color: #559dd3;
    box-shadow: none !important;
}

/* Disabled state */
.select2-container--bootstrap4.select2-container--disabled .select2-selection--single,
.select2-container--bootstrap4.select2-container--disabled .select2-selection--multiple {
    background-color: #f5f5f5 !important;
    border-color: #f0f0f0 !important;
    cursor: not-allowed;
    opacity: 1;
}

.select2-container--bootstrap4.select2-container--disabled .select2-selection__rendered {
    color: #6c757d;
}

.select2-container--bootstrap4.select2-container--disabled .select2-selection__placeholder {
    color: #6c757d !important;
    font-style: italic;
}

/* Clear button */
.select2-container--bootstrap4 .select2-selection__clear {
    color: #858796;
    font-size: 1.2rem;
    font-weight: bold;
    margin-right: 0.5rem;
    transition: color 0.2s;
    position: absolute;
    right: 0;
}

.select2-container--bootstrap4 .select2-selection__clear:hover {
    color: #5a5c69;
}

/* Placeholder */
.select2-container--bootstrap4 .select2-selection__placeholder {
    color: #adb5bd;
    opacity: 0.7;
    font-size: 0.9rem;
}

/* Arrow indicator */
.select2-container--bootstrap4 .select2-selection__arrow {
    height: 100%;
    right: 0.5rem;
}

.select2-container--bootstrap4 .select2-selection__arrow b {
    border-color: #858796 transparent transparent transparent;
    border-width: 6px 5px 0 5px;
}

.select2-container--bootstrap4.select2-container--open .select2-selection__arrow b {
    border-color: transparent transparent #858796 transparent;
    border-width: 0 5px 6px 5px;
}

/* When no tags, search field should be at normal position and take full width */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered:empty + .select2-search,
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered li.select2-search:only-child {
    margin: 0;
    flex: 1 1 100%;
}

.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered li.select2-search:only-child .select2-search__field {
    width: 100% !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice {
        font-size: 0.8rem;
        padding: 0.3rem 1.6rem 0.3rem 0.6rem;
    }

    .select2-container--bootstrap4 .select2-dropdown {
        font-size: 0.85rem;
    }
}
