/* 全局样式 */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --text-color: #333;
    --text-light: #666;
    --border-color: #ddd;
    --bg-color: #f8f9fa;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.1);
    --card-shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color);
    background: var(--bg-color);
    line-height: 1.6;
}

/* 头部导航 */
.header {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--secondary-color);
}

.cart-icon {
    position: relative;
    font-size: 1.5rem;
    cursor: pointer;
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

/* 主容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* 搜索栏 */
.search-bar {
    margin-bottom: 2rem;
}

.search-input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.3s;
}

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

/* 分类按钮 */
.categories {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.category-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

.category-icon {
    font-size: 1.25rem;
}

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

/* 商品卡片 */
.product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-4px);
}

.product-link {
    text-decoration: none;
    color: inherit;
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

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

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

.badge-sale {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: bold;
}

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

.product-name {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-desc {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.product-price {
    margin-top: auto;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.price-current {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

.price-original {
    font-size: 1rem;
    color: var(--text-light);
    text-decoration: line-through;
}

.btn-add-cart {
    margin: 1rem;
    padding: 0.75rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

/* 商品详情页 */
.product-detail-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    margin-bottom: 3rem;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.product-gallery .main-image {
    width: 100%;
    border-radius: 8px;
}

.product-main-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.product-title {
    font-size: 2rem;
    font-weight: 700;
}

.product-subtitle {
    color: var(--text-light);
    font-size: 1.125rem;
}

.product-rating-sales {
    display: flex;
    gap: 2rem;
    font-size: 1rem;
}

.product-price-box {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
}

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

.price-large {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

.price-original-large {
    font-size: 1.25rem;
    color: var(--text-light);
    text-decoration: line-through;
    margin-left: 1rem;
}

.price-save {
    color: var(--success-color);
    font-weight: 600;
    margin-top: 0.5rem;
}

.product-specs ul {
    list-style: none;
    display: grid;
    gap: 0.5rem;
}

.product-specs li {
    padding: 0.5rem;
    background: var(--bg-color);
    border-radius: 4px;
}

.product-stock {
    font-size: 1rem;
}

.stock-number {
    color: var(--success-color);
    font-weight: 600;
}

.product-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.quantity-selector {
    display: flex;
    align-items: center;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.quantity-selector button {
    padding: 0.75rem 1.25rem;
    border: none;
    background: white;
    cursor: pointer;
    font-size: 1.25rem;
    transition: background 0.3s;
}

.quantity-selector button:hover {
    background: var(--bg-color);
}

.quantity-selector input {
    width: 60px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    padding: 0.75rem;
    font-size: 1rem;
}

.btn-add-cart-large {
    flex: 1;
    padding: 1rem 2rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-add-cart-large:hover {
    background: #2980b9;
}

.product-description {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.product-description h2 {
    margin-bottom: 1rem;
}

.product-description h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

/* 购物车页面 */
.cart-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.cart-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cart-item {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    display: grid;
    grid-template-columns: 100px 1fr auto auto auto;
    gap: 1.5rem;
    align-items: center;
}

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

.cart-item-info h3 {
    margin-bottom: 0.5rem;
}

.cart-item-price {
    color: var(--text-light);
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-item-quantity button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.cart-item-quantity button:hover {
    background: var(--secondary-color);
    color: white;
}

.cart-item-total {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-color);
}

.btn-remove {
    padding: 0.5rem 1rem;
    background: white;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-remove:hover {
    background: var(--accent-color);
    color: white;
}

.cart-summary {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    height: fit-content;
    position: sticky;
    top: 100px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.summary-total {
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.total-price {
    color: var(--accent-color);
    font-size: 1.5rem;
}

.btn-checkout {
    width: 100%;
    padding: 1rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

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

.empty-cart {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.btn-primary {
    display: inline-block;
    margin-top: 1rem;
    padding: 1rem 2rem;
    background: var(--secondary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: #2980b9;
}

/* 通知 */
.notification {
    position: fixed;
    top: 100px;
    right: 20px;
    background: var(--success-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s;
    z-index: 2000;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.no-products {
    text-align: center;
    padding: 4rem 2rem;
    font-size: 1.25rem;
    color: var(--text-light);
    grid-column: 1 / -1;
}

/* 页脚 */
.footer {
    background: var(--primary-color);
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
}

/* 响应式设计 */
@media (max-width: 968px) {
    .product-detail-container {
        grid-template-columns: 1fr;
    }
    
    .cart-container {
        grid-template-columns: 1fr;
    }
    
    .cart-summary {
        position: static;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }
    
    .cart-item {
        grid-template-columns: 80px 1fr;
        gap: 1rem;
    }
    
    .cart-item-quantity,
    .cart-item-total {
        grid-column: 1 / -1;
    }
    
    .btn-remove {
        grid-column: 1 / -1;
    }
    
    .nav-links {
        gap: 1rem;
    }
}
