/* ===== 基础重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-x: hidden; width: 100%; max-width: 100vw; }
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif; background: #fff; color: #000; line-height: 1.5; overflow-x: hidden; width: 100%; max-width: 100vw; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
a { text-decoration: none; color: inherit; }
button { border: none; background: none; cursor: pointer; font-family: inherit; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
input { font-family: inherit; }

/* ===== 主容器防横向溢出 ===== */
main { max-width: 100%; overflow-x: hidden; }

/* PC端允许商品卡片放大时溢出 */
@media (min-width: 769px) {
    main {
        overflow-x: visible;
        overflow-y: visible;
    }
    body {
        overflow-x: visible;
    }
    html {
        overflow-x: visible;
    }
}

/* ===== Hero 区域 ===== */
.hero { position: relative; height: 480px; overflow: hidden; max-width: 100%; }
.hero-bg { position: absolute; inset: 0; background: #2a2a2a; }
.hero-bg img { width: 100%; height: 100%; object-fit: cover; }
.hero-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.35); }
.hero-content { position: relative; max-width: 1400px; width: 100%; margin: 0 auto; padding: 0 24px; height: 100%; display: flex; align-items: center; }
.hero-text { max-width: 500px; color: #fff; }
.hero-label { font-size: 13px; opacity: 0.9; margin-bottom: 12px; }
.hero-title { font-size: 42px; font-weight: 700; margin-bottom: 16px; line-height: 1.2; word-wrap: break-word; overflow-wrap: break-word; }
.hero-desc { font-size: 14px; opacity: 0.9; margin-bottom: 24px; line-height: 1.5; word-wrap: break-word; overflow-wrap: break-word; }
.btn-primary { display: inline-flex; align-items: center; gap: 8px; background: #000; color: #fff; padding: 12px 24px; font-size: 13px; font-weight: 500; border: 1px solid #000; transition: all 0.3s; }
.btn-primary:hover { background: #333; }
.btn-primary svg { width: 16px; height: 16px; }

/* ===== 分类筛选条 ===== */
.filter-section { border-bottom: 1px solid #e5e5e5; background: #fff; max-width: 100%; overflow-x: hidden; }
.filter-inner { max-width: 1400px; width: 100%; margin: 0 auto; padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.filter-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.filter-row-cat { flex: 1; min-width: 0; overflow: hidden; }
.filter-row-sort { flex-shrink: 0; }
.filter-label { display: none; }
.filter-left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.filter-btn { padding: 8px 16px; font-size: 13px; color: #666; border-radius: 4px; transition: all 0.3s; white-space: nowrap; }
.filter-btn:hover { color: #000; }
.filter-btn.active { background: #000; color: #fff; }
.filter-right { display: flex; gap: 20px; align-items: center; }
/* 排序项：箭头随排序方向切换（升序▲ 降序▼），默认▼ */
.filter-sort-links { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.filter-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: #666; transition: color 0.3s; text-decoration: none; }
.filter-link:hover { color: #000; }
.filter-link-arrow { font-size: 10px; opacity: 0.85; pointer-events: none; }
.filter-link-arrow-up { display: none; }
.filter-link-arrow-down { display: inline; }
.filter-link.sort-asc .filter-link-arrow-up { display: inline; }
.filter-link.sort-asc .filter-link-arrow-down { display: none; }
.filter-link.sort-desc .filter-link-arrow-up { display: none; }
.filter-link.sort-desc .filter-link-arrow-down { display: inline; }

/* ===== 商品网格 ===== */
.products-section { max-width: 1400px; width: 100%; margin: 0 auto; padding: 48px 24px; overflow-x: hidden; }
.products-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; min-width: 0; }

/* PC端允许卡片放大时溢出 */
@media (min-width: 769px) {
    .products-section {
        overflow: visible;
    }
.products-grid { 
        overflow: visible;
    }
}

/* ===== 首页商品为空时的空状态（仅首页使用，风格同产品列表） ===== */
.index-products-empty {
    max-width: 640px;
    margin: 56px auto 80px;
    padding: 24px 16px;
    text-align: center;
    color: #4b5563;
}
.index-products-empty-inner {
    display: inline-block;
}
.index-products-empty-title {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    margin: 0 0 6px 0;
}
.index-products-empty-desc {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 10px 0;
}
.index-products-empty-link {
    display: inline-block;
    font-size: 13px;
    color: #111827;
    text-decoration: underline;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .index-products-empty {
        max-width: 100%;
        margin: 40px 16px 64px;
        padding: 20px 12px;
    }
}
@media (max-width: 1200px) { .products-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .products-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .products-grid { grid-template-columns: 1fr; } }

/* 商品卡片 - 新设计（参照第二张图） */
.product-card { 
    border: 1px solid #e8e8e8; 
    background: #fff; 
    border-radius: 12px; 
    overflow: hidden; 
    transition: box-shadow 0.3s;
    position: relative;
}
.product-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.08); }

/* PC端悬停放大效果 */
@media (min-width: 769px) {
    .product-card {
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s;
        transform-origin: center center;
        z-index: 1;
        position: relative;
        will-change: transform;
        transform: scale(1); /* 明确设置默认缩放 */
    }
    /* 只有hover状态的卡片放大 */
    .product-card:hover {
        transform: scale(1.2) !important; /* 悬停略微放大 */
        z-index: 1000 !important;
        box-shadow: 0 20px 60px rgba(0,0,0,0.2);
        position: relative;
        border-radius: 12px !important; /* 保持圆角 */
        border: 1px solid #e8e8e8 !important; /* 保持边框颜色 */
        overflow: visible; /* 允许溢出 */
    }
    /* 确保所有非hover状态的卡片都恢复原状 */
    .products-grid .product-card:not(:hover) {
        transform: scale(1) !important;
        z-index: 1 !important;
        overflow: hidden !important;
    }
    /* 确保hover状态的卡片内容层级正确，防止触发其他卡片 */
    .product-card:hover .card-body {
        position: relative;
        z-index: 2;
    }
    .product-card:hover .card-actions-right {
        position: relative;
        z-index: 3;
    }
    /* 使用伪元素在卡片外层创建圆角边框，确保圆角显示 */
    .product-card:hover::before {
        content: '';
        position: absolute;
        top: -1px;
        left: -1px;
        right: -1px;
        bottom: -1px;
        border-radius: 12px;
        border: 1px solid #e8e8e8;
        pointer-events: none;
        z-index: -1;
    }
    /* 确保卡片内容区域也正确缩放 */
    .product-card:hover .card-image {
        overflow: hidden; /* 保持hidden，防止图片超出 */
        border-top-left-radius: 12px !important; /* 保持顶部圆角 */
        border-top-right-radius: 12px !important; /* 保持顶部圆角 */
    }
    /* 确保卡片内的图片不会超出边界 */
    .product-card:hover .card-image img,
    .product-card:hover .card-image video {
        max-width: 100%;
        max-height: 100%;
        object-fit: cover;
    }
    /* 确保card-body底部圆角 */
    .product-card:hover .card-body {
        transform: scale(1);
        border-bottom-left-radius: 12px;
        border-bottom-right-radius: 12px;
    }
    /* 非hover状态恢复card-image */
    .product-card:not(:hover) .card-image {
        overflow: hidden;
    }
    /* 确保卡片不会被父容器裁剪 */
    .products-grid > .product-card {
        overflow: visible;
    }
    /* 确保整个网格容器允许溢出 */
    .products-grid {
        isolation: isolate;
    }
}
.card-image--empty {
    aspect-ratio: 1;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    text-align: center;
}
.card-image-empty-text {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-image { 
    aspect-ratio: 1/1; 
    background: #f8f8f8; 
    overflow: hidden; 
    position: relative;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}
.card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s, opacity 0.4s ease-in-out; }
.product-card:hover .card-image img { transform: scale(1.03); }
.card-image:hover img { opacity: 0; transform: none; }
.card-video { 
    position: absolute; 
    inset: 0; 
    width: 100%; 
    height: 100%; 
    min-width: 100%;
    min-height: 100%;
    object-fit: cover; 
    object-position: center center;
    opacity: 0; 
    pointer-events: none; 
    transition: opacity 0.4s ease-in-out; 
    background: #f8f8f8; 
    border: none; 
    outline: none; 
    display: block;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    z-index: 1;
    transform: scale(1.01);
}
.card-image:hover .card-video { 
    opacity: 1; 
}
/* 确保视频加载完成后才显示，避免黑色闪烁 */
.card-video.loaded {
    opacity: 1;
}

/* 卡片内容区 */
.card-body { padding: 14px 16px 16px; }

/* 顶部：SKU/价格（左） + 操作按钮（右） */
.card-top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-meta { display: inline-flex; align-items: center; gap: 12px; flex-wrap: nowrap; min-width: 0; }
.card-sku { display: none; }
.card-price { font-size: 13px; color: #ff6b35; font-weight: 700; white-space: nowrap; }

.card-actions-right { 
    display: inline-flex; 
    align-items: center; 
    gap: 10px; 
    flex-shrink: 0;
    position: relative;
    z-index: 2; /* 确保按钮在卡片内容之上 */
}
.btn-order { display: inline-flex; align-items: center; justify-content: center; height: 30px; padding: 0 12px; font-size: 12px; color: #fff; background: #4a4a4a; border-radius: 4px; border: 1px solid #4a4a4a; white-space: nowrap; }
.btn-order:hover { background: #5a5a5a; border-color: #5a5a5a; }

.icon-btn-square { width: 30px; height: 30px; border: 1px solid #cfcfcf; border-radius: 4px; background: #fff; color: #333; display: inline-flex; align-items: center; justify-content: center; transition: background 0.2s, border-color 0.2s, color 0.2s; }
.icon-btn-square:hover { background: #f6f6f6; border-color: #bdbdbd; }
.icon-btn-square svg { width: 16px; height: 16px; }
.btn-favorite { position: relative; }
.btn-favorite .icon-outline,
.btn-favorite .icon-filled { position: absolute; width: 16px; height: 16px; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.btn-favorite.active .icon-outline { display: none !important; }
.btn-favorite.active .icon-filled { display: block !important; color: #c00; }
.btn-favorite.active { border-color: #e8b4b4; background: #fff5f5; color: #c00; }

/* 图片上的颜色球：靠右纵向排列，悬停时显示 */
.card-color-swatches {
    position: absolute;
    right: 20px;
    bottom: 24px;
    display: none;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 10px;
    z-index: 2;
}

.product-card:hover .card-color-swatches { display: flex; }
.color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
/* 无 colorImage 时用中性圆点，不用红/黑/蓝模拟色 */
.color-dot--plain {
    background: linear-gradient(145deg, #e2e8f0 0%, #cbd5e1 100%);
    border-color: rgba(255,255,255,0.95);
}
.card-image.card-image--no-video:hover img {
    opacity: 1;
}
.card-image.card-image--no-video .card-video {
    opacity: 0 !important;
    pointer-events: none;
}

/* 底部：标题（左） + 详情（右） */
.card-bottom-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 15px; font-weight: 700; line-height: 1.3; margin: 0; }
.card-title-link { color: #111; text-decoration: none; transition: color 0.2s; }
.card-title-link:hover { color: #333; }
.card-detail-link { font-size: 12px; color: #9a9a9a; white-space: nowrap; transition: color 0.2s; }
.card-detail-link:hover { color: #666; }
.card-detail-link::after { content: '›'; margin-left: 4px; }

/* ===== 回到顶部（欧美习惯：右下角固定、滚动后出现） ===== */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    background: #1a1a1a;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover {
    background: #333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.back-to-top:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
}
.back-to-top-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.back-to-top-icon svg {
    display: block;
}
.back-to-top-text {
    letter-spacing: 0.02em;
}
@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 16px;
        padding: 14px 18px;
        font-size: 13px;
        min-height: 48px;
    }
}

/* ===== 客服弹窗 ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { width: 90%; max-width: 500px; height: 80vh; max-height: 600px; background: #fff; display: flex; flex-direction: column; border-radius: 8px; overflow: hidden; }
.modal-header { padding: 16px 20px; background: #000; color: #fff; display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-status { font-size: 12px; color: #999; display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.status-dot { width: 8px; height: 8px; background: #22c55e; border-radius: 50%; }
.modal-close { font-size: 24px; color: #fff; cursor: pointer; line-height: 1; }
.modal-body { flex: 1; overflow-y: auto; padding: 20px; background: #f9f9f9; }
.chat-message { display: flex; margin-bottom: 16px; }
.chat-bubble { max-width: 70%; padding: 12px 16px; font-size: 13px; line-height: 1.5; border-radius: 4px; }
.chat-bubble.receive { background: #fff; color: #333; border: 1px solid #e5e5e5; }
.chat-bubble.send { background: #000; color: #fff; margin-left: auto; }
.chat-time { font-size: 11px; color: #999; margin-top: 4px; text-align: right; }
.modal-footer { padding: 16px 20px; background: #fff; border-top: 1px solid #e5e5e5; display: flex; gap: 12px; }
.chat-input { flex: 1; padding: 12px 16px; border: 1px solid #e5e5e5; font-size: 13px; outline: none; border-radius: 4px; }
.chat-input:focus { border-color: #000; }
.btn-send { padding: 12px 24px; background: #000; color: #fff; font-size: 13px; font-weight: 500; border-radius: 4px; }
.btn-send:hover { background: #333; }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 响应式：平板与手机 ===== */

/* 平板 */
@media (max-width: 1024px) {
    .hero { min-height: 380px; height: auto; padding: 40px 0; }
    .hero-content { padding: 0 20px; align-items: flex-start; justify-content: center; }
    .hero-text { max-width: 100%; }
    .hero-title { font-size: 32px; line-height: 1.25; }
    .hero-desc { font-size: 13px; }
    .products-section { padding: 36px 20px; }
    .products-grid { gap: 16px; }
}

/* 小屏平板 / 大屏手机 */
@media (max-width: 768px) {
    .hero { min-height: 280px; height: auto; padding: 32px 0; }
    .hero-content { padding: 0 16px; flex-direction: column; align-items: flex-start; justify-content: center; }
    .hero-text { max-width: 100%; width: 100%; }
    .hero-label { font-size: 12px; margin-bottom: 8px; }
    .hero-title { font-size: 26px; margin-bottom: 12px; line-height: 1.3; }
    .hero-desc { font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
    .btn-primary { padding: 10px 20px; font-size: 12px; }

    .filter-section { padding: 12px 0; }
    .filter-inner { padding: 12px 16px; gap: 14px; }
    .filter-row { gap: 10px; }
    /* 平板/大屏手机：分类换行，全部可见可点 */
    .filter-left { gap: 8px; flex-wrap: wrap; padding-bottom: 0; }
    .filter-btn { padding: 6px 14px; font-size: 12px; border-radius: 20px; flex-shrink: 0; }
    .filter-right { gap: 10px; }
    .filter-link { font-size: 12px; }

    .products-section { padding: 28px 16px; }
    .products-grid { gap: 14px; }

    .card-body { padding: 12px 14px; }
    .card-top-row { margin-bottom: 8px; gap: 8px; }
    .card-sku, .card-price { font-size: 12px; }
    .card-title { font-size: 14px; }
    .btn-order { height: 28px; padding: 0 10px; font-size: 11px; }
    .icon-btn-square { width: 28px; height: 28px; }
    .icon-btn-square svg { width: 14px; height: 14px; }
    .card-detail-link { font-size: 11px; }
    
    /* 移动端视频优化 - 消除黑边 */
    .card-video {
        object-fit: cover;
        object-position: center center;
        min-width: 100%;
        min-height: 100%;
        transform: scale(1.01);
    }

    .modal { width: 95%; max-width: none; height: 85vh; max-height: none; border-radius: 12px; }
    .modal-header, .modal-footer { padding: 14px 16px; }
    .modal-body { padding: 16px; }
    .chat-input, .btn-send { padding: 10px 14px; font-size: 12px; }
}

/* 手机 */
@media (max-width: 480px) {
    .hero { min-height: 240px; height: auto; padding: 24px 0; }
    .hero-content { padding: 0 12px; flex-direction: column; align-items: flex-start; justify-content: center; }
    .hero-text { max-width: 100%; width: 100%; }
    .hero-label { font-size: 11px; margin-bottom: 6px; }
    .hero-title { font-size: 22px; margin-bottom: 8px; line-height: 1.35; }
    .hero-desc { font-size: 12px; margin-bottom: 12px; line-height: 1.5; }
    .btn-primary { padding: 10px 16px; font-size: 12px; }

    .filter-section { background: #f8f8f8; border-bottom-color: #eee; }
    .filter-inner { flex-direction: column; align-items: stretch; padding: 14px 16px; gap: 14px; overflow-x: hidden; }
    .filter-row { flex-direction: column; align-items: stretch; gap: 8px; }
    .filter-row-cat { flex: none; min-width: 0; overflow: visible; }
    .filter-row-sort { flex: none; }
    .filter-label { display: block; font-size: 12px; font-weight: 600; color: #555; }
    /* 移动端分类改为换行展示，全部可见、可点，无需横向滚动 */
    .filter-left {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
        padding: 0;
        margin: 0;
    }
    .filter-btn { padding: 8px 16px; font-size: 13px; border-radius: 20px; flex-shrink: 0; }
    .filter-btn.active { background: #000; color: #fff; }
    .filter-right { width: 100%; justify-content: flex-start; gap: 16px; flex-wrap: wrap; }
    /* 移动端排序：纯文字+箭头，不用按钮样式 */
    .filter-link {
        font-size: 13px;
        color: #666;
        padding: 4px 0;
        min-height: auto;
        border: none;
        border-radius: 0;
        background: none;
        align-items: center;
    }
    .filter-link .filter-link-arrow { font-size: 10px; opacity: 0.9; }
    .filter-link:hover { color: #000; }
    .filter-link.sort-asc,
    .filter-link.sort-desc { color: #333; }

    .products-section { padding: 20px 12px; }
    .products-grid { gap: 12px; }

    .product-card { border-radius: 10px; }
    .card-body { padding: 10px 12px; }
    .card-top-row { flex-wrap: wrap; }
    .card-meta { order: 1; }
    .card-actions-right { order: 2; margin-left: auto; }
    .card-bottom-row { flex-wrap: wrap; gap: 6px; }
    .card-title { font-size: 13px; line-height: 1.35; }
    .card-detail-link { font-size: 11px; }
    
    /* 小屏移动端视频优化 - 消除黑边 */
    .card-video {
        object-fit: cover;
        object-position: center center;
        min-width: 100%;
        min-height: 100%;
        transform: scale(1.02);
    }
    .card-image {
        overflow: hidden;
    }

    .modal { width: 100%; height: 100%; max-height: none; border-radius: 0; }
    .modal-overlay { padding: 0; align-items: stretch; }
    .modal-overlay.active { display: flex; }
}
