/* 单位选择器样式 */
.unit-selector {
    position: relative;
    padding: 0;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.unit-selector:hover {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.1rem rgba(13, 110, 253, 0.1);
}

.unit-selector.open {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.unit-selector-container {
    position: relative;
    width: 100%;
}

.unit-selector-display {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    outline: none;
}

.selected-unit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.selected-text {
    flex: 1;
    display: flex;
    align-items: center;
    color: #495057;
    font-size: 0.95rem;
}

.unit-selector:not(.has-value) .selected-text {
    color: #6c757d;
}

.dropdown-icon {
    color: #6c757d;
    font-size: 0.875rem;
    transition: transform 0.2s ease;
    margin-left: 8px;
}

.unit-selector-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 400px;
    overflow: hidden;
}

.search-container {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.units-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px 0;
}

.category-group {
    margin-bottom: 4px;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    color: #495057;
    transition: background-color 0.2s ease;
    user-select: none;
}

.category-header:hover {
    background: #e9ecef;
}

.category-header i:first-child {
    margin-right: 8px;
    font-size: 1rem;
}

.category-title {
    flex: 1;
}

.expand-icon {
    font-size: 0.75rem;
    color: #6c757d;
    transition: transform 0.2s ease;
    margin-left: 8px;
}

.category-units {
    background: white;
}

.unit-item {
    display: flex;
    align-items: center;
    padding: 10px 24px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f8f9fa;
}

.unit-item:hover {
    background: #f8f9fa;
}

.unit-item:last-child {
    border-bottom: none;
}

.unit-item i {
    margin-right: 12px;
    font-size: 0.875rem;
}

.unit-name {
    flex: 1;
    font-size: 0.9rem;
    color: #495057;
}

.unit-code {
    font-size: 0.8rem;
    color: #6c757d;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* 滚动条样式 */
.units-list::-webkit-scrollbar {
    width: 6px;
}

.units-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.units-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.units-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 搜索框样式 */
.search-container .input-group-text {
    background: white;
    border-color: #dee2e6;
    color: #6c757d;
}

.search-container .form-control {
    border-color: #dee2e6;
    font-size: 0.875rem;
}

.search-container .form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.1rem rgba(13, 110, 253, 0.25);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .unit-selector-display {
        padding: 0.625rem 0.875rem;
        min-height: 44px;
    }
    
    .selected-text {
        font-size: 0.9rem;
    }
    
    .unit-selector-dropdown {
        max-height: 300px;
    }
    
    .units-list {
        max-height: 240px;
    }
    
    .category-header {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .unit-item {
        padding: 8px 16px;
    }
    
    .unit-name {
        font-size: 0.85rem;
    }
    
    .unit-code {
        font-size: 0.75rem;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.unit-selector-dropdown {
    animation: fadeIn 0.2s ease;
}

/* 聚焦状态 */
.unit-selector-display:focus {
    outline: none;
}

.unit-selector:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* 禁用状态 */
.unit-selector.disabled {
    background-color: #e9ecef;
    opacity: 0.65;
    cursor: not-allowed;
}

.unit-selector.disabled .unit-selector-display {
    cursor: not-allowed;
}

/* 错误状态 */
.unit-selector.is-invalid {
    border-color: #dc3545;
}

.unit-selector.is-invalid:focus-within {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* 成功状态 */
.unit-selector.is-valid {
    border-color: #198754;
}

.unit-selector.is-valid:focus-within {
    border-color: #198754;
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* 清空按钮样式 */
.clear-button {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.clear-button:hover {
    color: #495057;
    background: #f8f9fa;
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .unit-selector {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .unit-selector-display {
        color: #e2e8f0;
    }
    
    .selected-text {
        color: #e2e8f0;
    }
    
    .unit-selector:not(.has-value) .selected-text {
        color: #a0aec0;
    }
    
    .unit-selector-dropdown {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .search-container {
        background: #1a202c;
        border-color: #4a5568;
    }
    
    .category-header {
        background: #1a202c;
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .category-header:hover {
        background: #2d3748;
    }
    
    .unit-item {
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .unit-item:hover {
        background: #2d3748;
    }
    
    .unit-name {
        color: #e2e8f0;
    }
    
    .unit-code {
        background: #4a5568;
        color: #e2e8f0;
    }
} 