/* =====================================================
   Metronic-Style Select2 Theme
   CHỈ style cho Select2 – không đụng layout/body (main.css xử lý phần còn lại)
===================================================== */

/* Biến Select2 – match main.css (--bs-primary, --bg, --text, --border) */
.select2-container,
.select2-dropdown {
    --s2-primary: #3489c6;
    --s2-primary-soft: color-mix(in srgb, var(--s2-primary), white 20%);
    --s2-primary-light: rgba(52, 137, 198, 0.15);
    --s2-primary-rgb: 52, 137, 198;
    --s2-danger: #d63301;
    --s2-input-bg: #FFFFFF;
    --s2-input-border: #d9d9d9;
    --s2-text-primary: #241c15;
    --s2-text-secondary: #241c15;
    --s2-text-muted: #666666;
    --s2-input-placeholder: #999999;
    --s2-card-bg: #FFFFFF;
    --s2-card-border: #d9d9d9;
    --s2-border-radius: 1px;
}

/* =====================================================
   Select2 Custom Theme - Metronic Style
===================================================== */

.select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    background-color: var(--s2-input-bg);
    border: 1px solid var(--s2-input-border);
    border-width: 1px;
    border-radius: var(--s2-border-radius);
    min-height: 30px;
    padding: 0;
    box-sizing: border-box;
    box-shadow: 0 0 0 0 transparent;
}

.select2-container--default .select2-selection--single {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    flex: 1;
    min-width: 0;
}
.select2-container--default .select2-selection--single .select2-selection__clear {
    flex-shrink: 0;
    order: 2;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    flex-shrink: 0;
    order: 3;
}

.select2-container--default .select2-selection--single:hover,
.select2-container--default .select2-selection--multiple:hover {
    /* Không đổi border khi hover để tránh cảm giác "đậm/đen" */
    /* border-color: var(--s2-input-border); */
    border-width: 1px;
    /* Giữ box-shadow transparent để không làm element bị shift */
    box-shadow: 0 0 0 0 transparent;
}

.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: var(--s2-primary-soft); */
    border-width: 1px;
    /* box-shadow: 0 0 0 3px rgba(var(--s2-primary-rgb), 0.15); */
    outline: none;
    display: flex;
    align-items: center;
    border: 1px solid var(--s2-card-border);
}

/* Single Select */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--s2-text-primary);
    order: 1;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--s2-input-placeholder);
}

/* .select2-container--default .select2-selection--single .select2-selection__arrow {
} */

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--s2-text-muted) transparent transparent transparent;
    border-width: 5px 4px 0 4px;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent var(--s2-primary-soft) transparent;
    border-width: 0 4px 5px 4px;
}

.select2-container--default .select2-selection--single .select2-selection__clear {
    color: var(--s2-text-muted);
    font-weight: 400;
    display: flex;
    align-items: center;
    background: none !important;
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: var(--s2-danger);
}

/* Multiple Select */
.select2-container--default .select2-selection--multiple {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: flex-start;
    padding-inline: 4px;
    min-height: 30px;
}

.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: contents;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: var(--s2-primary-soft);
    border: none;
    border-radius: 4px;
    color: white;
    padding: 0;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: stretch;
    margin: 0;
    overflow: hidden;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__display {
    padding: 1px;
    display: inline-flex;
    align-items: center;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    /* font-weight: 300; */
    order: 1;
    margin: 0;
    padding: 5px 8px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.1);
    position: static !important;
    left: auto !important;
    top: auto !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove span {
    line-height: 1;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: white;
    background: rgba(0, 0, 0, 0.2);
}

.select2-container--default .select2-search--inline .select2-search__field {
    color: var(--s2-text-primary);
    font-size: 13px;
    margin-top: 4px;
    height: 24px;
}

.select2-container--default .select2-search--inline .select2-search__field::placeholder {
    color: var(--s2-input-placeholder);
}

/* Dropdown: width theo nội dung option, không kéo theo container */
.select2-dropdown {
    background-color: var(--s2-card-bg);
    border: 1px solid var(--s2-card-border);
    border-radius: var(--s2-border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
    width: max-content !important;
    max-width: min(90vw, 480px);
}

.select2-container--default .select2-search--dropdown {
    padding: 8px;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: var(--s2-input-bg);
    border: 1px solid var(--s2-input-border);
    border-radius: var(--s2-border-radius);
    color: var(--s2-text-primary);
    

}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--s2-primary-soft);
    outline: none;
    /* box-shadow: 0 0 0 3px rgba(var(--s2-primary-rgb), 0.15); */
}

.select2-results {
    padding: 4px;
}

.select2-results__options {
    overflow-x: hidden;
}

.select2-container--default .select2-results__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--s2-border-radius);
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
}

/* Nội dung option (text/badge) chiếm phần còn lại, tick nằm bên phải */
.select2-container--default .select2-results__option > * {
    flex: 1 1 auto;
    min-width: 0;
}

/* Icon check cho option đã chọn – Material Symbols Rounded (khớp với project) */
.select2-container--default .select2-results__option--selected::after {
    font-family: "Material Symbols Rounded";
    font-weight: 400;
    font-style: normal;
    font-size: 18px;
    line-height: 1;
    letter-spacing: normal;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "liga";
    content: "check";
    flex-shrink: 0;
    color: var(--s2-primary);
}

/* Không dùng nền highlight/selected – chỉ rely vào tick ở bên phải */
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option[aria-selected="true"],
.select2-container--default .select2-results__option--selected {
    background-color: transparent;
    color: var(--text);
}

.select2-container--default .select2-results__option--disabled {
    color: var(--s2-text-muted);
}

.select2-results__message {
    color: var(--s2-text-muted);
    padding: 10px 15px;
    font-size: 12px;
}

.select2-dropdown.no-search .select2-search {
    display: none !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__clear {
    font-weight: normal;
    background: none !important;
}

/* Parent container sử dụng flexbox */
.select2-container--default .select2-selection--multiple {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Tags container dùng display: contents để tags trở thành direct children */
.select2-selection__rendered {
    display: contents;
}

/* Tags không co lại */
.select2-selection__choice {
    flex-shrink: 0;
}

/* Row wrapper + tick icon cho option đã chọn trong list */
.s2-option-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.s2-option-main {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis; /* Nếu quá dài thì hiện ... thay vì mất hẳn */
}

.s2-option-tick {
    flex-shrink: 0;
    font-size: 16px;
    color: var(--s2-primary);
}

/* Search container co giãn */
.select2-search--inline {
    flex: 1 1 auto;
    min-width: 80px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    display: inline-flex;
    align-items: center;
    /* Center align items */
    background-color: var(--bs-secondary) !important;
    border: none !important;
    border-radius: 9999px !important;
    padding: 0 !important;
    /* Let inner content handle padding */
    /* margin: 4px 6px 4px 0 !important; */
    color: inherit;
    max-width: 100%;
    position: relative;
}

/* Default remove button */
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    background-color: #eee;
    /* Light gray bg for X */
    border: none;
    border-radius: 4px 0 0 4px;
    /* Attach to badge if possible? or just standalone rounded */
    color: var(--text);
    cursor: pointer;
    /*   */
    font-weight: normal;
    padding: 0 6px;
    margin-right: 0;
    /* No margin, sit next to badge */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    /* Stretch to match badge? might need height fix */
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #dc3545;
    background-color: #ddd;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__display {
    /* padding: 2px 6px; */
    cursor: default;
}

.select2-container--default .select2-results__option--selected {
    background-color: transparent;
 
}
