
.category-sidebar {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
    position: sticky;
    top: 100px;
}

.category-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.8rem;
    border-bottom: 3px solid var(--accent-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-item {
    margin-bottom: 0.5rem;
}

.category-link {
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    color: #555;
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.category-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--accent-color);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.category-link:hover {
    background: rgba(0, 86, 179, 0.08);
    color: var(--primary-color);
    padding-left: 1.5rem;
}

.category-link:hover::before {
    transform: translateX(0);
}

.category-link.active {
    background: linear-gradient(135deg, rgba(0, 86, 179, 0.1), rgba(255, 107, 53, 0.1));
    color: var(--primary-color);
    font-weight: 600;
}

.category-link.active::before {
    transform: translateX(0);
}

.category-icon {
    margin-right: 0.8rem;
    font-size: 1.1rem;
    color: var(--accent-color);
    transition: all 0.3s ease;
}

.category-link:hover .category-icon {
    transform: scale(1.2);
}

.category-count {
    margin-left: auto;
    background: var(--accent-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.subcategory-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 2rem;
    display: none;
}

.subcategory-list.show {
    display: block;
}

.subcategory-item {
    margin-bottom: 0.3rem;
}

.subcategory-link {
    display: block;
    padding: 0.5rem 1rem;
    color: #666;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    position: relative;
}

.subcategory-link:hover {
    background: rgba(0, 86, 179, 0.05);
    color: var(--primary-color);
    padding-left: 1.5rem;
}

.subcategory-link::before {
    content: '•';
    position: absolute;
    left: 0.5rem;
    color: var(--accent-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.subcategory-link:hover::before {
    opacity: 1;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.product-item {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.product-image {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: #f8f9fa;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-item:hover .product-image img {
    transform: scale(1.1);
}

.product-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--accent-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.product-info {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-category-tag {
    display: inline-block;
    background: rgba(0, 86, 179, 0.1);
    color: var(--primary-color);
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.product-title {
    /* --- 1. 字体与行高设定 --- */
    /* 建议明确写上行高，确保计算准确 */
    font-size: 1.1rem;
    line-height: 1.4;
    margin-bottom: 10px; /* 标题下方的间距 */
    font-weight: bold; /* 保持标题加粗 */
    /* --- 2. 多行省略逻辑 (最多2行) --- */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2; /* 限制显示2行 */
    overflow: hidden;
    text-overflow: ellipsis;
    /* --- 3. 强制占位逻辑 (最少2行) --- */
    /* 计算公式：行高(1.4) * 行数(2) = 2.8em */
    /* 无论标题是1行还是2行，都会固定占用2行的高度 */
    min-height: 2.8em;
    /* --- 4. 可选：防止长单词/型号炸开布局 --- */
    /* 比如很长的型号 "KW-PLC-S71200-001-EXTRA-LONG" */
    word-break: break-word;
}

.product-description {
    /* --- 1. 字体与行高设定 (基础) --- */
    font-size: 0.9rem; /* 假设字体大小，如果是默认值可不写 */
    line-height: 1.5; /* 设定行高为字体的1.5倍 */
    color: #666;
    margin-bottom: 0.9rem;
    /* --- 2. 多行省略逻辑 (最多3行) --- */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3; /* 限制第3行省略 */
    overflow: hidden;

    /* --- 3. 强制占位逻辑 (最少3行) --- */
    /* 计算公式：行高(1.5) * 行数(3) = 4.5em */
    /* 这样即使文字只有1行，也会留出3行的高度，保证下方按钮对齐 */
    min-height: 4.5em;
}

.product-features {
    /* --- 1. 基础样式重置 --- */
    list-style: none; /* 去掉默认圆点 */
    padding-left: 0;
    margin-bottom: 15px; /* 列表底部的间距 */

    /* --- 2. 核心高度计算 (固定4行) --- */
    /*
       计算公式：
       单行总高 = 行高(1.6em) + 下边距(0.4em) = 2.0em
       总容器高度 = 单行总高(2.0em) * 4行 = 8.0em
    */
    height: 5em; /* 强制高度 */
    overflow: hidden; /* 超过4个特性时隐藏 */
}

.product-features li {
    /* --- 3. 单行布局控制 --- */
    font-size: 14px; /* 字体大小 */
    line-height: 1.6; /* 行高 (对应上方计算) */
    margin-bottom: 0.4em; /* 下边距 (对应上方计算) */
    color: #555; /* 字体颜色 */

    /* --- 4. 防止单行文字过长换行 (破坏布局) --- */
    white-space: nowrap; /* 强制不换行 */
    overflow: hidden; /* 超出隐藏 */
    text-overflow: ellipsis; /* 显示省略号 */

    /* --- 5. 添加自定义图标 (可选) --- */
    position: relative;
    padding-left: 1.2rem; /* 给图标留位置 */
}

/* 添加一个小对勾图标 */
.product-features li::before {
    content: "\F26A"; /* Bootstrap Icon: bi-check-circle */
    font-family: "bootstrap-icons";
    position: absolute;
    left: 0;
    top: 1px; /* 微调图标垂直位置 */
    color: var(--accent-color);
    font-size: 0.9rem;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
}

.product-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.product-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-product {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn-primary-product {
    background: var(--primary-color);
    color: white;
}

.btn-primary-product:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

.btn-outline-product {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline-product:hover {
    background: var(--primary-color);
    color: white;
}

.pagination {
    justify-content: center;
    margin-top: 3rem;
}

.page-link {
    color: var(--primary-color);
    border: 1px solid #e9ecef;
    margin: 0 0.2rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.page-link:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-item.active .page-link {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.5rem;
    }

    .category-sidebar {
        position: static;
        margin-bottom: 2rem;
    }
}
