﻿/* --- 基础样式重置 --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    padding-bottom: 70px;
}

/* --- 1. 顶部 Banner 轮播样式 (Bootstrap 接管布局，这里只保留背景) --- */
.carousel {
    height: 300px; /* 限制轮播图整体高度 */
}

.carousel-inner {
    height: 100%;
}

.banner-item {
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
/* 第 1 张轮播图的背景 */
.carousel-item:nth-child(1) .banner-item {
    background-color: #4facfe;
    background-image: url(../img/banner1.jpg);
}

/* 第 2 张轮播图的背景 */
.carousel-item:nth-child(2) .banner-item {
    background-color: #43e97b;
    background-image: url(../img/banner2.jpg);
}

/* 第 3 张轮播图的背景 */
.carousel-item:nth-child(3) .banner-item {
    background-color: #fa709a;
    background-image: url(../img/banner3.jpg);
}
/* 第 4 张轮播图的背景 */
.carousel-item:nth-child(4) .banner-item {
    background-color: #4facfe;
    background-image: url(../img/banner4.jpg);
}

/* 第 5 张轮播图的背景 */
.carousel-item:nth-child(5) .banner-item {
    background-color: #43e97b;
    background-image: url(../img/banner5.jpg);
}

/* 第 6 张轮播图的背景 */
.carousel-item:nth-child(6) .banner-item {
    background-color: #fa709a;
    background-image: url(../img/banner6.jpg);
}

/* --- 主体布局：侧边栏 + 内容区 --- */
.main-container {
    display: flex;
    height: calc(100vh - 200px);
    overflow-y: auto; /* 开启内部垂直滚动（内容超出时才出现滚动条） */
    /* overflow-y: scroll;  如果你希望滚动条一直显示，可以用 scroll */
    /* 移动端顺滑滚动优化（让滑动带有惯性，体验更像原生APP） */
    -webkit-overflow-scrolling: touch;
}

/* 2. 侧边栏分类 */
.sidebar {
    width: 90px;
    background: #f8f8f8;
    overflow-y: auto;
    border-right: 1px solid #eee;
}

.category-item {
    padding: 15px 10px;
    text-align: center;
    font-size: 13px;
    color: #666;
    border-left: 3px solid transparent;
    cursor: pointer;
}

    .category-item.active {
        background: #fff;
        color: #007BFF;
        font-weight: bold;
        border-left-color: #007BFF;
    }

/* 3. 右侧商品卡片展示区 */
.product-area {
    flex: 1; /* 自动占据父容器剩余的所有空间 */    
    min-height: 0; /* 【关键防坑点】必须加上！防止 flex 子项高度被内容撑开导致滚动失效 */
    padding: 10px;
    background: #fff;
}

.product-card {
    display: flex;
    background: #fff;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #f0f0f0;
}

.product-img {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    background: #eee;
    object-fit: cover;
    margin-right: 12px;
}

.product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-name {
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 4px;
}

.product-spec {
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
}

.product-desc {
    font-size: 11px;
    color: #aaa;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.product-price {
    color: #ff4d4f;
    font-weight: bold;
    font-size: 16px;
}

    .product-price::before {
        content: '¥';
        font-size: 12px;
        margin-right: 1px;
    }

/* 数量加减按钮组 */
.quantity-control {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
}

.quantity-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: #f5f5f5;
    font-size: 16px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-input {
    width: 30px;
    height: 24px;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 12px;
    outline: none;
}
/* 加入购物车按钮 */
.add-cart-btn {
    background: #007BFF;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin-left: 8px;
    cursor: pointer;
}
.quantity-btn, .add-cart-btn {
    position: relative;
    z-index: 999;
    pointer-events: auto; /* 确保允许点击 */
}
#productList {
    position: relative;    
    z-index: 100 !important;
    overflow: visible !important; /* 防止内容被截断 */
}

/* 强行让商品卡片和按钮可以被点击，且位于最上层 */
.product-card, .quantity-btn, .add-cart-btn, .quantity-control {
    position: relative !important;
    z-index: 9999 !important;
    pointer-events: auto !important; /* 恢复鼠标点击 */
}
.bottom-placeholder {
    height: 50px;
    width: 100%;
}
/* --- 4. 底部购物车徽标 --- */
.bottom-cart {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    height: 50px;
    background: #333;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 100;
}

.cart-left {
    display: flex;
    align-items: center;
    color: white;
}

.cart-icon {
    font-size: 24px;
    margin-right: 10px;
    position: relative;
}
/* 购物车数量徽标 */
.cart-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background: #ff4d4f;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid #333;
}

.cart-total {
    font-size: 18px;
    font-weight: bold;
}

    .cart-total::before {
        content: '¥';
        font-size: 12px;
    }

.checkout-btn {
    background: #007BFF;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 15px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}
