* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    z-index: 100;
}

.categories-tab {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    padding-bottom: 5px;
    scrollbar-width: none; /* Firefox */
    position: relative;
    /* 添加渐变遮罩 */
    mask-image: linear-gradient(to right, transparent, black 20px, black 95%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 20px, black 95%, transparent);
    cursor: grab;
    user-select: none; /* 防止文字被选中 */
}

.categories-tab::-webkit-scrollbar {
    display: none;
}

.category-item {
    padding: 8px 20px;
    white-space: nowrap;
    color: #666;
    text-decoration: none;
    border-radius: 10px;
    margin-right: 12px;
    font-size: 15px;
    transition: all 0.3s;
    flex-shrink: 0; /* 防止项目被压缩 */
    cursor: pointer;
}

.category-item:first-child {
    margin-left: 5px;
}

.category-item:last-child {
    margin-right: 5px;
}

.category-item.active {
    background: #007bff;
    color: #fff;
    font-weight: 500;
}

.category-item:hover {
    background: #f0f7ff;
    color: #007bff;
}

.search-container {
    position: relative;
    margin-bottom: 15px;
}

.search-category {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 14px;
    background: #f5f7fa;
    padding: 8px 25px 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s;
}

/* 添加下拉箭头 */
.search-category::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-right: 2px solid #666;
    border-bottom: 2px solid #666;
    transform: translateY(-70%) rotate(45deg);
    transition: transform 0.3s;
}

.search-category.active::after {
    transform: translateY(-30%) rotate(-135deg);
}

.search-category:hover {
    background: #e8edf5;
}

.search-input {
    width: 100%;
    padding: 12px 100px 12px 90px;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 15px;
    background: #f5f7fa;
    transition: all 0.3s;
}

.search-input:focus {
    background: #fff;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
    outline: none;
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px 20px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s;
}

.search-btn:hover {
    background: #0056b3;
}

.search-info {
    padding: 10px 0;
    color: #666;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.search-mode-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #007bff;
    cursor: pointer;
    font-size: 14px;
}

.search-mode-switch:hover {
    color: #0056b3;
}

.clear-search {
    color: #007bff;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
}

.clear-search:hover {
    background: #f0f7ff;
}

.products-container {
    margin-top: 180px;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.products-container.reduced-margin {
    margin-top: 100px;
}

.product-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.product-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: #f9f9f9;
}

.product-card .title {
    padding: 10px;
    font-size: 14px;
    color: #333;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card .price {
    padding: 0 10px;
    font-size: 16px;
    color: #ff5000;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-card .original-price {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
}

.product-card .discount-price {
    font-size: 16px;
    color: #ff5000;
    font-weight: bold;
}

.product-card .sales {
    padding: 5px 10px 10px;
    font-size: 12px;
    color: #999;
}

@media (max-width: 480px) {
    .products-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 10px;
    }
    
    .product-card img {
        width: 100%;
        aspect-ratio: 1;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .products-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

@media (min-width: 769px) {
    .products-container {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 20px;
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
    }
}

.loading {
    text-align: center;
    padding: 20px;
    font-size: 14px;
    color: #999;
    position: relative;
}

.loading-active::after {
    content: "";
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0%, 20% {
        content: ".";
    }
    40% {
        content: "..";
    }
    60%, 100% {
        content: "...";
    }
}

.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 80px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 90;
}

.back-to-top.visible {
    transform: translateY(0);
    opacity: 1;
}

.back-to-top:hover {
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.category-dropdown {
    position: absolute;
    left: 10px;
    top: 55px;
    width: 150px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    padding: 10px 0;
    z-index: 110;
    max-height: 300px;
    overflow-y: auto;
    transform: translateY(-20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
}

.category-dropdown.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.category-dropdown-item {
    padding: 10px 15px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.category-dropdown-item:hover {
    background: #f7f9fc;
    color: #007bff;
}

.category-dropdown-item.active {
    background: #f0f7ff;
    color: #007bff;
    font-weight: 500;
}

.dropdown-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.dropdown-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* 地区限制样式 */
.region-blocked-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.region-blocked-container {
    padding: 20px;
    max-width: 90%;
}

.region-blocked-container h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: #333;
}

.region-blocked-container p {
    font-size: 16px;
    margin-bottom: 30px;
    color: #666;
}

.qrcode-container {
    margin: 0 auto;
    width: 200px;
    height: 200px;
}

.qrcode-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 商品详情抽屉样式 */
.product-drawer {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    visibility: hidden;
    pointer-events: none;
}

.product-drawer.active {
    visibility: visible;
    pointer-events: auto;
}

.drawer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-drawer.active .drawer-backdrop {
    opacity: 1;
}

.drawer-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 90%;
    background-color: #fff;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.product-drawer.active .drawer-content {
    transform: translateY(0);
}

.drawer-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.3);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    z-index: 10;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 70px;
}

.drawer-scroll-content {
    display: flex;
    flex-direction: column;
}

.drawer-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2979ff;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.drawer-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    background-color: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 5;
}

.service-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex: 1;
    font-size: 12px;
    color: #333;
    background-color: #fff;
    cursor: pointer;
}

.service-btn i {
    font-size: 18px;
    margin-bottom: 2px;
    color: #2979ff;
}

.cart-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex: 1.5;
    font-size: 12px;
    color: #333;
    background-color: #fff;
    border-left: 1px solid #eee;
    border-right: 1px solid #eee;
    cursor: pointer;
}

.cart-btn i {
    font-size: 18px;
    margin-bottom: 2px;
    color: #ff9800;
}

.buy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex: 2;
    font-size: 16px;
    color: #fff;
    background-color: #000000;
    font-weight: 500;
    letter-spacing: 1px;
    cursor: pointer;
}

/* 轮播图样式 */
.swiper-container {
    width: 100%;
    background-color: #f5f5f5;
    overflow: hidden;
    flex-shrink: 0;
    margin-bottom: 15px;
    height: auto;
    min-height: 200px;
    position: relative;
    padding-bottom: 30px;
}

.swiper-pagination {
    position: absolute;
    bottom: 5px;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 10;
}

.swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
    background: #000;
    opacity: 0.2;
    margin: 0 4px;
}

.swiper-pagination-bullet-active {
    opacity: 0.8;
    background: #000;
}

.swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    padding: 10px 0;
}

.swiper-slide img {
    width: 100%;
    height: auto;
    object-fit: contain;
    background-color: #f5f5f5;
}

.swiper-button-prev,
.swiper-button-next {
    color: #ffffff;
    opacity: 0.7;
    width: 50px;
    height: 50px;
    transition: opacity 0.3s;
}

.swiper-button-prev:hover,
.swiper-button-next:hover {
    opacity: 0.8;
}

.swiper-button-prev:after,
.swiper-button-next:after {
    font-size: 50px;
    font-weight: bold;
}

.product-info {
    padding: 10px 15px;
    background-color: #fff;
    margin-bottom: 10px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.product-id {
    font-size: 16px;
    color: #777;
    margin-bottom: 10px;
    text-align: center;
    padding: 5px 0;
    text-decoration: none;
}

.product-price {
    font-size: 26px;
    font-weight: 800;
    color: #000000;
    margin-bottom: 10px;
    text-align: center;
    padding: 5px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.product-price .original-price {
    font-size: 20px;
    color: #999;
    text-decoration: line-through;
    font-weight: normal;
}

.product-price .discount-price {
    font-size: 26px;
    color: #ff5000;
    font-weight: 800;
}

/* 折扣倒计时样式 */
.discount-countdown {
    background: linear-gradient(135deg, #f99b9b, #ffae00);
    color: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
}

.countdown-text {
    font-weight: normal;
}

.countdown-time {
    font-weight: bold;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
}

.product-time {
    font-size: 14px;
    color: #999;
    text-align: right;
    padding: 5px 0;
}

.product-content {
    padding: 15px;
    background-color: #fff;
    flex: 1;
    font-size: 18px;
    line-height: 1.6;
    text-align: center;
    font-weight: 500;
    padding: 20px 15px;
    color: #333;
    min-height: 100px;
}

.product-content img {
    max-width: 100%;
    height: auto !important;
    width: auto !important;
    display: block;
    margin: 0 auto;
}

/* 客服弹窗 */
.service-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 0.3s, opacity 0.3s;
}

.service-modal.show {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s, opacity 0.3s;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    width: 80%;
    max-width: 320px;
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    z-index: 1;
}

.modal-content img {
    width: 200px;
    margin-bottom: 15px;
}

.modal-content p {
    margin-bottom: 0;
    font-size: 16px;
    color: #333;
}

.modal-close {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 24px;
    color: #999;
    cursor: pointer;
}

/* 折扣相关样式 */
.discount-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(45deg, #f8d384, #e2a639);
    color: #fff;
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 5;
}

.service-badges {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.service-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: #f0f7ff;
    color: #007bff;
    border-radius: 15px;
    font-size: 12px;
}

.service-badge i {
    font-size: 14px;
}

/* 折扣券弹窗 */
.discount-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 0.3s, opacity 0.3s;
}

.discount-popup.show {
    visibility: visible;
    opacity: 1;
    transition: visibility 0s, opacity 0.3s;
}

.popup-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
}

.popup-content {
    position: relative;
    width: 80%;
    max-width: 320px;
    background: linear-gradient(135deg, #f8d384, #e2a639);
    border-radius: 16px;
    padding: 30px 20px;
    text-align: center;
    z-index: 1;
    color: #fff;
}

.popup-close {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 24px;
    color: #fff;
    cursor: pointer;
    opacity: 0.8;
}

.discount-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.popup-content h3 {
    font-size: 18px;
    margin-bottom: 10px;
}

.discount-amount {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 10px;
}

.popup-content p {
    font-size: 14px;
    opacity: 0.9;
}

/* 悬浮提示 */
.floating-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.floating-toast.show {
    opacity: 1;
    visibility: visible;
}

/* 服务弹窗样式 */
.service-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.service-popup-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.service-popup-content {
    width: 85%;
    max-width: 350px;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    position: relative;
    z-index: 1;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    max-height: 80vh;
    overflow-y: auto;
}

.service-popup-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    color: #999;
    cursor: pointer;
}

.service-popup-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.service-popup-desc {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* 服务保障标签可点击样式 */
.service-badge {
    cursor: pointer;
    transition: all 0.2s;
}

.service-badge:hover {
    background: #e8f4ff !important;
    transform: translateY(-1px);
}