/**
 * Maqam Select2 theme - used across admin forms, filters, and modals.
 * Covers both Maqam-enhanced selects (.maqam-s2) and Kartik krajee-bs5 widgets.
 */
:root {
    --maqam-s2-blue: #2782c5;
    --maqam-s2-ink: #1a3f5b;
    --maqam-s2-muted: #7a8fa3;
    --maqam-s2-border: #d8e2ec;
    --maqam-s2-border-strong: #9ec3e0;
    --maqam-s2-soft: #eaf4fb;
}

/* Selection trigger only — never apply width:100% to the open dropdown container. */
.select2-container.maqam-s2:not(.select2-container--open),
.maqam-s2.select2-container:not(.select2-container--open),
.select2-container--krajee-bs5.maqam-s2:not(.select2-container--open),
.select2-container--krajee-bs5:not(.select2-container--open) {
    width: 100% !important;
    min-width: 0 !important;
    flex-shrink: 1 !important;
}

/* Open menu is a separate container (often on body). Cap it so filters never span the page. */
.select2-container.select2-container--open {
    width: auto !important;
    min-width: 160px !important;
    max-width: min(360px, calc(100vw - 24px)) !important;
}

.select2-container.maqam-s2 .select2-dropdown,
.select2-dropdown.maqam-s2-dropdown,
.select2-container--krajee-bs5 .select2-dropdown,
.select2-container.select2-container--open .select2-dropdown {
    min-width: 0 !important;
    width: 100% !important;
    max-width: min(360px, calc(100vw - 24px)) !important;
}

.select2-dropdown.maqam-s2-dropdown .select2-results__option,
.select2-container--krajee-bs5 .select2-results__option {
    margin: 0.15rem 0;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    color: #243b4d;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: normal;
    line-height: 1.35;
    transition: background 0.12s ease, color 0.12s ease;
}

.ots-toolbar .select2-container,
.ots-toolbar__field .select2-container {
    width: 100% !important;
    max-width: 100% !important;
}

.select2-container.maqam-s2 .select2-selection--single,
.select2-container--krajee-bs5 .select2-selection--single {
    min-height: 44px !important;
    height: auto !important;
    padding: 0 0.85rem !important;
    display: flex !important;
    align-items: center !important;
    border: 1px solid var(--maqam-s2-border) !important;
    border-radius: 12px !important;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbfe 100%) !important;
    box-shadow: 0 1px 2px rgba(15, 48, 78, 0.04) !important;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    cursor: pointer;
}

.select2-container.maqam-s2 .select2-selection--single:hover,
.select2-container--krajee-bs5 .select2-selection--single:hover {
    border-color: var(--maqam-s2-border-strong) !important;
    background: #fff !important;
}

.select2-container.maqam-s2.select2-container--focus .select2-selection--single,
.select2-container.maqam-s2.select2-container--open .select2-selection--single,
.select2-container--krajee-bs5.select2-container--focus .select2-selection--single,
.select2-container--krajee-bs5.select2-container--open .select2-selection--single {
    border-color: var(--maqam-s2-blue) !important;
    background: #fff !important;
    box-shadow:
        0 0 0 3px rgba(39, 130, 197, 0.16),
        0 8px 18px rgba(26, 63, 91, 0.06) !important;
}

.select2-container.maqam-s2 .select2-selection--single .select2-selection__rendered,
.select2-container--krajee-bs5 .select2-selection--single .select2-selection__rendered {
    padding: 0 2rem 0 0 !important;
    color: var(--maqam-s2-ink) !important;
    font-size: 0.925rem !important;
    font-weight: 550;
    line-height: 1.3 !important;
    letter-spacing: 0.01em;
}

.select2-container.maqam-s2 .select2-selection--single .select2-selection__placeholder,
.select2-container--krajee-bs5 .select2-selection--single .select2-selection__placeholder {
    color: var(--maqam-s2-muted) !important;
    font-weight: 500;
}

.select2-container.maqam-s2 .select2-selection--single .select2-selection__arrow,
.select2-container--krajee-bs5 .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
    top: 0 !important;
    right: 0.55rem !important;
    width: 1.5rem !important;
}

.select2-container.maqam-s2 .select2-selection--single .select2-selection__arrow b,
.select2-container--krajee-bs5 .select2-selection--single .select2-selection__arrow b {
    border: 0 !important;
    margin: 0 !important;
    left: 50% !important;
    top: 50% !important;
    width: 0.55rem !important;
    height: 0.55rem !important;
    border-right: 2px solid #5f7d96 !important;
    border-bottom: 2px solid #5f7d96 !important;
    transform: translate(-50%, -65%) rotate(45deg) !important;
    transition: transform 0.18s ease, border-color 0.18s ease;
    background: none !important;
}

.select2-container.maqam-s2.select2-container--open .select2-selection--single .select2-selection__arrow b,
.select2-container--krajee-bs5.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: var(--maqam-s2-blue) !important;
    transform: translate(-50%, -25%) rotate(225deg) !important;
}

.select2-container.maqam-s2 .select2-selection--single .select2-selection__clear,
.select2-container--krajee-bs5 .select2-selection--single .select2-selection__clear {
    margin-right: 1.6rem;
    color: #8aa0b4;
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1;
}

.select2-container.maqam-s2 .select2-selection--single .select2-selection__clear:hover,
.select2-container--krajee-bs5 .select2-selection--single .select2-selection__clear:hover {
    color: #c0392b;
}

.select2-container--open {
    z-index: 2000 !important;
}

.select2-dropdown.maqam-s2-dropdown,
.select2-container--krajee-bs5 .select2-dropdown {
    z-index: 2000 !important;
    margin-top: 6px;
    border: 1px solid #d5e3ef !important;
    border-radius: 14px !important;
    overflow: hidden;
    background: #fff;
    box-shadow:
        0 18px 40px rgba(15, 48, 78, 0.14),
        0 2px 6px rgba(15, 48, 78, 0.06);
    animation: maqamS2In 0.16s ease-out;
}

@keyframes maqamS2In {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.select2-dropdown.maqam-s2-dropdown .select2-search--dropdown,
.select2-container--krajee-bs5 .select2-search--dropdown {
    padding: 0.7rem 0.75rem 0.45rem;
    background: linear-gradient(180deg, #f4f8fc 0%, #fff 100%);
    border-bottom: 1px solid #e6eef5;
}

.select2-dropdown.maqam-s2-dropdown .select2-search--dropdown .select2-search__field,
.select2-container--krajee-bs5 .select2-search--dropdown .select2-search__field {
    width: 100% !important;
    margin: 0;
    padding: 0.55rem 0.85rem 0.55rem 2.1rem !important;
    border: 1px solid #cfe0ee !important;
    border-radius: 999px !important;
    background:
        #fff
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%237a8fa3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='M10 10l2.5 2.5'/%3E%3C/svg%3E")
        0.8rem 50% / 14px no-repeat !important;
    box-shadow: inset 0 1px 2px rgba(15, 48, 78, 0.04);
    outline: none !important;
    font-size: 0.9rem;
    color: var(--maqam-s2-ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.select2-dropdown.maqam-s2-dropdown .select2-search--dropdown .select2-search__field:focus,
.select2-container--krajee-bs5 .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--maqam-s2-blue) !important;
    box-shadow: 0 0 0 3px rgba(39, 130, 197, 0.15);
}

.select2-dropdown.maqam-s2-dropdown .select2-results__options,
.select2-container--krajee-bs5 .select2-results__options {
    max-height: 280px;
    padding: 0.4rem;
}

.select2-dropdown.maqam-s2-dropdown .select2-results__option--highlighted.select2-results__option--selectable,
.select2-container--krajee-bs5 .select2-results__option--highlighted {
    background: linear-gradient(90deg, #2782c5 0%, #3a95d4 100%) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(39, 130, 197, 0.28);
}

.select2-dropdown.maqam-s2-dropdown .select2-results__option[aria-selected="true"],
.select2-container--krajee-bs5 .select2-results__option[aria-selected="true"] {
    background: var(--maqam-s2-soft) !important;
    color: #1a5f8f !important;
    font-weight: 650;
    position: relative;
    padding-left: 1.55rem;
}

.select2-dropdown.maqam-s2-dropdown .select2-results__option[aria-selected="true"]::before,
.select2-container--krajee-bs5 .select2-results__option[aria-selected="true"]::before {
    content: "";
    position: absolute;
    left: 0.65rem;
    top: 50%;
    width: 0.35rem;
    height: 0.65rem;
    border-right: 2px solid var(--maqam-s2-blue);
    border-bottom: 2px solid var(--maqam-s2-blue);
    transform: translateY(-60%) rotate(45deg);
}

.select2-dropdown.maqam-s2-dropdown .select2-results__option[aria-selected="true"].select2-results__option--highlighted,
.select2-container--krajee-bs5 .select2-results__option[aria-selected="true"].select2-results__option--highlighted {
    background: linear-gradient(90deg, #2782c5 0%, #3a95d4 100%) !important;
    color: #fff !important;
}

.select2-dropdown.maqam-s2-dropdown .select2-results__option[aria-selected="true"].select2-results__option--highlighted::before,
.select2-container--krajee-bs5 .select2-results__option[aria-selected="true"].select2-results__option--highlighted::before {
    border-color: #fff;
}

.select2-dropdown.maqam-s2-dropdown .select2-results__message,
.select2-container--krajee-bs5 .select2-results__message {
    color: var(--maqam-s2-muted);
    padding: 0.85rem;
    font-size: 0.85rem;
}

select.form-select:not(.select2-hidden-accessible),
select.form-control:not(.select2-hidden-accessible) {
    min-height: 44px;
    border-radius: 12px;
    border-color: var(--maqam-s2-border);
}

.ots-filter .select2-container .select2-selection--single,
.ots-toolbar__field .select2-container .select2-selection--single {
    min-height: 2.65rem !important;
}
