/* ==========================================================================
   product-list.css - 产品列表页面样式
   ========================================================================== */

/* 主要内容区域 */
.product-list-content {
    padding: 60px 0;
    background-color: var(--background-primary);
}

/* 标题样式 */
.main-section-title {
    text-align: center;
    margin-bottom: 40px;
}

.main-section-title h2 {
    font-size: 36px;
    font-weight: 600;
    color: var(--text-dark);
    position: relative;
    display: inline-block;
}

/* 产品容器 - 左右布局 */
.product-container {
    display: flex;
    gap: 30px;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 15px;
}

/* 左侧分类导航 */
.product-categories {
    width: 260px;
    flex-shrink: 0;
}

.categories-header {
    background-color: var(--primary-blue); /* 使用网站主蓝色 */
    color: white;
    padding: 15px;
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.categories-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background-color: #f9f9f9;
    border: 1px solid #eee;
}

.category-item {
    border-bottom: 1px solid #eee;
    color: var(--text-dark);
    font-size: 15px;
    position: relative;
    background-color: #f9f9f9; /* 使用原来的浅灰色背景 */
}

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

.category-item:hover {
    background-color: #f0f0f0;
    color: var(--primary-blue);
}

.category-item.active {
    background-color: white;
    color: var(--primary-blue);
    font-weight: 600;
    border-left: 3px solid var(--primary-blue);
}

/* 右侧产品列表 */
.product-list {
    flex: 1;
}

/* 产品筛选器 */
.product-filter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.current-category {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-dark);
}

.filter-options {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sort-by {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    color: var(--text-primary);
}

/* 产品网格布局 */
.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    min-height: 400px;
    position: relative;
}

/* 产品卡片 - 与主页样式一致 */
.product-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    padding: 15px;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeIn 0.3s ease forwards;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.product-card h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--text-dark);
    line-height: 1.4;
    height: 45px;
    overflow: hidden;
}

.product-specs {
    list-style: none;
    margin: 10px 0;
    font-size: 14px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.5);
    padding: 10px;
    border-radius: 4px;
}

.product-card img {
    width: 100%;
    height: 220px;
    object-fit: contain;
    margin-bottom: 15px;
    background: transparent;
    border: none;
    padding: 10px;
    border-radius: 4px;
    transition: transform 0.3s ease;
}

.product-card:hover img {
    transform: scale(1.02);
}

.learn-more-btn {
    background: rgba(var(--primary-blue-rgb, 69, 140, 255), 0.9);
    color: white;
    text-align: center;
    padding: 8px 20px;
    text-decoration: none;
    margin-top: auto;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    font-size: 14px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.learn-more-btn:hover {
    background: rgba(var(--primary-blue-rgb, 69, 140, 255), 1);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(69, 140, 255, 0.2);
}

/* 加载状态 */
.loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(2px);
    z-index: 5;
    transition: opacity 0.2s ease;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(var(--primary-blue-rgb, 69, 140, 255), 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-blue);
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: -100% 0; }
    100% { background-position: 100% 0; }
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .product-container {
        flex-direction: column;
    }
    
    .product-categories {
        width: 100%;
        margin-bottom: 30px;
    }
}

@media (max-width: 576px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .product-filter {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}

/* 产品卡片淡入动画 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 产品网格布局添加位置定位 */
.products-grid {
    position: relative;
    min-height: 400px;
}

/* 分类项目基础样式 */
.category-item {
    border-bottom: 1px solid #eee;
    color: var(--text-dark);
    font-size: 15px;
    position: relative;
    background-color: #f9f9f9; /* 使用原来的浅灰色背景 */
}

/* 分类头部样式 */
.category-header {
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.category-header:hover {
    background-color: #f0f0f0; /* 浅灰色悬停效果 */
    color: var(--primary-blue); /* 使用网站主色调 */
}

/* 分类标题样式 */
.categories-header {
    background-color: var(--primary-blue); /* 使用网站主蓝色 */
    color: white;
    padding: 15px;
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 子分类列表 */
.subcategory-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
    background-color: white; /* 子分类使用白色背景 */
}

.category-item.active > .subcategory-list {
    max-height: 500px; /* 足够高以显示所有子分类 */
}

/* 子分类样式 */
.subcategory-list .category-item {
    padding-left: 0; /* 移除额外填充 */
    border-bottom: 1px solid #eee;
    background-color: white; /* 确保背景是白色 */
}

.subcategory-list .category-header {
    padding-left: 25px; /* 缩进以显示层级 */
}

/* 激活状态 - 使用主配色作为背景色块 */
.category-item.selected > .category-header {
    background-color: var(--primary-blue); /* 使用网站主色调作为背景 */
    color: white; /* 文字改为白色以提高可读性 */
    font-weight: 600;
    border-left: none; /* 移除左侧边框，因为现在整个背景都有颜色 */
}

/* 选中状态的悬停效果 */
.category-item.selected > .category-header:hover {
    background-color: var(--primary-dark-blue, #3a75d4); /* 稍深的蓝色 */
    color: white; /* 保持文字为白色 */
}

/* 选中分类的加号图标颜色 */
.category-item.selected > .category-header .toggle-icon {
    color: white; /* 图标改为白色 */
}

/* 切换图标样式 */
.toggle-icon {
    transition: transform 0.3s ease;
    color: #aaa; /* 灰色图标 */
}

.category-item.active > .category-header .toggle-icon {
    transform: rotate(45deg); /* 加号变成X */
    color: var(--primary-blue); /* 激活时使用主色调 */
}

.category-header:hover .toggle-icon {
    color: var(--primary-blue); /* 悬停时使用主色调 */
}

/* 没有子分类的项目仍然显示加号，但不可点击 */
.category-item:not(.has-children) .toggle-icon {
    opacity: 0.5; /* 降低不可点击图标的透明度 */
}

/* 处于激活状态的类别 */
.category-item.active > .category-header {
    color: var(--primary-blue);
}

/* 子分类的二级和三级层次样式 */
.subcategory-list .subcategory-list .category-header {
    padding-left: 35px; /* 三级分类更多缩进 */
}

.subcategory-list .subcategory-list .subcategory-list .category-header {
    padding-left: 45px; /* 四级分类更多缩进 */
}

/* 确保选中状态在所有层级都有正确的背景色 */
.subcategory-list .category-item.selected > .category-header {
    background-color: var(--primary-blue);
    color: white;
}

/* 子分类的选中状态悬停效果 */
.subcategory-list .category-item.selected > .category-header:hover {
    background-color: var(--primary-dark-blue, #3a75d4);
}

/* ==========================================================================
   Responsive Styles - Consolidated and Enhanced
   ========================================================================== */

/* For Laptops and Large Tablets (adjusting from your 1200px breakpoint) */
@media (max-width: 1199px) { /* Was 1200px */
    .product-container {
        /* padding: 0 15px; /* Already in base */
        gap: 25px; /* Reduce gap between categories and list */
    }
    .product-categories {
        width: 240px; /* Slightly reduce category width */
    }
    .products-grid {
        grid-template-columns: repeat(2, 1fr); /* Existing rule, good */
        gap: 20px; /* Reduce gap for 2 columns */
    }

    .main-section-title h2 {
        font-size: 32px;
    }
    .current-category {
        font-size: 22px;
    }
    .sort-by {
        padding: 7px 10px;
        font-size: 14px;
    }
    .categories-header {
        font-size: 17px;
        padding: 12px 15px;
    }
    .category-header { /* For individual category items */
        padding: 10px 12px;
        font-size: 14px;
    }
    .subcategory-list .category-header {
        padding-left: 20px; /* Adjust subcategory indent */
    }
     .subcategory-list .subcategory-list .category-header {
        padding-left: 30px;
    }

    /* Product Card adjustments for 2-column layout */
    .product-card h3 {
        font-size: 15px;
        height: 42px; /* Adjust if needed for 2 lines */
    }
    .product-card img {
        height: 200px;
    }
    .product-specs {
        font-size: 13px;
        padding: 8px;
    }
    .learn-more-btn {
        padding: 7px 18px;
        font-size: 13px;
    }
}

/* For Tablets (adjusting from your 992px breakpoint) */
@media (max-width: 991px) { /* Was 992px */
    .product-list-content {
        padding: 50px 0;
    }
    .product-container {
        flex-direction: column; /* Existing rule, good */
        padding: 0 10px; /* Reduce container padding */
        gap: 20px;
    }
    
    .product-categories {
        width: 100%;         /* Existing rule, good */
        margin-bottom: 25px; /* Adjusted from 30px */
    }

    /* Product Filter */
    .product-filter {
        margin-bottom: 20px;
        padding-bottom: 12px;
    }
    .current-category {
        font-size: 20px;
    }

    /* Product Grid still 2 columns from 1199px, or 1 if you prefer earlier */
    /* .products-grid {
        grid-template-columns: repeat(2, 1fr); /* Or 1fr if desired at this stage 
    } */

    .main-section-title {
        margin-bottom: 30px;
    }
    .main-section-title h2 {
        font-size: 30px;
    }

    /* Category list visual adjustments */
    .categories-list {
        border-left: none;
        border-right: none;
        border-radius: 4px; /* Add radius if it becomes a block */
    }
    .category-item.active {
        border-left-width: 0; /* Remove side border when stacked */
         /* Consider adding top/bottom border for active item if side is gone */
        border-top: 2px solid var(--primary-blue);
    }
    .category-item.selected > .category-header { /* Ensure selected full background */
        border-radius: 0;
    }


}

/* For Mobile Landscape and Small Tablets */
@media (max-width: 767px) { /* New breakpoint for finer control */
    .product-list-content {
        padding: 40px 0;
    }
    .main-section-title h2 {
        font-size: 26px;
    }

    .product-categories {
        margin-bottom: 20px;
    }
    .categories-header { /* Main "CATEGORIES" title */
        font-size: 16px;
        padding: 10px 12px;
        justify-content: center; /* Center header content */
    }
    .category-header { /* Individual category items */
        padding: 10px;
        font-size: 14px;
    }
    .toggle-icon {
        font-size: 1.1em; /* Make toggle icon slightly larger for tap */
    }

    .product-filter {
        align-items: center; /* Center items if not stacked yet */
    }
    .current-category {
        font-size: 18px;
    }
    .sort-by {
        padding: 6px 8px;
        font-size: 13px;
    }

    .products-grid {
        grid-template-columns: 1fr; /* Switch to 1 column */
        gap: 15px;
        min-height: 300px; /* Adjust min-height */
    }

    /* Product Card adjustments for 1-column layout */
    .product-card {
        padding: 12px;
    }
    .product-card h3 {
        font-size: 15px; /* Can be a bit larger in single column */
        height: auto;    /* Allow natural height */
        min-height: 40px;
    }
    .product-card img {
        height: 220px; /* Can allow more height */
    }
    .learn-more-btn {
        width: 100%; /* Full width button */
        text-align: center;
    }
}


/* For Mobile Portrait (adjusting from your 576px breakpoint) */
@media (max-width: 575px) { /* Was 576px */
    .product-list-content {
        padding: 30px 0;
    }
    .product-container {
        padding: 0 5px; /* Minimal padding */
    }
    .main-section-title {
        margin-bottom: 25px;
    }
    .main-section-title h2 {
        font-size: 22px;
    }

    .product-filter {
        flex-direction: column;     /* Existing rule, good */
        align-items: flex-start;    /* Existing rule, good */
        gap: 12px;                  /* Adjusted from 15px */
        padding-bottom: 10px;
        margin-bottom: 15px;
    }
    .current-category {
        font-size: 17px;
    }
    .filter-options {
        width: 100%; /* Make options take full width */
    }
    .sort-by {
        width: 100%; /* Make sort dropdown full width */
        text-align: center;
    }

    .categories-header { /* Main "CATEGORIES" title */
        padding: 10px;
    }
    .category-header { /* Individual category items */
        font-size: 13px;
    }
    .subcategory-list .category-header {
        padding-left: 15px;
    }
    .subcategory-list .subcategory-list .category-header {
        padding-left: 25px;
    }


    /* Product Card */
    .product-card img {
        height: 200px;
    }
    .product-card h3 {
        font-size: 14px;
    }
    .product-specs {
        font-size: 12px;
        padding: 6px;
    }
    .learn-more-btn {
        padding: 8px 15px; /* Ensure good tap size */
        font-size: 13px;
    }

    /* Spinner */
    .spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }
    .loading-spinner p {
        font-size: 14px;
    }
}
