/**
 * WooCommerce产品图片插入插件 - 样式文件
 * 作者：无剑
 */

/* 产品图片容器 */
.wcpi-product-image-wrapper {
    position: relative;
    display: inline-block; /* 改为inline-block，让容器高度完全匹配图片 */
    width: 85%; /* 缩小15% */
    max-width: 85%;
    margin: 20px auto; /* 居中显示 */
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    /* 确保容器高度和图片高度完全一致 */
    line-height: 0;
    vertical-align: top;
}

.wcpi-product-image-wrapper:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* 产品链接 */
.wcpi-product-link {
    display: block;
    position: relative;
    width: 100%;
    text-decoration: none;
    color: inherit;
    line-height: 0;
}

/* 产品图片 */
.wcpi-product-image {
    width: 100%;
    max-height: 500px; /* 限制最大高度，避免图片过高 */
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    image-rendering: -webkit-optimize-contrast; /* 保持图片清晰度 */
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
    object-fit: contain; /* 保持比例，完整显示图片 */
}

.wcpi-product-image-wrapper:hover .wcpi-product-image {
    transform: scale(1.05);
}

/* 悬浮遮罩层 */
.wcpi-product-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%; /* 确保高度和容器完全一致 */
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.7) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-end; /* 底部对齐 */
    justify-content: center; /* 水平居中 */
    padding: 20px;
    padding-bottom: 60px; /* 为底部按钮留出空间 */
    box-sizing: border-box;
}

.wcpi-product-image-wrapper:hover .wcpi-product-overlay,
.wcpi-product-image-wrapper.wcpi-in-viewport .wcpi-product-overlay {
    opacity: 1;
}

/* 产品信息容器 */
.wcpi-product-info {
    color: #fff;
    width: 100%;
    text-align: center; /* 文字居中 */
}

/* 标题和价格同一行 */
.wcpi-title-price-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* 产品标题 */
.wcpi-product-title {
    font-size: 18px;
    font-weight: bold;
    margin: 0;
    color: #fff;
    line-height: 1.4;
}

/* 产品价格 */
.wcpi-product-price {
    font-size: 20px;
    font-weight: bold;
    color: #ff6b6b;
    margin: 0;
}

.wcpi-product-price del {
    color: #ccc;
    font-size: 16px;
    margin-right: 8px;
}

.wcpi-product-price ins {
    text-decoration: none;
    color: #ff6b6b;
}

/* 产品评分 */
.wcpi-product-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    font-size: 14px;
}

.wcpi-stars {
    color: #ffd700;
    font-size: 16px;
}

.wcpi-rating-text {
    color: #fff;
    opacity: 0.9;
}

/* 产品描述 */
.wcpi-product-description {
    font-size: 14px;
    line-height: 1.6;
    margin: 10px 0;
    color: #fff;
    opacity: 0.95;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 查看产品按钮 - 在遮罩层内的右下角 */
.wcpi-view-product-btn {
    position: absolute;
    bottom: 15px;
    right: 15px; /* 右下角 */
    padding: 10px 18px;
    background: #fff9c4; /* 淡黄色背景 */
    color: #333; /* 深色文字，提高对比度 */
    border: 2px solid #ffd700; /* 金黄色边框 */
    border-radius: 25px; /* 圆角边框 */
    font-size: 14px;
    font-weight: 600; /* 加粗字体，更显眼 */
    text-decoration: none;
    white-space: nowrap; /* 防止换行 */
    opacity: 0;
    transition: opacity 0.3s ease, background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 12; /* 确保在遮罩层内容之上 */
    box-shadow: 0 3px 10px rgba(255, 215, 0, 0.4); /* 淡黄色阴影，更显眼 */
    display: inline-flex;
    align-items: center;
    backdrop-filter: blur(5px); /* 背景模糊效果 */
}

.wcpi-product-image-wrapper:hover .wcpi-view-product-btn,
.wcpi-product-image-wrapper.wcpi-in-viewport .wcpi-view-product-btn {
    opacity: 1;
    background: #fffacd; /* 悬浮时稍亮的淡黄色 */
    transform: scale(1.05); /* 轻微放大效果 */
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.6); /* 更强的阴影 */
}


/* 响应式设计 - 移动端 */
@media (max-width: 768px) {
    .wcpi-product-image-wrapper {
        margin: 15px 0;
    }
    
    .wcpi-product-overlay {
        padding: 15px;
        padding-bottom: 50px; /* 为底部按钮留出空间 */
        height: 100%; /* 确保高度一致 */
    }
    
    .wcpi-title-price-row {
        gap: 10px;
    }
    
    .wcpi-product-title {
        font-size: 16px;
    }
    
    .wcpi-product-price {
        font-size: 18px;
    }
    
    .wcpi-view-product-btn {
        bottom: 10px;
        right: 10px; /* 移动端靠右显示 */
        padding: 8px 14px; /* 移动端稍小的内边距 */
        font-size: 12px;
        border-width: 2px; /* 保持边框宽度 */
        border-radius: 20px; /* 移动端稍小的圆角 */
        box-shadow: 0 2px 8px rgba(255, 215, 0, 0.5); /* 移动端阴影 */
    }
    
    .wcpi-product-image-wrapper:hover .wcpi-view-product-btn {
        transform: scale(1.03); /* 移动端较小的放大效果 */
    }
    
    .wcpi-product-description {
        font-size: 13px;
        -webkit-line-clamp: 2;
    }
    
}

/* 响应式设计 - 小屏幕 */
@media (max-width: 480px) {
    .wcpi-product-title {
        font-size: 14px;
    }
    
    .wcpi-product-price {
        font-size: 16px;
    }
    
    .wcpi-product-description {
        font-size: 12px;
        -webkit-line-clamp: 1;
    }
    
    .wcpi-view-product-btn {
        bottom: 8px;
        right: 8px;
        padding: 6px 12px;
        font-size: 11px;
        border-width: 1.5px;
        border-radius: 18px;
    }
    
}

/* 清除浮动 */
.wcpi-product-image-wrapper::after {
    content: "";
    display: table;
    clear: both;
}

/* 打印样式 */
@media print {
    .wcpi-product-overlay {
        display: none;
    }
    
    .wcpi-product-image-wrapper {
        box-shadow: none;
        page-break-inside: avoid;
    }
}

