/**
 * WooCommerce产品图片插入插件 - 样式文件
 * 作者：无剑
 */

/* 产品图片容器 */
.wcpi-product-image-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 100%;
    margin: 20px 0;
    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;
}

.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;
}

/* 产品图片 */
.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;
    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;
    padding: 20px;
    box-sizing: border-box;
}

.wcpi-product-image-wrapper:hover .wcpi-product-overlay {
    opacity: 1;
}

/* 产品信息容器 */
.wcpi-product-info {
    color: #fff;
    width: 100%;
}

/* 产品标题 */
.wcpi-product-title {
    font-size: 18px;
    font-weight: bold;
    margin: 0 0 10px 0;
    color: #fff;
    line-height: 1.4;
}

/* 产品价格 */
.wcpi-product-price {
    font-size: 20px;
    font-weight: bold;
    color: #ff6b6b;
    margin: 10px 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 {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background: #ff6b6b;
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.3s ease;
}

.wcpi-product-image-wrapper:hover .wcpi-view-product {
    background: #ff5252;
}

/* 放大按钮 */
.wcpi-zoom-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.wcpi-product-image-wrapper:hover .wcpi-zoom-btn {
    opacity: 1;
}

.wcpi-zoom-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
}

/* 图片放大灯箱 */
.wcpi-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    cursor: pointer;
    overflow: auto;
}

.wcpi-lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.wcpi-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    margin: auto;
}

.wcpi-lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    display: block;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.wcpi-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: background 0.3s ease, transform 0.3s ease;
}

.wcpi-lightbox-close:hover {
    background: rgba(255, 255, 255, 1);
    transform: rotate(90deg);
}

.wcpi-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: background 0.3s ease;
}

.wcpi-lightbox-nav:hover {
    background: rgba(255, 255, 255, 1);
}

.wcpi-lightbox-prev {
    left: 20px;
}

.wcpi-lightbox-next {
    right: 20px;
}

.wcpi-lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
}

/* 响应式设计 - 移动端 */
@media (max-width: 768px) {
    .wcpi-product-image-wrapper {
        margin: 15px 0;
    }
    
    .wcpi-product-overlay {
        padding: 15px;
    }
    
    .wcpi-product-title {
        font-size: 16px;
    }
    
    .wcpi-product-price {
        font-size: 18px;
    }
    
    .wcpi-product-description {
        font-size: 13px;
        -webkit-line-clamp: 2;
    }
    
    .wcpi-zoom-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
        top: 10px;
        right: 10px;
    }
    
    .wcpi-lightbox-content {
        max-width: 95%;
    }
    
    .wcpi-lightbox-close,
    .wcpi-lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .wcpi-lightbox-prev {
        left: 10px;
    }
    
    .wcpi-lightbox-next {
        right: 10px;
    }
    
    .wcpi-lightbox-close {
        top: 10px;
        right: 10px;
    }
}

/* 响应式设计 - 小屏幕 */
@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 {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .wcpi-zoom-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
}

/* 清除浮动 */
.wcpi-product-image-wrapper::after {
    content: "";
    display: table;
    clear: both;
}

/* 打印样式 */
@media print {
    .wcpi-product-overlay,
    .wcpi-zoom-btn {
        display: none;
    }
    
    .wcpi-product-image-wrapper {
        box-shadow: none;
        page-break-inside: avoid;
    }
}

