/* 通用设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f4f4f4;
    color: #333;
}

/* 页面头部 */
header {
    background-color: #333;
    color: white;
    padding: 1rem;
    text-align: center;
    font-size: 1.5rem;
}

nav ul {
    list-style-type: none;
    display: flex;
    justify-content: center;
    gap: 2rem;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: bold;
}

.breadcrumb {
    margin-bottom: 20px;
    padding: 10px 15px;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* 确保面包屑导航后面的div使用flex布局 */
.breadcrumb + div {
    display: flex;
    min-height: calc(100vh - 150px);
    gap: 20px;
}

/* 左侧分类栏 - 填满整个左侧高度 */
#sidebar {
    width: 250px;
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    float: left; /* 让侧边栏浮动到左侧 */
    display: flex;
    flex-direction: column;
}

#sidebar h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

#sidebar ul {
    list-style-type: none;
    flex-grow: 1; /* 让列表填满剩余垂直空间 */
}

#sidebar li {
    margin-bottom: 8px;
}

#sidebar a {
    display: block;
    padding: 8px 12px;
    color: #555;
    text-decoration: none;
    border-radius: 3px;
    transition: all 0.3s;
}

#sidebar a:hover {
    background-color: #f0f0f0;
    color: #e44d26;
}

/* 右侧内容区域 */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}


/* 产品列表 */
#product-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 2rem;
}

/* 每个产品的样式 */
.product {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product:hover {
    transform: translateY(-10px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.product-thumbnail {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.product-thumbnail:hover {
    transform: scale(1.1);
}

.product h3 {
    margin: 1rem 0;
    font-size: 1.2rem;
    color: #333;
}

.product p {
    font-size: 1rem;
    color: #666;
    margin-bottom: 1rem;
}

.qty-input {
    width: 50px;
    padding: 5px;
    margin-bottom: 10px;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.add-to-cart {
    background-color: #28a745;
    color: white;
    padding: 12px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.add-to-cart:hover {
    background-color: #218838;
}

/* 商品详情 */
.product-detail {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    margin: 20px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

        .product-images {
            width: 50%;
        }

        .main-image {
            width: 100%;
            border-radius: 10px;
        }

        .thumbnail-images {
            display: flex;
            gap: 10px;
            margin-top: 10px;
        }

        .thumb {
            width: 60px;
            height: 60px;
            cursor: pointer;
            border-radius: 5px;
            transition: transform 0.3s;
        }

        .thumb:hover {
            transform: scale(1.1);
        }

        .product-info {
            width: 45%;
            padding: 20px;
        }

        .product-info h1 {
            font-size: 2rem;
            margin-bottom: 10px;
        }

        .price {
            font-size: 1.5rem;
            color: #28a745;
            margin-bottom: 20px;
        }

        .description {
            font-size: 1rem;
            color: #555;
            margin-bottom: 20px;
        }

        input[type="number"] {
            width: 80px;
            padding: 5px;
            font-size: 1rem;
            border-radius: 5px;
            border: 1px solid #ccc;
            margin-bottom: 20px;
        }

/* 购物车图标 */
.cart-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 3rem;
    background-color: #007BFF;
    color: white;
    border-radius: 50%;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.3s;
}

.cart-icon:hover {
    transform: scale(1.1);
}

/* 购物车弹出框 */
.cart-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 3rem;
    background-color: #007BFF;
    color: white;
    border-radius: 50%;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.3s;
}

.cart-icon:hover {
    transform: scale(1.1);
}

/* 购物车弹出框 */
.cart {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background-color: #fff;
    border-radius: 8px;
    width: 250px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: none; /* 默认隐藏 */
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* 当购物车图标或购物车本身悬停时显示购物车 */
.cart-icon:hover + .cart,
.cart:hover {
    display: block;   /* 显示购物车 */
    opacity: 1;       /* 渐变显示 */
}

#cart-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

#cart-items li {
    margin: 10px 0;
    display: flex;
    justify-content: space-between;
}

#cart-total {
    margin-top: 10px;
    font-size: 1.1rem;
    font-weight: bold;
}

#checkout-btn {
    background-color: #28a745;
    color: white;
    padding: 12px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    width: 100%;
}

#checkout-btn:hover {
    background-color: #218838;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #product-list {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 480px) {
    #product-list {
        grid-template-columns: 1fr;
    }
}

/* ========= for Phase 2B/3 ========== */

/* 加载状态 */
.loading {
    text-align: center;
    padding: 50px;
    font-size: 1.2rem;
    color: #666;
}

/* 购物车计数徽章 */
.cart-count {
    position: absolute;
    top: 0;
    right: 0;
    background-color: #dc3545;
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 50%;
    transform: translate(25%, -25%);
}

/* 购物车项样式 */
.cart-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1.5fr 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.cart-item-name {
    font-weight: bold;
}

.cart-item-price, .cart-item-subtotal {
    color: #28a745;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 5px;
}

.cart-item-qty button {
    width: 25px;
    height: 25px;
    border: 1px solid #ddd;
    background-color: #f8f9fa;
    cursor: pointer;
    border-radius: 3px;
}

.cart-item-qty input {
    width: 40px;
    text-align: center;
    padding: 3px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.cart-item-remove {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.2rem;
    cursor: pointer;
}

.empty-cart {
    text-align: center;
    padding: 20px;
    color: #999;
}

/* 错误信息 */
.error {
    color: #dc3545;
    text-align: center;
    padding: 20px;
}

/* 产品网格 */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .cart-item {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}
