/* 全局重置与基础样式 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #2962ff;
    --primary-light: #e3f2fd;
    --accent-color: #ff3d00;
    --text-main: #1a1a1a;
    --text-secondary: #666666;
    --text-light: #999999;
    --bg-body: #f5f7fa;
    --bg-card: #ffffff;
    --border-color: #eaeaea;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 14px;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

ul, li {
    list-style: none;
}

input, button {
    outline: none;
    font-family: inherit;
}

/* 布局容器 */
.app-container {
    max-width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.main-content {
    flex: 1;
    padding-bottom: 30px;
}

.main-content.has-bottom-bar {
    padding-bottom: 80px;
}

/* 顶部导航 (Header) */
.app-header {
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    padding: 12px 0;
}

.app-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 18px;
    color: var(--primary-color);
    white-space: nowrap;
}

.logo i {
    font-size: 22px;
    margin-right: 8px;
}

.search-bar {
    flex: 1;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    color: var(--text-light);
    max-width: 400px;
}

.search-bar input {
    border: none;
    background: transparent;
    margin-left: 8px;
    width: 100%;
    font-size: 13px;
    color: var(--text-main);
}

/* 详情页 Header */
.page-header {
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    height: 50px;
    display: flex;
    align-items: center;
}

.page-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.page-header h1 {
    font-size: 16px;
    font-weight: 600;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}

.back-btn, .home-btn {
    font-size: 18px;
    color: var(--text-main);
    padding: 8px;
}

/* Banner 轮播 */
.banner-wrapper {
    margin-top: 16px;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    background: #fff;
}

.banner-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE 10+ */
    height: 160px; /* Mobile height */
}

.banner-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.banner-item {
    flex: 0 0 100%;
    scroll-snap-align: start;
    height: 100%;
}

.banner-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.banner-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.3s;
}

.dot.active {
    background: #fff;
    width: 12px;
    border-radius: 3px;
}

/* 公告栏 */
.notice-wrapper {
    margin-top: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.notice-icon {
    color: var(--accent-color);
    margin-right: 10px;
    font-size: 16px;
}

.notice-content {
    flex: 1;
    height: 20px;
    overflow: hidden;
    position: relative;
}

.notice-item {
    height: 20px;
    line-height: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notice-more {
    color: var(--text-light);
    font-size: 14px;
    margin-left: 8px;
}

/* 分类导航 */
.category-scroll-container {
    margin-top: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px 0;
    overflow: hidden;
}

.category-wrapper {
    display: flex;
    overflow-x: auto;
    gap: 20px;
    padding: 0 16px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE 10+ */
}

.category-wrapper::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.category-item {
    flex: 0 0 auto;
    width: 72px; /* Fixed width for consistent spacing */
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    scroll-snap-align: start;
}

.category-icon-box {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    color: var(--primary-color);
    font-size: 20px;
    transition: transform 0.2s;
    overflow: hidden; /* For uploaded images */
}

.category-icon-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.category-item:hover .category-icon-box {
    transform: translateY(-2px);
    background: var(--primary-color);
    color: #fff;
}

.category-name {
    font-size: 12px;
    color: var(--text-main);
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* 推荐标题 */
.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin: 24px 0 16px;
    display: flex;
    align-items: center;
}

.section-title i {
    color: var(--accent-color);
    margin-right: 8px;
}

/* 商品列表 */
.product-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.product-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid transparent;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.product-image {
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    position: relative;
    background: #f9f9f9;
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    padding: 12px;
}

.product-name {
    font-size: 14px;
    color: var(--text-main);
    line-height: 1.4;
    height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 8px;
}

.product-meta {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
}

.product-price {
    color: var(--accent-color);
    font-weight: 700;
    font-size: 16px;
}

.product-price small {
    font-size: 10px;
    margin-right: 2px;
}

.product-sales {
    font-size: 10px;
    color: var(--text-light);
}

/* 商品详情页 */
.product-detail-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-top: 16px;
    box-shadow: var(--shadow-sm);
    padding-bottom: 20px;
}

.product-detail-image {
    width: 100%;
    height: 300px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-detail-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-detail-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.product-price-row .price {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-color);
}

.stock-badge {
    background: #e6f7ff;
    color: #1890ff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
}

.stock-badge i {
    margin-right: 4px;
}

.product-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
    margin-bottom: 12px;
}

.product-sales-row {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

.product-sales-row span {
    display: flex;
    align-items: center;
}

.product-sales-row i {
    margin-right: 4px;
    color: var(--text-light);
}

.product-section {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.section-header {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-main);
}

.quantity-selector {
    display: flex;
    align-items: center;
    width: 120px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.quantity-btn {
    width: 36px;
    height: 36px;
    background: #f9f9f9;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.quantity-btn:active {
    background: #eee;
}

.quantity-input {
    flex: 1;
    height: 36px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    color: var(--text-main);
    font-weight: 600;
}

.product-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* 底部购买栏 */
.purchase-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    padding: 10px 16px;
    z-index: 100;
}

.purchase-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.total-price-display {
    display: flex;
    flex-direction: column;
}

.total-price-display .label {
    font-size: 12px;
    color: var(--text-light);
}

.total-price-display .amount {
    color: var(--accent-color);
    font-size: 20px;
    font-weight: 700;
}

.buy-btn {
    background: linear-gradient(135deg, #ff5722 0%, #ff3d00 100%);
    color: #fff;
    border: none;
    padding: 12px 32px;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 61, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.buy-btn:active {
    transform: scale(0.98);
}

/* 客服按钮 */
.customer-service-btn {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    color: var(--primary-color);
    font-size: 24px;
    z-index: 99;
    transition: transform 0.2s;
}

.customer-service-btn:hover {
    transform: scale(1.1);
}

/* 桌面端适配 */
@media (min-width: 768px) {
    .banner-container {
        height: 300px;
    }
    
    .category-scroll-container {
        padding: 30px 20px;
    }

    .category-wrapper {
        flex-wrap: wrap; /* Grid-like layout on desktop */
        justify-content: flex-start;
        overflow-x: visible;
        gap: 30px;
    }

    .category-item {
        width: 80px;
    }

    .product-list {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
    
    .product-image {
        padding-top: 80%; /* Slightly shorter aspect ratio on desktop */
    }
    
    .product-detail-card {
        display: grid;
        grid-template-columns: 450px 1fr;
        gap: 30px;
        padding: 30px;
        align-items: start;
    }
    
    .product-detail-image {
        height: 450px;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
    }
    
    .product-detail-header {
        border-bottom: none;
        padding-top: 0;
    }
    
    .purchase-bar {
        position: static;
        box-shadow: none;
        margin-top: 20px;
        padding: 0;
        background: transparent;
    }
    
    .purchase-container {
        justify-content: flex-start;
        gap: 20px;
    }
    
    .main-content.has-bottom-bar {
        padding-bottom: 30px;
    }
}
