/* ==========================================
   手机端 Related Products 响应式优化
   ========================================== */

/* 手机端 - 每行显示2个产品 */
@media (max-width: 767px) {
    /* Related products 每行2个 */
    .single-product .related ul.products li.product,
    .woocommerce .related.products ul.products li.product,
    .woocommerce-page .related.products ul.products li.product {
        width: 50% !important;
        padding: 0 4px 20px 4px !important;
    }

    /* 调整第一个产品的左边距 */
    .single-product .related ul.products li.product:nth-child(2n+1),
    .woocommerce .related.products ul.products li.product:nth-child(2n+1),
    .woocommerce-page .related.products ul.products li.product:nth-child(2n+1) {
        padding-left: 0 !important;
    }

    /* 调整最后一个产品的右边距 */
    .single-product .related ul.products li.product:nth-child(2n),
    .woocommerce .related.products ul.products li.product:nth-child(2n),
    .woocommerce-page .related.products ul.products li.product:nth-child(2n) {
        padding-right: 0 !important;
    }

    /* 产品列表容器 */
    .single-product .related ul.products,
    .woocommerce .related.products ul.products,
    .woocommerce-page .related.products ul.products {
        display: flex !important;
        flex-wrap: wrap !important;
        margin: 0 !important;
    }

    /* 产品卡片最大高度 */
    .single-product .related ul.products li.product .post_item,
    .woocommerce .related.products ul.products li.product .post_item,
    .woocommerce-page .related.products ul.products li.product .post_item {
        max-height: 300px !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    /* 产品图片区域 - 完整显示不裁切 */
    .single-product .related ul.products li.product .post_featured,
    .woocommerce .related.products ul.products li.product .post_featured,
    .woocommerce-page .related.products ul.products li.product .post_featured {
        max-height: 220px !important;
        height: 200px !important;
        width: 100% !important;
        margin-bottom: 8px !important;
        overflow: hidden !important;
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #f5f5f5 !important;
        padding: 0 !important;
    }

    /* 图片容器链接 */
    .single-product .related ul.products li.product .post_featured > a,
    .woocommerce .related.products ul.products li.product .post_featured > a,
    .woocommerce-page .related.products ul.products li.product .post_featured > a {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* 图片完整显示,占满整个卡片宽度 */
    .single-product .related ul.products li.product .post_featured img,
    .woocommerce .related.products ul.products li.product .post_featured img,
    .woocommerce-page .related.products ul.products li.product .post_featured img {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: cover !important; /* 填充整个容器,可能会裁切 */
        object-position: center !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 产品信息区域 */
    .single-product .related ul.products li.product .post_data,
    .woocommerce .related.products ul.products li.product .post_data,
    .woocommerce-page .related.products ul.products li.product .post_data {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        min-height: 70px !important;
        overflow: visible !important;
    }

    /* 产品标题 */
    .single-product .related ul.products li.product .post_data h3,
    .single-product .related ul.products li.product .post_data .woocommerce-loop-product__title,
    .woocommerce .related.products ul.products li.product .post_data h3,
    .woocommerce .related.products ul.products li.product .post_data .woocommerce-loop-product__title,
    .woocommerce-page .related.products ul.products li.product .post_data h3,
    .woocommerce-page .related.products ul.products li.product .post_data .woocommerce-loop-product__title {
        font-size: 16px !important;
        line-height: 1.3 !important;
        margin: 0 0 6px 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
        max-height: 62px !important;
        word-break: break-word !important;
        hyphens: auto !important;
    }

    /* 产品标题链接 */
    .single-product .related ul.products li.product .post_data h3 a,
    .single-product .related ul.products li.product .post_data .woocommerce-loop-product__title a,
    .woocommerce .related.products ul.products li.product .post_data h3 a,
    .woocommerce .related.products ul.products li.product .post_data .woocommerce-loop-product__title a,
    .woocommerce-page .related.products ul.products li.product .post_data h3 a,
    .woocommerce-page .related.products ul.products li.product .post_data .woocommerce-loop-product__title a {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
        word-break: break-word !important;
        hyphens: auto !important;
    }

    /* 价格 */
    .single-product .related ul.products li.product .post_data .price,
    .woocommerce .related.products ul.products li.product .post_data .price,
    .woocommerce-page .related.products ul.products li.product .post_data .price {
        font-size: 16px !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        font-weight: 600 !important;
    }

    /* 折扣标签 */
    .single-product .related ul.products li.product .onsale,
    .woocommerce .related.products ul.products li.product .onsale,
    .woocommerce-page .related.products ul.products li.product .onsale {
        font-size: 10px !important;
        padding: 2px 6px !important;
        min-width: auto !important;
        min-height: auto !important;
        line-height: 1.2 !important;
    }

    /* 按钮 */
    .single-product .related ul.products li.product .button,
    .single-product .related ul.products li.product .add_to_cart_button,
    .woocommerce .related.products ul.products li.product .button,
    .woocommerce .related.products ul.products li.product .add_to_cart_button,
    .woocommerce-page .related.products ul.products li.product .button,
    .woocommerce-page .related.products ul.products li.product .add_to_cart_button {
        font-size: 10px !important;
        padding: 4px 8px !important;
        margin-top: 4px !important;
    }

    /* Related Products 标题 */
    .single-product .related > h2,
    .woocommerce .related.products > h2,
    .woocommerce-page .related.products > h2 {
        font-size: 18px !important;
        margin-bottom: 15px !important;
    }
}

/* 超小屏幕优化 (320px - 400px) */
@media (max-width: 400px) {
    .single-product .related ul.products li.product .post_item,
    .woocommerce .related.products ul.products li.product .post_item,
    .woocommerce-page .related.products ul.products li.product .post_item {
        max-height: 280px !important;
    }

    .single-product .related ul.products li.product .post_featured,
    .woocommerce .related.products ul.products li.product .post_featured,
    .woocommerce-page .related.products ul.products li.product .post_featured {
        max-height: 200px !important;
        height: 200px !important;
    }

    .single-product .related ul.products li.product .post_data h3,
    .single-product .related ul.products li.product .post_data .woocommerce-loop-product__title,
    .woocommerce .related.products ul.products li.product .post_data h3,
    .woocommerce .related.products ul.products li.product .post_data .woocommerce-loop-product__title,
    .woocommerce-page .related.products ul.products li.product .post_data h3,
    .woocommerce-page .related.products ul.products li.product .post_data .woocommerce-loop-product__title {
        font-size: 14px !important;
        max-height: 55px !important;
    }

    .single-product .related ul.products li.product .post_data .price,
    .woocommerce .related.products ul.products li.product .post_data .price,
    .woocommerce-page .related.products ul.products li.product .post_data .price {
        font-size: 14px !important;
    }
}
