/* 商品列表页样式 */

/* 页头 */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.page-title h1 {
    font-size: 22px;
    font-weight: 700;
    color: #333;
    position: relative;
    padding-left: 14px;
}

.page-title h1::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 20px;
    border-radius: 3px;
    background: linear-gradient(180deg, #ff6b9d, #ff8a80);
}

.product-count {
    font-size: 13px;
    color: #999;
}

.search-form {
    display: flex;
    flex: 1;
    max-width: 460px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 24px;
    padding: 4px 4px 4px 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    transition: border-color 0.25s, box-shadow 0.25s;
}

.search-form:focus-within {
    border-color: #ffb3cc;
    box-shadow: 0 4px 16px rgba(255,107,157,0.15);
}

.search-form input {
    flex: 1;
    min-width: 0;
    padding: 8px 14px;
    border: none;
    background: transparent;
    font-size: 14px;
    outline: none;
}

.search-form button {
    padding: 8px 22px;
    background: linear-gradient(135deg, #ff6b9d, #ff8a80);
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.25s;
}

.search-form button:hover {
    opacity: 0.9;
}

/* 布局 */
.content-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* 侧栏分类 */
.sidebar {
    width: 180px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 14px;
    padding: 18px 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    position: sticky;
    top: 72px;
}

.sidebar h3 {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin-bottom: 14px;
    padding-left: 10px;
    position: relative;
}

.sidebar h3::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 15px;
    border-radius: 2px;
    background: #ff6b9d;
}

.category-menu {
    list-style: none;
}

.category-menu li {
    margin-bottom: 4px;
}

.category-menu li a {
    display: block;
    padding: 9px 14px;
    color: #666;
    font-size: 14px;
    border-radius: 10px;
    transition: all 0.25s;
}

.category-menu li a:hover {
    background: #fff0f5;
    color: #ff6b9d;
}

.category-menu li a.active {
    background: linear-gradient(135deg, #ff6b9d, #ff8a80);
    color: #fff;
    font-weight: 500;
    box-shadow: 0 4px 10px rgba(255,107,157,0.3);
}

/* 商品区 */
.product-area {
    flex: 1;
    min-width: 0;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
}

.product-card {
    display: block;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    transition: transform 0.28s ease, box-shadow 0.28s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 26px rgba(255,107,157,0.16);
}

.product-image {
    width: 100%;
    height: 170px;
    overflow: hidden;
    background: #fafafa;
    position: relative;
}

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

.pinch-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: linear-gradient(135deg, #ff6b9d, #ff8a80);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    z-index: 1;
}

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

.product-info {
    padding: 12px;
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-desc {
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-price {
    color: #ff4d4f;
    font-size: 16px;
    font-weight: 700;
}

.product-sales {
    font-size: 11px;
    color: #999;
    background: #f6f6f6;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.pagination a {
    min-width: 36px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 10px;
    color: #666;
    font-size: 13px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.25s;
}

.pagination a:hover {
    color: #ff6b9d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255,107,157,0.15);
}

.pagination a.active {
    background: linear-gradient(135deg, #ff6b9d, #ff8a80);
    color: #fff;
    box-shadow: 0 4px 12px rgba(255,107,157,0.3);
}

.pagination .prev, .pagination .next {
    padding: 8px 16px;
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    .page-header {
        padding: 16px 0 14px;
        gap: 12px;
    }
    
    .page-title h1 {
        font-size: 18px;
    }
    
    .search-form {
        max-width: 100%;
    }
    
    .content-wrapper {
        flex-direction: column;
        gap: 14px;
    }
    
    /* 移动端把分类改为横向滑动的胶囊条（原先整块隐藏且无入口） */
    .sidebar {
        width: 100%;
        position: static;
        padding: 12px;
    }
    
    .sidebar h3 {
        display: none;
    }
    
    .category-menu {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    
    .category-menu::-webkit-scrollbar {
        display: none;
    }
    
    .category-menu li {
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .category-menu li a {
        padding: 7px 16px;
        background: #f5f5f5;
        white-space: nowrap;
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .product-image {
        height: 150px;
    }
    
    .product-info {
        padding: 10px;
    }
    
    .product-name {
        font-size: 13px;
    }
    
    .product-desc {
        display: none;
    }
    
    .product-price {
        font-size: 15px;
    }
    
    .pagination a {
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media screen and (max-width: 375px) {
    .product-grid {
        gap: 8px;
    }

    .product-image {
        height: 120px;
    }
}

/* ===== 映糖式布局 ===== */
.cat-main { padding: 0 0 40px; }
.cat-container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.cat-header {
    padding: 16px 0 0;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 0;
}

.cat-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
}
.cat-title-row h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: #222;
}
.cat-title-row .product-count {
    font-size: 13px;
    color: #999;
}

.cat-header .search-form {
    margin-bottom: 12px;
}

/* 顶部一级分类横向 Tab */
.top-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0 0 4px;
}
.top-tabs::-webkit-scrollbar { display: none; }

.top-tab {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    border-radius: 8px;
    white-space: nowrap;
    transition: all 0.2s;
    background: transparent;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 60px;
}
.top-tab-icon {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
}
.top-tab-label {
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}
.top-tab:hover { color: #ff6b9d; }
.top-tab.active {
    color: #ffffff;
}
.top-tab.active .top-tab-label {
    font-weight: 600;
    background: #ff6b9d;
    color: #ffffff;
    padding: 2px 10px;
    border-radius: 12px;
}

/* 左右两栏布局 */
.cat-body {
    display: flex;
    gap: 20px;
    margin-top: 16px;
}

/* 左侧二级分类竖列 - 映糖风格 */
.sub-sidebar {
    width: 120px;
    flex-shrink: 0;
    background: #f5f5f5;
    border-radius: 0;
    padding: 0;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid #eee;
}

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

.sub-item {
    padding: 16px 10px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    text-align: center;
    position: relative;
    line-height: 1.4;
    white-space: normal;
    word-break: break-all;
}
.sub-item:hover {
    color: #ff6b9d;
    background: #fafafa;
}
.sub-item.active {
    color: #ff6b9d;
    font-weight: 600;
    background: #fff;
    border-left-color: #ff6b9d;
    box-shadow: 1px 0 4px rgba(0,0,0,0.04);
    margin-right: -1px;
}

/* 右侧商品区 */
.cat-body .product-area {
    flex: 1;
    min-width: 0;
}

/* ===== 一级分类大标题（拼多多式，保留兼容） ===== */
.top-section {
    margin-bottom: 40px;
    scroll-margin-top: 72px;
}
.top-title {
    font-size: 18px;
    font-weight: 700;
    color: #222;
    margin: 0 0 18px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #fff0f5, #ffffff);
    border-radius: 12px;
    border-left: 5px solid #ff6b9d;
    position: sticky;
    top: 72px;
    z-index: 5;
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.top-title .group-count {
    font-size: 13px;
    color: #999;
    font-weight: 400;
}

/* 二级分组标题 */
.sub-group-title {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin: 18px 0 12px;
    padding-left: 12px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sub-group-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: linear-gradient(180deg, #ff6b9d, #ff8a80);
}
.sub-group-title .group-count {
    font-size: 12px;
    color: #bbb;
    font-weight: 400;
}

/* 搜索加载更多 */
.load-more-wrap {
    padding: 20px 0 40px;
    text-align: center;
}
.load-more-btn {
    padding: 10px 40px;
    background: #fff;
    border: 1.5px solid #ff6b9d;
    color: #ff6b9d;
    font-size: 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}
.load-more-btn:hover {
    background: #ff6b9d;
    color: #fff;
}
.no-more {
    padding: 20px 0 40px;
    text-align: center;
    color: #bbb;
    font-size: 13px;
}

/* 搜索激活时收起左侧二级菜单（避免和搜索结果模式视觉冲突） */
.product-area.search-mode .top-section {
    display: none;
}
.loading-state {
    padding: 80px 0;
    text-align: center;
    color: #999;
}
.loading-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto 12px;
    border: 3px solid #ffe0ec;
    border-top-color: #ff6b9d;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.search-clear {
    background: #f0f0f0;
    color: #666;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin-left: 6px;
}
.search-clear:hover {
    background: #e0e0e0;
}
/* 商品卡片图片懒加载占位 */
.product-image img {
    background: #f5f5f5;
}

/* ===== 二级分类手风琴 ===== */
.category-menu .cat-item {
    position: relative;
}
.cat-link {
    display: block;
    padding: 9px 28px 9px 14px;
    color: #666;
    font-size: 14px;
    border-radius: 10px;
    transition: all 0.25s;
}
.cat-link:hover,
.cat-item.active > .cat-link {
    color: #ff6b9d;
    background: #fff0f5;
}
.cat-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #aaa;
    font-size: 12px;
    padding: 4px;
    user-select: none;
    transition: transform 0.25s;
}
.cat-item.expanded > .cat-toggle {
    transform: translateY(-50%) rotate(180deg);
}
.sub-cate-menu {
    list-style: none;
    margin: 4px 0 4px 8px;
    padding: 0;
    border-left: 2px solid #ffe0ec;
}
.sub-cate-menu li a {
    display: block;
    padding: 7px 14px;
    color: #999;
    font-size: 13px;
    border-radius: 8px;
    margin-left: 6px;
    transition: all 0.2s;
}
.sub-cate-menu li a:hover {
    background: #fff0f5;
    color: #ff6b9d;
}
.sub-cate-menu li a.active {
    color: #ff6b9d;
    font-weight: 600;
    background: #fff0f5;
}

/* ===== 分组商品区 ===== */
.product-group {
    margin-bottom: 32px;
    scroll-margin-top: 80px;
}
.group-title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 14px;
    padding-left: 12px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}
.group-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: linear-gradient(180deg, #ff6b9d, #ff8a80);
}
.group-count {
    font-size: 12px;
    color: #999;
    font-weight: 400;
}

/* 移动端响应式优化（映糖风格） */
@media screen and (max-width: 768px) {
    .cat-container {
        padding: 0 12px;
    }
    .cat-header {
        padding: 12px 0 0;
    }
    .cat-title-row h1 {
        font-size: 17px;
    }
    .cat-title-row .product-count {
        font-size: 12px;
    }
    .search-form {
        max-width: 100%;
    }
    .search-form input {
        font-size: 13px;
        padding: 6px 10px;
    }
    .search-form button {
        padding: 6px 16px;
        font-size: 13px;
    }

    /* 顶部 Tab 移动端样式 */
    .top-tabs {
        gap: 4px;
        padding: 4px 0 2px;
    }
    .top-tab {
        padding: 6px 10px;
        gap: 3px;
        min-width: 56px;
    }
    .top-tab-icon {
        width: 40px;
        height: 40px;
        border-radius: 8px;
    }
    .top-tab-label {
        font-size: 11px;
    }

    /* 左右布局：左侧窄条 + 右侧商品 */
    .cat-body {
        gap: 0;
        margin-top: 12px;
    }
    .sub-sidebar {
        width: 72px;
        background: #f5f5f5;
        border-radius: 0;
        padding: 0;
        top: 80px;
        max-height: calc(100vh - 100px);
        border-right: 1px solid #eee;
    }
    .cat-body .product-area {
        padding: 0 8px;
    }
    .sub-item {
        padding: 10px 6px;
        font-size: 12px;
        text-align: center;
        border-left: 3px solid transparent;
        line-height: 1.3;
        word-break: break-all;
        white-space: normal;
    }
    .sub-item.active {
        border-left-color: #ff6b9d;
        background: #fff;
    }

    /* 商品区：两列更大卡片 */
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .product-image {
        height: 200px;
    }
    .product-info {
        padding: 10px 12px 12px;
    }
    .product-name {
        font-size: 13px;
        margin-bottom: 3px;
    }
    .product-desc {
        display: none;
    }
    .product-price {
        font-size: 15px;
    }
    .product-sales {
        font-size: 11px;
        padding: 1px 6px;
    }

    /* 分组商品区 */
    .product-group {
        margin-bottom: 20px;
    }
    .group-title {
        font-size: 14px;
        padding: 10px 10px 8px;
    }
    .group-title::before {
        width: 3px;
        height: 14px;
    }
    .group-count {
        font-size: 11px;
    }
}

@media screen and (max-width: 480px) {
    /* 小屏手机：优化紧凑布局 */
    .cat-container {
        padding: 0 8px;
    }
    .cat-title-row h1 {
        font-size: 16px;
    }

    /* Tab 样式更紧凑 */
    .top-tab {
        padding: 4px 8px;
        gap: 2px;
        min-width: 48px;
    }
    .top-tab-icon {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }
    .top-tab-label {
        font-size: 10px;
        white-space: nowrap;
    }

    /* 侧边栏更窄 */
    .sub-sidebar {
        width: 60px;
    }
    .sub-item {
        padding: 8px 4px;
        font-size: 11px;
    }

    /* 商品卡片更大 */
    .product-grid {
        gap: 8px;
    }
    .product-image {
        height: 180px;
    }
    .product-info {
        padding: 8px 10px 10px;
    }
    .product-name {
        font-size: 12px;
    }
    .product-price {
        font-size: 14px;
    }
}
