/**
 * ===================================
 * AI工具分类展示页面 - 优化版
 * 增强用户体验和功能
 * ===================================
 */

/* ---------- 基础样式 ---------- */
.categories-page {
    background: #f8f9fa;
    min-height: 100vh;
}

/* ---------- 面包屑导航 ---------- */
.cat-breadcrumb {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.75rem 0;
}

.cat-breadcrumb-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.cat-breadcrumb-list {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.875rem;
}

.cat-breadcrumb-list li {
    display: flex;
    align-items: center;
}

.cat-breadcrumb-list li:not(:last-child)::after {
    content: '›';
    margin-left: 0.5rem;
    color: #cbd5e1;
}

.cat-breadcrumb-list a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s ease;
}

.cat-breadcrumb-list a:hover {
    color: #667eea;
}

.cat-breadcrumb-list li[aria-current="page"] {
    color: #1e293b;
    font-weight: 600;
}

/* ---------- Hero区域 ---------- */
.cat-hero {
    background: #f8f9fa;
    padding: 2rem 0 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.cat-hero-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* 搜索框 */
.cat-search-wrapper {
    position: relative;
    width: 100%;
}

.cat-search-input {
    width: 100%;
    padding: 0.875rem 3.5rem 0.875rem 1.25rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.9375rem;
    color: #2d3748;
    outline: none;
    transition: all 0.2s ease;
}

.cat-search-input::placeholder {
    color: #94a3b8;
}

.cat-search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.cat-search-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: #667eea;
    border: none;
    border-radius: 6px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cat-search-btn:hover {
    background: #5568d3;
}

/* ---------- 快速导航 ---------- */
.cat-quick-nav {
    background: #ffffff;
    padding: 1rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.cat-quick-nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    position: relative;
}

.cat-quick-nav-items {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.cat-quick-nav-item {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.cat-quick-nav-item:hover {
    background: #667eea;
    border-color: #667eea;
    color: #ffffff;
}

/* ---------- 分类列表区域 ---------- */
.cat-list-section {
    padding: 2rem 0 4rem;
}

.cat-list-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* 工具栏 */
.cat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding: 1rem 0;
}

.cat-results-count {
    font-size: 0.9375rem;
    color: #64748b;
    font-weight: 500;
}

.cat-sort-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cat-sort-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.cat-sort-btn svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

/* 分类组包装器 */
.cat-groups-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* 分类组 */
.cat-group {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.75rem;
    transition: all 0.3s ease;
    scroll-margin-top: 100px;
    margin-bottom: 1.5rem;
}

.cat-group:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    border-color: #cbd5e1;
}

/* 折叠状态 */
.cat-group.is-collapsed .cat-group-content {
    max-height: 0 !important;
    overflow: hidden;
}

.cat-group.is-collapsed .cat-group-toggle svg {
    transform: rotate(-90deg);
}

/* 分类组头部 */
.cat-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.cat-group-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.cat-group-icon {
    font-size: 2rem;
    line-height: 1;
}

.cat-group-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
    letter-spacing: -0.01em;
}

.cat-group-count {
    padding: 0.25rem 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
}

.cat-group-toggle {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.5rem;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.cat-group-toggle:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.cat-group-toggle svg {
    transition: transform 0.3s ease;
}

/* 分类组内容 */
.cat-group-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: none;
    overflow: visible;
    transition: max-height 0.3s ease;
}

/* 分类项目网格 */
.cat-items {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

/* 分类项目 */
.cat-item {
    position: relative;
}

.cat-item-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    color: #64748b;
}

.cat-item-link:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateX(4px);
}

/* 主分类项目 */
.cat-item-main .cat-item-link {
    background: #667eea;
    border-color: #667eea;
    color: #ffffff;
    font-weight: 600;
}

.cat-item-main .cat-item-link:hover {
    background: #5568d3;
    border-color: #5568d3;
}

.cat-item-main .cat-item-count {
    color: rgba(255, 255, 255, 0.9);
}

.cat-item-name {
    font-size: 0.9375rem;
    font-weight: 500;
    flex: 1;
}

.cat-item-count {
    font-size: 0.875rem;
    color: #94a3b8;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* 分类描述 */
.cat-group-desc {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.9375rem;
    color: #64748b;
    line-height: 1.6;
    margin: 0;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.cat-desc-icon {
    flex-shrink: 0;
    margin-top: 0.125rem;
    color: #667eea;
}

/* ---------- 空状态 ---------- */
.cat-empty {
    text-align: center;
    padding: 4rem 2rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
}

.cat-empty svg {
    color: #cbd5e1;
    margin-bottom: 1.5rem;
}

.cat-empty p {
    font-size: 1.125rem;
    color: #64748b;
    margin: 0;
}

/* 无搜索结果 */
.cat-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
}

.cat-no-results svg {
    color: #cbd5e1;
    margin-bottom: 1.5rem;
}

.cat-no-results h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #334155;
    margin: 0 0 0.5rem;
}

.cat-no-results p {
    font-size: 1rem;
    color: #64748b;
    margin: 0 0 1.5rem;
}

.cat-reset-btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cat-reset-btn:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ---------- 返回顶部按钮 ---------- */
.cat-back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
}

.cat-back-to-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5);
}

/* ---------- 响应式设计 ---------- */

@media (max-width: 1024px) {
    .cat-items {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.625rem;
    }
    
    .cat-quick-nav-items {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 transparent;
    }
    
    .cat-quick-nav-items::-webkit-scrollbar {
        height: 4px;
    }
    
    .cat-quick-nav-items::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .cat-quick-nav-items::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 2px;
    }
}

@media (max-width: 768px) {
    .cat-breadcrumb {
        padding: 0.5rem 0;
    }
    
    .cat-breadcrumb-container {
        padding: 0 1rem;
    }
    
    .cat-hero {
        padding: 1.5rem 0 1.25rem;
    }
    
    .cat-hero-container {
        padding: 0 1rem;
    }
    
    .cat-search-input {
        padding: 0.75rem 3rem 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .cat-search-btn {
        width: 32px;
        height: 32px;
    }
    
    .cat-quick-nav {
        padding: 0.75rem 0;
    }
    
    .cat-quick-nav-container {
        padding: 0 1rem;
    }
    
    .cat-quick-nav-items {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .cat-quick-nav-item {
        padding: 0.4375rem 0.875rem;
        font-size: 0.8125rem;
    }
    
    .cat-list-section {
        padding: 1.5rem 0 3rem;
    }
    
    .cat-list-container {
        padding: 0 1rem;
    }
    
    .cat-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.875rem 0;
    }
    
    .cat-sort-btn {
        width: 100%;
        justify-content: center;
    }
    
    .cat-group {
        padding: 1.5rem;
    }
    
    .cat-group-header {
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }
    
    .cat-group-header-left {
        gap: 0.75rem;
    }
    
    .cat-group-icon {
        font-size: 1.75rem;
    }
    
    .cat-group-title {
        font-size: 1.25rem;
    }
    
    .cat-group-count {
        padding: 0.1875rem 0.625rem;
        font-size: 0.8125rem;
    }
    
    .cat-items {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .cat-item-link {
        padding: 0.625rem 0.875rem;
    }
    
    .cat-item-name {
        font-size: 0.875rem;
    }
    
    .cat-item-count {
        font-size: 0.8125rem;
    }
    
    .cat-back-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 480px) {
    .cat-hero {
        padding: 1.25rem 0 1rem;
    }
    
    .cat-search-input {
        padding: 0.625rem 2.75rem 0.625rem 0.875rem;
    }
    
    .cat-search-btn {
        width: 30px;
        height: 30px;
    }
    
    .cat-group {
        padding: 1.25rem;
        border-radius: 10px;
    }
    
    .cat-group-icon {
        font-size: 1.5rem;
    }
    
    .cat-group-title {
        font-size: 1.125rem;
    }
    
    .cat-back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }
}
