/* 首页样式 - 微信小程序风格 */

/* CSS变量定义 */
:root {
    --primary-color: #07c160;
    --primary-hover: #06ad56;
    --secondary-color: #576b95;
    --success-color: #07c160;
    --warning-color: #ffc300;
    --danger-color: #fa5151;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --bg-primary: #ffffff;
    --bg-secondary: #ededed;
    --bg-page: #f6f6f6;
    --border-color: #e5e5e5;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--bg-page);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

/* 通知横幅样式 */
.notification-container {
    background: #fff;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
    position: relative;
    height: 36px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    box-shadow: var(--shadow-sm);
}

.notification-label {
    color: var(--danger-color);
    font-weight: 600;
    margin-right: 8px;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.notification-label::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    background: var(--danger-color);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E");
    background-size: 10px;
    background-position: center;
    background-repeat: no-repeat;
}

.notification-scroll-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
}

.notification-content {
    display: flex;
    align-items: center;
    white-space: nowrap;
    animation: scroll-left 30s linear infinite;
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: max-content;
}

.notification-text {
    color: var(--text-secondary);
    font-size: 12px;
    letter-spacing: 0.2px;
    line-height: 1.4;
}

@keyframes scroll-left {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* 分类标签样式 - 小程序宫格风格 */
.category-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    overflow-x: auto;
    padding: 20px 16px;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    scrollbar-width: none;
    flex-wrap: nowrap;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tabs .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 8px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
    min-width: 80px;
    flex-shrink: 0;
    position: relative;
}

.category-tabs .tab .tab-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    overflow: hidden;
    background: var(--bg-secondary);
    transition: all var(--transition-fast);
}

.category-tabs .tab .tab-icon-img {
    width: 70%;
    height: 70%;
    object-fit: contain;
}

.category-tabs .tab .tab-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.2;
    transition: color var(--transition-fast);
}

.category-tabs .tab.active .tab-icon {
    background: rgba(7, 193, 96, 0.1);
}

.category-tabs .tab.active .tab-text {
    color: var(--primary-color);
    font-weight: 600;
}

.category-tabs .tab.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* 商品分类区域 */
.product-category {
    margin-bottom: 16px;
}

/* 商品分类标题 */
.category-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    padding: 0 12px;
    color: var(--text-primary);
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 6px;
}

.category-title::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* 商品网格布局 */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
    padding: 0 12px;
}

/* 商品卡片样式 */
.product-card {
    background-color: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform var(--transition-fast);
    display: flex;
    flex-direction: column;
}

.product-card:active {
    transform: scale(0.98);
}

/* 商品内容区域 */
.product-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* 商品封面图样式 */
.product-image {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background-color: var(--bg-secondary);
    position: relative;
}

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

.product-card:active .product-cover {
    transform: scale(1.03);
}

/* 商品信息 */
.product-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    flex: 1;
}

.product-region {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.4;
    word-break: break-all;
}

.product-description {
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--danger-color);
    margin: 4px 0;
}

.product-price::before {
    content: "\A5";
    font-size: 12px;
    margin-right: 1px;
}

/* 商品标签 */
.product-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.tag {
    background-color: rgba(7, 193, 96, 0.08);
    color: var(--primary-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    line-height: 1.4;
}

/* 商品库存 */
.product-stock {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* 购买按钮 */
.add-to-cart {
    width: 100%;
    padding: 10px 0;
    background: var(--primary-color);
    color: #fff;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast);
    margin-top: auto;
}

.add-to-cart:active {
    background: var(--primary-hover);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0 10px;
    }

    .product-info {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .product-region {
        font-size: 13px;
    }

    .product-price {
        font-size: 15px;
    }

    .add-to-cart {
        padding: 8px 0;
        font-size: 12px;
    }

    .category-tabs .tab .tab-icon {
        width: 40px;
        height: 40px;
    }
}

@media (min-width: 769px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}
