/**
 * 现代化工具分类筛选器样式
 * 提供美观、响应式的UI设计
 * @version 3.0
 */

/* 分类筛选器主容器 */
.category-filter-wrapper {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.1);
    position: relative;
    overflow: hidden;
}

.category-filter-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="1" fill="%23ffffff" opacity="0.05"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>') repeat;
    pointer-events: none;
}

/* 筛选器头部 */
.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.filter-header h3 {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-header h3 i {
    font-size: 1rem;
    opacity: 0.9;
}

/* 筛选控制区域 */
.filter-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* 多选模式按钮 */
.btn-multi-select {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-multi-select:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.btn-multi-select.active {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border-color: white;
}

.btn-multi-select.active:hover {
    background: white;
    transform: translateY(-2px);
}

/* 清除筛选按钮 */
.btn-clear-filter {
    background: #ff6b6b;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-clear-filter:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.4);
    background: linear-gradient(135deg, #ff5252, #e53935);
}

/* 统计信息 */
.category-stats {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
}

.stats-text {
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
}

.stats-text strong {
    font-weight: 700;
    color: #ffd700;
}

/* 分类网格 - 两行紧凑布局 */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    grid-template-rows: repeat(2, 40px);
    gap: 6px;
    position: relative;
    z-index: 1;
    max-height: 86px;
    overflow: hidden;
}

/* 分类项 */
.category-item {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.1s ease;
    border: 1px solid transparent;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px);
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 40px;
    white-space: nowrap;
}

.category-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--category-color, #667eea);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.category-item:hover::before {
    transform: scaleX(1);
}

.category-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    border-color: var(--category-color, #667eea);
}

.category-item.active {
    background: var(--category-color, #667eea);
    color: white;
    border-color: var(--category-color, #667eea);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.category-item.active::before {
    transform: scaleX(1);
    background: rgba(255, 255, 255, 0.3);
}

.category-item.active .category-icon {
    color: white;
}

.category-item.active .category-name {
    color: white;
}

.category-item.active .category-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* 全部工具分类项特殊样式 */
.category-item.all-category {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.category-item.all-category:not(.active) {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
}

.category-item.all-category.active {
    background: linear-gradient(135deg, #5a67d8, #6b46c1);
}

/* 分类图标 */
.category-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--category-color, #667eea);
    border-radius: 6px;
    margin-right: 6px;
    color: white;
    font-size: 0.9rem;
    transition: all 0.1s ease;
    flex-shrink: 0;
}

.category-item:not(.active) .category-icon {
    background: rgba(102, 126, 234, 0.1);
    color: var(--category-color, #667eea);
}

.category-item.all-category:not(.active) .category-icon {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

/* 分类信息 */
.category-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    min-width: 0;
    flex: 1;
    text-align: left;
}

/* 分类名称 */
.category-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
    transition: color 0.1s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* 分类计数 */
.category-count {
    display: inline-block;
    background: rgba(102, 126, 234, 0.1);
    color: var(--category-color, #667eea);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    transition: all 0.1s ease;
    flex-shrink: 0;
    min-width: 16px;
    text-align: center;
}

/* 动画效果 */
.category-item.animate-in {
    animation: slideInUp 0.2s ease forwards;
}

@keyframes slideInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 错误信息样式 */
.error-message {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.error-message i {
    font-size: 1.2rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .category-filter-wrapper {
        padding: 20px;
        margin-bottom: 24px;
    }
    
    .filter-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .filter-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .category-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
    
    .category-item {
        padding: 16px;
    }
    
    .category-icon {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
        margin-bottom: 12px;
    }
    
    .category-name {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .category-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    
    .filter-header h3 {
        font-size: 1.3rem;
    }
    
    .btn-multi-select,
    .btn-clear-filter {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .category-item:not(.active) {
        background: rgba(255, 255, 255, 0.1);
        color: white;
    }
    
    .category-item:not(.active) .category-name {
        color: white;
    }
    
    .category-item:not(.active) .category-icon {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .category-filter-wrapper {
        border: 2px solid #000;
    }
    
    .category-item {
        border: 2px solid #000;
    }
    
    .category-item.active {
        border: 3px solid #000;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .category-item,
    .btn-multi-select,
    .btn-clear-filter {
        transition: none;
    }
    
    .category-item.animate-in {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* 打印样式 */
@media print {
    .category-filter-wrapper {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #ccc;
    }
    
    .filter-header h3,
    .stats-text {
        color: black !important;
    }
    
    .category-item {
        background: white !important;
        border: 1px solid #ccc !important;
        color: black !important;
    }
    
    .btn-multi-select,
    .btn-clear-filter {
        display: none;
    }
}