/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #ff6b6b;
    --secondary-color: #4ecdc4;
    --dark-color: #2d3436;
    --light-color: #f7f7f7;
    --gray-color: #95a5a6;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: var(--light-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 顶部导航 */
.header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
}

.search-bar {
    display: flex;
    flex: 1;
    max-width: 500px;
    margin: 0 40px;
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #eee;
    border-radius: 25px;
    font-size: 14px;
    transition: var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-bar button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-color);
    color: var(--white);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.search-bar button:hover {
    background: #ff5252;
}

.nav-icons {
    display: flex;
    gap: 15px;
    align-items: center;
}

.cart-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--dark-color);
    cursor: pointer;
    transition: var(--transition);
}

.cart-btn:hover {
    color: var(--primary-color);
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--primary-color);
    color: var(--white);
    font-size: 12px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--dark-color);
    cursor: pointer;
}

/* 移动端菜单 */
.mobile-menu {
    display: none;
    padding: 20px 0;
    border-top: 1px solid #eee;
}

.mobile-menu.active {
    display: block;
}

.mobile-menu ul {
    list-style: none;
}

.mobile-menu li {
    padding: 10px 0;
}

.mobile-menu a {
    text-decoration: none;
    color: var(--dark-color);
    font-size: 16px;
    display: block;
}

/* 分类导航 */
.category-nav {
    background: var(--white);
    padding: 20px 0;
    border-bottom: 1px solid #eee;
}

.category-list {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.category-btn {
    padding: 10px 20px;
    background: var(--light-color);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

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

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

/* 轮播图 */
.banner {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    text-align: center;
    padding: 80px 20px;
    margin-bottom: 40px;
}

.banner h1 {
    font-size: 48px;
    margin-bottom: 10px;
}

.banner p {
    font-size: 20px;
    margin-bottom: 30px;
    opacity: 0.9;
}

.cta-btn {
    padding: 15px 40px;
    background: var(--white);
    color: var(--primary-color);
    border: none;
    border-radius: 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.cta-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

/* 主要内容 */
.main-content {
    padding: 40px 0;
}

.section-title {
    font-size: 32px;
    margin-bottom: 30px;
    text-align: center;
    color: var(--dark-color);
}

/* 商品网格 */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

.product-card {
    background: var(--white);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
}

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

.product-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    background: #f0f0f0;
}

.product-info {
    padding: 20px;
}

.product-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-desc {
    color: var(--gray-color);
    font-size: 14px;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.product-price {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.product-price::before {
    content: '¥';
    font-size: 16px;
}

.add-cart-btn {
    padding: 10px 20px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.add-cart-btn:hover {
    background: #ff5252;
}

/* 购物车侧边栏 */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    z-index: 2000;
    transition: var(--transition);
}

.cart-sidebar.active {
    right: 0;
}

.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.cart-sidebar.active .cart-overlay {
    opacity: 1;
    visibility: visible;
}

.cart-content {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 100%;
    height: 100vh;
    background: var(--white);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: var(--transition);
}

.cart-sidebar.active .cart-content {
    transform: translateX(0);
}

.cart-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header h3 {
    font-size: 24px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-color);
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--primary-color);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.empty-cart {
    text-align: center;
    color: var(--gray-color);
    padding: 40px 0;
}

.cart-item {
    display: flex;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 10px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.cart-item-price {
    color: var(--primary-color);
    font-weight: bold;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.quantity-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #eee;
    background: var(--white);
    border-radius: 5px;
    cursor: pointer;
    transition: var(--transition);
}

.quantity-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.quantity {
    min-width: 30px;
    text-align: center;
}

.remove-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: #ff5252;
    cursor: pointer;
}

.cart-footer {
    padding: 20px;
    border-top: 1px solid #eee;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 20px;
    margin-bottom: 20px;
}

.total-price {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 28px;
}

.checkout-btn {
    width: 100%;
    padding: 15px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.checkout-btn:hover {
    background: #ff5252;
}

/* 商品详情弹窗 */
.product-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    display: none;
}

.product-modal.active {
    display: block;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    border-radius: 20px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
}

.modal-content .close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
}

.product-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.detail-image {
    width: 100%;
    border-radius: 15px;
    object-fit: cover;
}

.detail-info h2 {
    font-size: 32px;
    margin-bottom: 20px;
}

.detail-category {
    display: inline-block;
    padding: 5px 15px;
    background: var(--light-color);
    border-radius: 15px;
    font-size: 14px;
    color: var(--gray-color);
    margin-bottom: 20px;
}

.detail-price {
    font-size: 36px;
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 20px;
}

.detail-price::before {
    content: '¥';
    font-size: 24px;
}

.detail-desc {
    color: var(--gray-color);
    line-height: 1.8;
    margin-bottom: 30px;
}

.detail-actions {
    display: flex;
    gap: 15px;
}

.detail-actions .add-cart-btn {
    flex: 1;
    padding: 15px;
    font-size: 16px;
}

/* 底部 */
.footer {
    background: var(--dark-color);
    color: var(--white);
    padding: 60px 0 20px;
    margin-top: 60px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-section h4 {
    font-size: 20px;
    margin-bottom: 20px;
}

.footer-section p {
    color: var(--gray-color);
    line-height: 1.8;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    padding: 8px 0;
}

.footer-section a {
    color: var(--gray-color);
    text-decoration: none;
    transition: var(--transition);
}

.footer-section a:hover {
    color: var(--primary-color);
}

.footer-section i {
    margin-right: 10px;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--gray-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .search-bar {
        display: none;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .category-list {
        gap: 10px;
    }
    
    .category-btn {
        padding: 8px 15px;
        font-size: 12px;
    }
    
    .banner h1 {
        font-size: 32px;
    }
    
    .banner p {
        font-size: 16px;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .product-image {
        height: 150px;
    }
    
    .product-info {
        padding: 15px;
    }
    
    .product-name {
        font-size: 14px;
    }
    
    .product-price {
        font-size: 18px;
    }
    
    .cart-sidebar {
        width: 100%;
    }
    
    .cart-content {
        width: 100%;
    }
    
    .product-detail {
        grid-template-columns: 1fr;
    }
    
    .detail-price {
        font-size: 28px;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .logo span {
        font-size: 18px;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        padding: 20px;
    }
}
