/* 分类选择器优化样式 - 精简分割线版 */
.category-optimizer-loading {
    text-align: center;
    padding: 12px;
    color: var(--theme-color);
    background: var(--theme-bg);
    border-radius: 6px;
    margin: 8px 0;
    border: 1px solid var(--theme-border);
    font-size: 13px;
}

.category-optimizer-error {
    text-align: center;
    padding: 10px;
    color: var(--theme-red);
    background: var(--theme-red-light);
    border-radius: 6px;
    margin: 8px 0;
    border: 1px solid var(--theme-red-border);
    font-size: 13px;
}

/* 主容器 */
.category-selector-container {
    display: flex;
    min-height: 350px;
    max-height: 400px;
    background: var(--theme-bg);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px var(--theme-shadow);
}

/* 字母导航 - 宽度改为35px */
.category-letter-nav {
    width: 35px;
    background: var(--theme-bg-gray);
    border-right: 1px solid var(--theme-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    padding: 4px 0;
}

.category-letter-nav::-webkit-scrollbar {
    width: 2px;
}

.category-letter-nav::-webkit-scrollbar-thumb {
    background: var(--theme-color-light);
    border-radius: 1px;
}

.letter-item {
    padding: 6px 2px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--theme-color-light);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    margin: 1px 3px;
    min-height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.letter-item:hover {
    color: var(--theme-color);
    background: var(--theme-hover);
}

.letter-item.active {
    color: var(--theme-blue);
    background: var(--theme-blue-light);
    font-weight: 700;
}

.letter-item.active::after {
    content: '';
    position: absolute;
    right: -1px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 14px;
    background: var(--theme-blue);
    border-radius: 1px;
}

/* 分类内容区域 */
.category-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.category-search-box {
    padding: 8px 12px;
    border-bottom: 1px solid var(--theme-border);
    background: var(--theme-bg);
    flex-shrink: 0;
}

.category-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--theme-border);
    border-radius: 4px;
    background: var(--theme-bg);
    color: var(--theme-color);
    font-size: 13px;
    transition: all 0.2s ease;
}

.category-search-input:focus {
    outline: none;
    border-color: var(--theme-blue);
    box-shadow: 0 0 0 2px var(--theme-blue-light);
}

.category-search-input::placeholder {
    color: var(--theme-color-light);
    font-size: 13px;
}

/* 分类列表 */
.category-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.category-list-container::-webkit-scrollbar {
    width: 4px;
}

.category-list-container::-webkit-scrollbar-track {
    background: var(--theme-bg-gray);
}

.category-list-container::-webkit-scrollbar-thumb {
    background: var(--theme-color-light);
    border-radius: 2px;
}

.category-list-container::-webkit-scrollbar-thumb:hover {
    background: var(--theme-color);
}

/* 字母分组 */
.letter-section {
    margin-bottom: 6px;
}

.letter-header {
    padding: 4px 8px;
    background: var(--theme-bg-gray);
    color: var(--theme-color);
    font-weight: 600;
    font-size: 12px;
    border-radius: 4px;
    margin-bottom: 2px;
    border-left: 2px solid var(--theme-blue);
    display: flex;
    align-items: center;
}

.letter-header::before {
    content: '';
    width: 3px;
    height: 3px;
    background: var(--theme-blue);
    border-radius: 50%;
    margin-right: 6px;
}

/* 分类项 - 更紧凑，使用分割线替代外框 */
.category-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    margin: 1px 0;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    position: relative;
    background: transparent;
    border-bottom: 1px solid var(--theme-border-light);
    min-height: 32px;
}

/* 最后一个分类项不需要底部分割线 */
.category-item:last-child {
    border-bottom: none;
}

.category-item:hover {
    background: var(--theme-hover);
    transform: none;
    box-shadow: none;
}

.category-item.selected {
    background: var(--theme-blue-light);
}

.category-item.selected .category-name {
    color: var(--theme-blue);
    font-weight: 600;
}

.category-content {
    display: flex;
    align-items: center;
    flex: 1;
    min-height: 24px;
}

/* Logo样式 - 只有第二级分类显示，移除外框 */
.category-logo-container {
    margin-right: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-logo {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
    border: none; /* 移除边框 */
    background: var(--theme-bg-gray);
    transition: all 0.2s ease;
}

.category-item:hover .category-logo {
    transform: scale(1.05);
}

.category-logo-placeholder {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--theme-bg-gray) 0%, var(--theme-hover) 100%);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-color-light);
    border: none; /* 移除边框 */
    font-size: 12px;
    transition: all 0.2s ease;
}

.category-item:hover .category-logo-placeholder {
    background: linear-gradient(135deg, var(--theme-blue-light) 0%, var(--theme-hover) 100%);
    color: var(--theme-blue);
}

/* 分类名称 */
.category-name {
    flex: 1;
    font-size: 13px;
    color: var(--theme-color);
    font-weight: 600;
    line-height: 1.3;
    transition: color 0.2s ease;
}

/* 计数 */
.category-count {
    background: var(--theme-bg-gray);
    color: var(--theme-color-light);
    padding: 2px 5px;
    border-radius: 8px;
    font-size: 10px;
    margin-left: 6px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
    transition: all 0.2s ease;
}

.category-item:hover .category-count {
    background: var(--theme-blue-light);
    color: var(--theme-blue);
}

/* 单选按钮 */
.category-item input[type="radio"] {
    margin-right: 8px;
    flex-shrink: 0;
}

.category-item input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border: 2px solid var(--theme-border);
    border-radius: 50%;
    outline: none;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    background: var(--theme-bg);
}

.category-item input[type="radio"]:checked {
    border-color: var(--theme-blue);
    background-color: var(--theme-blue);
}

.category-item input[type="radio"]:checked::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.category-item input[type="radio"]:hover {
    border-color: var(--theme-blue);
}

/* 不可选择的分类项 */
.category-item:not(.selectable) {
    cursor: default;
    opacity: 0.8;
}

.category-item:not(.selectable):hover {
    background: transparent;
    transform: none;
    box-shadow: none;
}

.category-item:not(.selectable) .category-name {
    color: var(--theme-color-light);
    font-weight: 500;
}

/* 最后一级可选择的分类项 */
.category-item.selectable {
    cursor: pointer;
    opacity: 1;
}

.category-item.selectable:hover {
    background: var(--theme-hover);
}

/* 层级缩进 - 从第三级开始缩进，第三四级不显示logo */
.category-level-2 {
    margin-left: 0;
}

.category-level-3 {
    margin-left: 16px;
    padding-left: 8px;
    border-bottom: none;
    position: relative;
}

/* 第三级分类的竖线 - 高度减小一半 */
.category-level-3::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%; /* 从25%开始，到75%结束，高度为50% */
    bottom: 25%;
    width: 2px;
    background: var(--theme-border-light);
    border-radius: 1px;
}

/* 第三级和第四级分类不显示logo容器 */
.category-level-3 .category-logo-container,
.category-level-4 .category-logo-container {
    display: none;
}

.category-level-3 .category-name {
    font-size: 12px;
    font-weight: 500;
    margin-left: 0;
}

.category-level-4 {
    margin-left: 24px;
    padding-left: 8px;
    border-bottom: none;
    position: relative;
}

/* 第四级分类的竖线 - 高度减小一半 */
.category-level-4::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%; /* 从25%开始，到75%结束，高度为50% */
    bottom: 25%;
    width: 2px;
    background: var(--theme-border-light);
    border-radius: 1px;
}

.category-level-4 .category-name {
    font-size: 12px;
    font-weight: 400;
    margin-left: 0;
}

/* 子分类容器 */
.category-children {
    margin-top: 2px;
    margin-left: 0;
}

/* 展开/收起按钮 */
.category-expand-btn {
    margin-left: 6px;
    padding: 2px;
    cursor: pointer;
    color: var(--theme-color-light);
    transition: all 0.2s ease;
    background: none;
    border: none;
    border-radius: 3px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.category-expand-btn:hover {
    color: var(--theme-blue);
    background: var(--theme-hover);
}

.category-expand-btn i {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.category-expand-btn.expanded i {
    transform: rotate(90deg);
}

/* 无结果状态 */
.category-no-results {
    text-align: center;
    padding: 20px 15px;
    color: var(--theme-color-light);
    font-size: 13px;
}

.category-no-results::before {
    content: '🔍';
    font-size: 18px;
    margin-bottom: 6px;
    display: block;
    color: var(--theme-border);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .category-selector-container {
        flex-direction: column;
        max-height: 320px;
    }
    
    .category-letter-nav {
        width: 100%;
        height: 36px;
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--theme-border);
        padding: 0;
    }
    
    .letter-item {
        flex: 1;
        min-width: 32px;
        padding: 8px 2px;
        margin: 2px 1px;
        min-height: 24px;
    }
    
    .letter-item.active::after {
        right: 50%;
        bottom: -1px;
        top: auto;
        left: 50%;
        transform: translateX(-50%);
        width: 14px;
        height: 2px;
    }
    
    .category-level-3 {
        margin-left: 12px;
    }
    
    .category-level-3::before {
        top: 25%;
        bottom: 25%;
    }
    
    .category-level-4 {
        margin-left: 20px;
    }
    
    .category-level-4::before {
        top: 25%;
        bottom: 25%;
    }
    
    .category-item {
        padding: 5px 6px;
        min-height: 28px;
    }
    
    .category-logo {
        width: 20px;
        height: 20px;
    }
    
    .category-logo-placeholder {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
}

/* 子比主题适配 */
.theme-dark .category-selector-container,
body[data-theme="dark"] .category-selector-container,
.night-mode .category-selector-container {
    --theme-bg: #1a1d21;
    --theme-bg-gray: #25292e;
    --theme-color: #e4e6eb;
    --theme-color-light: #8a8f98;
    --theme-border: #3a3f45;
    --theme-border-light: #2d3238;
    --theme-hover: #25292e;
    --theme-shadow: rgba(0, 0, 0, 0.3);
    --theme-blue: #3a86ff;
    --theme-blue-light: rgba(58, 134, 255, 0.15);
    --theme-red: #ff4757;
    --theme-red-light: rgba(255, 71, 87, 0.1);
    --theme-red-border: rgba(255, 71, 87, 0.3);
}

.theme-light .category-selector-container,
body[data-theme="light"] .category-selector-container,
.day-mode .category-selector-container {
    --theme-bg: #ffffff;
    --theme-bg-gray: #f8f9fa;
    --theme-color: #2c3e50;
    --theme-color-light: #6c757d;
    --theme-border: #e9ecef;
    --theme-border-light: #dee2e6;
    --theme-hover: #f8f9fa;
    --theme-shadow: rgba(0, 0, 0, 0.1);
    --theme-blue: #007bff;
    --theme-blue-light: rgba(0, 123, 255, 0.1);
    --theme-red: #dc3545;
    --theme-red-light: rgba(220, 53, 69, 0.1);
    --theme-red-border: rgba(220, 53, 69, 0.3);
}

/* 默认主题变量（如果没有主题类时使用） */
.category-selector-container {
    --theme-bg: #ffffff;
    --theme-bg-gray: #f8f9fa;
    --theme-color: #2c3e50;
    --theme-color-light: #6c757d;
    --theme-border: #e9ecef;
    --theme-border-light: #dee2e6;
    --theme-hover: #f8f9fa;
    --theme-shadow: rgba(0, 0, 0, 0.1);
    --theme-blue: #007bff;
    --theme-blue-light: rgba(0, 123, 255, 0.1);
    --theme-red: #dc3545;
    --theme-red-light: rgba(220, 53, 69, 0.1);
    --theme-red-border: rgba(220, 53, 69, 0.3);
}