/* ============================================================
   MAIN-MULTISELECT — Premium chip-based multi-select
============================================================ */

.ms-wrap {
    position: relative;
    width: 100%;
    z-index: 100;
}

/* ── Control ─────────────────────────────────────────── */
.ms-control {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 7px 36px 7px 10px;
    border: 1.5px solid #d8e0ec;
    border-radius: 10px;
    background: #fff;
    min-height: 40px;
    cursor: pointer;
    transition: border 0.2s, box-shadow 0.2s, background 0.15s;
    align-items: center;
    position: relative;
    font-size: 13px;
    color: #1e293b;
}

.ms-control:hover {
    border-color: #b0bdd4;
    background: #fcfcff;
}

.ms-control.ms-focused {
    border-color: #2f7ae5;
    box-shadow: 0 0 0 3px rgba(47, 122, 229, 0.12);
    background: #fff;
}

.ms-control::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #94a3b8;
    transition: transform 0.2s;
    pointer-events: none;
}

.ms-control.ms-open::after {
    transform: translateY(-50%) rotate(180deg);
}

.ms-placeholder {
    color: #94a3b8;
    font-size: 13px;
    pointer-events: none;
    user-select: none;
}

/* Summary mode — single label instead of chips */
.ms-summary {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Chips ────────────────────────────────────────────── */
.ms-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 6px 4px 10px;
    background: #1e3a5c;
    color: #fff;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    animation: ms-chip-in 0.15s ease;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 3px rgba(30, 58, 92, 0.2);
}

@keyframes ms-chip-in {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

.ms-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    border: none;
    padding: 0;
    transition: background 0.15s;
    flex-shrink: 0;
}

.ms-chip-x:hover {
    background: rgba(255,255,255,0.45);
}

/* ── Dropdown ────────────────────────────────────────── */
.ms-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 260px;
    background: #fff;
    border: 1px solid #dde3ed;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    z-index: 9999;
    max-height: 360px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: ms-drop-in 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes ms-drop-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ms-dropdown.ms-hidden {
    display: none;
}

/* Search */
.ms-search {
    padding: 10px 12px 8px;
    border-bottom: 1px solid #eef1f6;
    flex-shrink: 0;
    background: #fafbfd;
    border-radius: 12px 12px 0 0;
}

.ms-search input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #dde3ed;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    outline: none;
    box-sizing: border-box;
    transition: border 0.15s, box-shadow 0.15s;
    background: #fff;
}

.ms-search input::placeholder {
    color: #b0b8c9;
}

.ms-search input:focus {
    border-color: #2f7ae5;
    box-shadow: 0 0 0 3px rgba(47, 122, 229, 0.10);
}

/* Options */
.ms-options {
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    padding: 4px 6px;
}

/* Option group wrapper — grid layout */
.ms-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 0 8px;
}

/* Group label */
.ms-group-label {
    padding: 10px 8px 4px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8b95a9;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 1;
    width: 100%;
    flex-basis: 100%;
}

/* Option — compact pill style */
.ms-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    font-size: 12px;
    color: #334155;
    background: #f5f7fa;
    cursor: pointer;
    transition: all 0.12s;
    border-radius: 8px;
    border: 1.5px solid transparent;
    flex: 0 0 auto;
}

.ms-option:hover {
    background: #e8edff;
    border-color: #c0ccf0;
}

.ms-option.ms-highlighted {
    background: #e4ecff;
    border-color: #b0bfe8;
}

.ms-option.ms-selected {
    color: #fff;
    font-weight: 700;
    background: #1e3a5c;
    border-color: #1e3a5c;
    box-shadow: 0 1px 3px rgba(30, 58, 92, 0.2);
}

/* Checkbox — hidden in pill mode, selection shown by pill fill */
.ms-check {
    display: none;
}

.ms-option-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* No results */
.ms-no-results {
    padding: 20px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

/* ── Mobile ──────────────────────────────────────────── */
html.mobile .ms-control {
    min-height: 44px;
    font-size: 14px;
}

html.mobile .ms-option {
    padding: 12px 14px;
    min-height: 44px;
}

html.mobile .ms-dropdown {
    max-height: 50vh;
}

html.mobile .ms-chip {
    font-size: 12px;
    padding: 5px 8px 5px 10px;
}

@media (max-width: 700px) {
    .ms-control {
        padding: 8px 36px 8px 10px;
    }
}
