/* 多选下拉组件样式 */

/* 多选容器 */
.multiselect-container {
    position: relative;
    width: 100%;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.multiselect-container.ready {
    opacity: 1;
}

/* 多选输入框 */
.multiselect-input {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='%23212529' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    cursor: pointer;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.multiselect-input:hover {
    border-color: #86b7fe;
}

.multiselect-input:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* 已选择的标签 */
.multiselect-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    font-size: 0.875rem;
    color: #fff;
    background-color: #0d6efd;
    border-radius: 0.25rem;
    margin-right: 0.25rem;
    margin-bottom: 0rem;
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.multiselect-tag:last-child {
    margin-right: 0;
}

.multiselect-tag-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.multiselect-tag-remove {
    margin-left: 0.5rem;
    color: #fff;
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s ease-in-out;
    padding: 0;
    line-height: 1;
}

.multiselect-tag-remove:hover {
    opacity: 1;
}

/* 占位符文本 */
.multiselect-placeholder {
    color: #212529 !important;
    flex: 1;
    min-width: 0;
    opacity: 0.9;
}

/* 单选模式下的选中值显示 */
.multiselect-single-value {
    color: #212529;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* 下拉箭头在有标签时的调整 */
.multiselect-input.has-tags {
    background-position: right 0.75rem center;
}

/* 下拉选项容器 */
.multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.multiselect-dropdown.show {
    display: block;
}

/* 搜索框 */
.multiselect-search {
    padding: 0.5rem;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    background-color: #fff;
    z-index: 1001;
}

.multiselect-search input {
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    outline: none;
}

.multiselect-search input:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.125rem rgba(13, 110, 253, 0.25);
}

/* 选项列表 */
.multiselect-options {
    padding: 0;
    margin: 0;
    list-style: none;
}

.multiselect-option {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    color: #212529;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    border-bottom: 1px solid #f8f9fa;
}

.multiselect-option:last-child {
    border-bottom: none;
}

.multiselect-option:hover {
    background-color: #f8f9fa;
}

.multiselect-option.selected {
    background-color: #e7f3ff;
    color: #0d6efd;
}

.multiselect-option.disabled {
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.5;
}

.multiselect-option.disabled:hover {
    background-color: transparent;
}

/* 复选框样式 */
.multiselect-checkbox {
    margin-right: 0.5rem;
    width: 1rem;
    height: 1rem;
    position: relative;
    flex-shrink: 0;
}

.multiselect-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.multiselect-checkbox .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 1rem;
    width: 1rem;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: all 0.15s ease-in-out;
}

.multiselect-checkbox input:checked ~ .checkmark {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.multiselect-checkbox .checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 0.25rem;
    top: 0.125rem;
    width: 0.25rem;
    height: 0.5rem;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.multiselect-checkbox input:checked ~ .checkmark:after {
    display: block;
}

/* 单选按钮样式 */
.multiselect-radio {
    margin-right: 0.5rem;
    width: 1rem;
    height: 1rem;
    position: relative;
    flex-shrink: 0;
}

.multiselect-radio input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.multiselect-radio .radiomark {
    position: absolute;
    top: 0;
    left: 0;
    height: 1rem;
    width: 1rem;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 50%;
    transition: all 0.15s ease-in-out;
}

.multiselect-radio input:checked ~ .radiomark {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.multiselect-radio .radiomark:after {
    content: "";
    position: absolute;
    display: none;
    top: 50%;
    left: 50%;
    width: 0.25rem;
    height: 0.25rem;
    background-color: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.multiselect-radio input:checked ~ .radiomark:after {
    display: block;
}

/* 选项文本 */
.multiselect-option-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 全选选项特殊样式 */
.multiselect-option.select-all {
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    background-color: #f8f9fa;
}

.multiselect-option.select-all:hover {
    background-color: #e9ecef;
}

/* 无选项提示 */
.multiselect-no-options {
    padding: 1rem 0.75rem;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* 加载状态 */
.multiselect-loading {
    padding: 1rem 0.75rem;
    text-align: center;
    color: #6c757d;
}

.multiselect-loading::before {
    content: "";
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #e9ecef;
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: multiselect-spin 1s linear infinite;
    margin-right: 0.5rem;
}

@keyframes multiselect-spin {
    to {
        transform: rotate(360deg);
    }
}

/* 验证状态样式 */
.multiselect-container.is-invalid .multiselect-input {
    border-color: #dc3545;
    /*background-color: #fff5f5;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);*/
}

.multiselect-container.is-valid .multiselect-input {
    border-color: #28a745;
    background-color: #f8fff9;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* 验证状态下的图标 */
.multiselect-container.is-invalid .multiselect-input {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='%23212529' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e"), url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 3.6 0.4 5.4M5.8 10.2h.4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center, right 2.25rem center;
    background-size: 16px 12px, calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 2.25rem);
}

.multiselect-container.is-valid .multiselect-input {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='%23212529' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e"), url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16'%3e%3cpath fill='%2328a745' d='M12.736 3.97a.733.733 0 0 1 1.047 0c.286.289.29.756.01 1.05L7.88 12.01a.733.733 0 0 1-1.065.02L3.217 8.384a.757.757 0 0 1 0-1.06.733.733 0 0 1 1.047 0l3.052 3.093 5.4-6.425a.247.247 0 0 1 .02-.022Z'/%3e%3c/svg%3e");
    background-position: right 0.75rem center, right 2.25rem center;
    background-size: 16px 12px, 1em 1em;
    padding-right: calc(1.5em + 2.25rem);
}

/* 禁用状态 */
.multiselect-container.disabled .multiselect-input {
    background-color: #e9ecef;
    opacity: 1;
    cursor: not-allowed;
}

.multiselect-container.disabled .multiselect-tag {
    background-color: #6c757d;
}

.multiselect-container.disabled .multiselect-tag-remove {
    cursor: not-allowed;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .multiselect-input {
        font-size: 16px; /* 防止iOS缩放 */
        min-height: 44px; /* 更适合触摸 */
    }
    
    .multiselect-dropdown {
        max-height: 240px;
    }
    
    .multiselect-option {
        padding: 0.75rem;
        font-size: 16px;
    }
    
    .multiselect-tag {
        max-width: 150px;
        font-size: 0.8rem;
    }
    
    .multiselect-search input {
        font-size: 16px;
        padding: 0.5rem 0.75rem;
    }
}

/* 平板适配 */
@media (min-width: 769px) and (max-width: 1024px) {
    .multiselect-tag {
        max-width: 180px;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .multiselect-input {
        border-width: 2px;
    }
    
    .multiselect-tag {
        border: 1px solid #000;
    }
    
    .multiselect-option:hover {
        background-color: #000;
        color: #fff;
    }
}

/* 减少动画偏好支持 */
@media (prefers-reduced-motion: reduce) {
    .multiselect-input,
    .multiselect-option,
    .multiselect-tag-remove,
    .multiselect-checkbox .checkmark {
        transition: none;
    }
}

/* 聚焦状态可见性增强 */
.multiselect-input:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.multiselect-option:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

/* RTL支持 */
[dir="rtl"] .multiselect-input {
    background-position: left 0.75rem center;
    padding-left: 2.25rem;
    padding-right: 0.75rem;
}

[dir="rtl"] .multiselect-tag-remove {
    margin-left: 0;
    margin-right: 0.5rem;
}

[dir="rtl"] .multiselect-checkbox {
    margin-left: 0.5rem;
    margin-right: 0;
}
