﻿/* 全屏分类菜单样式 */
.category-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.98);
    z-index: 1001; /* z-index低于底部导航栏 */
    display: none;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    padding-bottom: 100px; /* 给底部导航栏留出空间 */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 修改：将标题区域改为浮动跟随 */
.category-header {
    position: sticky;
    top: 0;
    z-index: 1002;
    padding: 25px 20px 15px;
    background-color: #f8f9fa;
    color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid #eaeaea;
}

.category-header h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #9b59b6;
}

.category-header h2 i {
    font-size: 1.6rem;
}

.category-header p {
    font-size: 0.95rem;
    color: #666;
    text-align: center;
}

.close-category {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(155, 89, 182, 0.1);
    border: none;
    color: #9b59b6;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-category:hover {
    background: rgba(155, 89, 182, 0.2);
    transform: rotate(90deg);
}

.category-main {
    flex: 1;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    margin-top: 20px; /* 增加上边距，避免内容紧贴浮动头部 */
}

.category-section {
    margin-bottom: 30px;
}

.section-title1 {
    color: #9b59b6;
    font-size: 1.4rem;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #9b59b6;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title1 i {
    font-size: 1.2rem;
}

.category-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

/* 修改：调整按钮内边距，为展开按钮提供更多空间 */
.category-btn {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    color: #333;
    padding: 14px 8px 14px 8px; /* 修改：减少左右内边距，特别是左边距 */
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px; /* 修改：缩小整体间距 */
    font-size: 0.95rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    position: relative;
}

.category-btn:hover {
    background: #f8f9fa;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

/* 高亮分类按钮样式 - 新增 */
.category-btn.highlighted {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.15), #ffffff);
    border-color: #9b59b6;
    box-shadow: 0 0 0 2px #9b59b6, 0 5px 15px rgba(155, 89, 182, 0.3);
    transform: translateY(-2px);
    animation: pulse 1.5s infinite;
}

/* 子分类高亮样式 - 新增 */
.subcategory-btn.highlighted {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.15), #ffffff);
    border-color: #3498db;
    box-shadow: 0 0 0 2px #3498db, 0 5px 15px rgba(52, 152, 219, 0.3);
    transform: translateY(-2px);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 2px rgba(155, 89, 182, 0.7), 0 5px 15px rgba(155, 89, 182, 0.3);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(155, 89, 182, 0.9), 0 8px 20px rgba(155, 89, 182, 0.4);
    }
    100% {
        box-shadow: 0 0 0 2px rgba(155, 89, 182, 0.7), 0 5px 15px rgba(155, 89, 182, 0.3);
    }
}

/* 修改：缩小数字序号与图标/文字的距离 */
.category-btn .btn-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
    background: #9b59b6;
    color: white;
    margin: 0; /* 移除默认外边距 */
}

/* 级别0 - 紫色 */
.category-btn.level-0 {
    border-left: 4px solid #9b59b6;
}

.category-btn.level-0:hover {
    border-color: #9b59b6;
}

.category-btn.level-0 .btn-number {
    background: #9b59b6;
}

/* 级别1 - 蓝色 */
.category-btn.level-1 {
    border-left: 4px solid #3498db;
}

.category-btn.level-1:hover {
    border-color: #3498db;
}

.category-btn.level-1 .btn-number {
    background: #3498db;
}

/* 级别2 - 绿色 */
.category-btn.level-2 {
    border-left: 4px solid #2ecc71;
}

.category-btn.level-2:hover {
    border-color: #2ecc71;
}

.category-btn.level-2 .btn-number {
    background: #2ecc71;
}

/* 级别3 - 橙色 */
.category-btn.level-3 {
    border-left: 4px solid #e67e22;
}

.category-btn.level-3:hover {
    border-color: #e67e22;
}

.category-btn.level-3 .btn-number {
    background: #e67e22;
}

/* 级别4 - 红色 */
.category-btn.level-4 {
    border-left: 4px solid #e74c3c;
}

.category-btn.level-4:hover {
    border-color: #e74c3c;
}

.category-btn.level-4 .btn-number {
    background: #e74c3c;
}

/* 级别5 - 青色 */
.category-btn.level-5 {
    border-left: 4px solid #1abc9c;
}

.category-btn.level-5:hover {
    border-color: #1abc9c;
}

.category-btn.level-5 .btn-number {
    background: #1abc9c;
}

/* 级别6 - 粉色 */
.category-btn.level-6 {
    border-left: 4px solid #e84393;
}

.category-btn.level-6:hover {
    border-color: #e84393;
}

.category-btn.level-6 .btn-number {
    background: #e84393;
}

.category-btn.home-btn {
    background: #9b59b6;
    border-color: #9b59b6;
    color: white;
}

.category-btn.home-btn:hover {
    background: #8e44ad;
    border-color: #8e44ad;
}

/* 修改：多级分类样式调整 - 为展开按钮提供更多空间 */
.expandable-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-right: 12px; /* 修改：增加右侧内边距，让展开按钮更靠右 */
}

/* 修改：分类名称保持左对齐，调整内容区域间距 */
.expandable-btn .btn-content {
    display: flex;
    align-items: center;
    gap: 6px; /* 修改：缩小内容区域间距 */
    flex-grow: 1;
    text-align: left;
}

/* 修改：调整展开按钮样式，使其更靠右 */
.expandable-btn .expand-text {
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 12px; /* 修改：增加左侧外边距，让展开按钮更靠右 */
    white-space: nowrap;
}

.expandable-btn .expand-text:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

/* 级别0的展开文字颜色 - 紫色 */
.expandable-btn.level-0 .expand-text {
    color: #9b59b6;
    background: rgba(155, 89, 182, 0.1);
}

.expandable-btn.level-0 .expand-text:hover {
    background: rgba(155, 89, 182, 0.2);
}

/* 级别1的展开文字颜色 - 蓝色 */
.expandable-btn.level-1 .expand-text {
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.expandable-btn.level-1 .expand-text:hover {
    background: rgba(52, 152, 219, 0.2);
}

/* 级别2的展开文字颜色 - 绿色 */
.expandable-btn.level-2 .expand-text {
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
}

.expandable-btn.level-2 .expand-text:hover {
    background: rgba(46, 204, 113, 0.2);
}

/* 级别3的展开文字颜色 - 橙色 */
.expandable-btn.level-3 .expand-text {
    color: #e67e22;
    background: rgba(230, 126, 34, 0.1);
}

.expandable-btn.level-3 .expand-text:hover {
    background: rgba(230, 126, 34, 0.2);
}

.category-expandable-container {
    display: contents; /* 让容器不打断网格布局 */
}

.subcategory-container {
    margin-top: 10px;
    margin-left: 20px;
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    animation: slideDown 0.3s ease;
    grid-column: 1 / -1; /* 让子分类占据整行 */
}

@keyframes slideDown {
    from { 
        opacity: 0;
        transform: translateY(-10px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* 修改：子分类按钮也应用间距调整 */
.subcategory-btn {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    color: #555;
    padding: 10px 8px 10px 8px; /* 修改：减少左右内边距 */
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px; /* 修改：缩小子分类按钮内间距 */
    font-size: 0.9rem;
}

.subcategory-btn:hover {
    background: #f0f0f0;
}

.subcategory-btn .btn-number {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
    background: #9b59b6;
    color: white;
    margin: 0; /* 移除默认外边距 */
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 分类菜单响应式 */
    .category-buttons {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .category-header h2 {
        font-size: 1.5rem;
    }
    
    .category-header {
        padding: 20px 15px 10px;
    }
    
    .category-main {
        padding: 15px;
        margin-top: 15px; /* 移动端调整上边距 */
    }
    
    /* 修改：调整按钮在移动端的间距 */
    .category-btn {
        padding: 14px 6px 14px 6px; /* 移动端进一步减少内边距 */
        gap: 6px;
    }
    
    .expandable-btn .btn-content {
        gap: 5px; /* 移动端进一步缩小内容区域间距 */
    }
    
    .expandable-btn .expand-text {
        margin-left: 8px; /* 移动端调整展开按钮外边距 */
    }
    
    .subcategory-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        margin-left: 0; /* 取消子分类缩进 */
    }
}

@media (max-width: 600px) {
    /* 分类菜单响应式 */
    .category-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .category-btn {
        padding: 12px 5px 12px 5px; /* 超小屏幕进一步减少内边距 */
        font-size: 0.9rem;
    }
    
    .section-title1 {
        font-size: 1.2rem;
    }
    
    .subcategory-container {
        grid-template-columns: repeat(2, 1fr);
        margin-left: 0; /* 取消子分类缩进 */
    }
}

@media (max-width: 480px) {
    /* 分类菜单响应式 - 修改：从1fr改为repeat(2, 1fr) */
    .category-buttons {
        grid-template-columns: repeat(2, 1fr); /* 修改：每行显示两个分类按钮 */
    }
    
    .category-header h2 {
        font-size: 1.3rem;
    }
    
    .close-category {
        top: 15px;
        right: 15px;
        width: 35px;
        height: 35px;
    }
    
    /* 修改：调整超小屏幕按钮间距 */
    .category-btn {
        padding: 12px 4px 12px 4px; /* 超小屏幕最小化内边距 */
        gap: 4px;
    }
    
    .expandable-btn .btn-content {
        gap: 4px; /* 超小屏幕最小化内容区域间距 */
    }
    
    .expandable-btn .expand-text {
        margin-left: 6px; /* 超小屏幕调整展开按钮外边距 */
        font-size: 0.75rem; /* 缩小字体 */
        padding: 2px 6px; /* 缩小内边距 */
    }
    
    /* 修改：子分类容器也从1fr改为repeat(2, 1fr) */
    .subcategory-container {
        grid-template-columns: repeat(2, 1fr); /* 修改：每行显示两个子分类按钮 */
        margin-left: 0; /* 取消子分类缩进 */
    }
}

/* 添加在文件末尾 */

/* 正在打开状态样式 */
.category-btn.opening {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
    overflow: hidden;
}

.category-btn.opening::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.subcategory-btn.opening {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
    overflow: hidden;
}

.subcategory-btn.opening::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading-shimmer 1.5s infinite;
}

/* 禁用状态样式 */
.category-btn:disabled,
.subcategory-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 移动端适配 */
@media (max-width: 480px) {
    .category-btn.opening::after,
    .subcategory-btn.opening::after {
        animation: loading-shimmer 2s infinite;
    }
}