/**
 * Product Images Widget Styles
 * 
 * Estilos para o widget de imagens de produtos com responsividade melhorada
 * 
 * @package CemPorcentoEcommerce
 * @since 1.3.0
 */

/* Container Principal */
.cpc-product-images {
    position: relative;
    width: 100%;
}

.cpc-product-images__container {
    display: flex;
    gap: 20px;
    width: 100%;
}

/* Badge de Promoção */
.cpc-product-images__badge {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 10;
    background-color: #ff0000;
    color: #ffffff;
    padding: 8px 15px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Layout: Miniaturas à Esquerda */
.cpc-product-images__container.cpc-thumbnails-left {
    flex-direction: row;
}

.cpc-product-images__container.cpc-thumbnails-left .cpc-product-images__thumbnails {
    order: 1;
    flex-direction: column;
    max-width: 120px;
}

.cpc-product-images__container.cpc-thumbnails-left .cpc-product-images__main-wrapper {
    order: 2;
    flex: 1;
}

/* Layout: Miniaturas à Direita */
.cpc-product-images__container.cpc-thumbnails-right {
    flex-direction: row;
}

.cpc-product-images__container.cpc-thumbnails-right .cpc-product-images__thumbnails {
    order: 2;
    flex-direction: column;
    max-width: 120px;
}

.cpc-product-images__container.cpc-thumbnails-right .cpc-product-images__main-wrapper {
    order: 1;
    flex: 1;
}

/* Layout: Miniaturas Embaixo */
.cpc-product-images__container.cpc-thumbnails-bottom {
    flex-direction: column;
}

.cpc-product-images__container.cpc-thumbnails-bottom .cpc-product-images__thumbnails {
    order: 2;
    flex-direction: row;
    flex-wrap: wrap;
}

.cpc-product-images__container.cpc-thumbnails-bottom .cpc-product-images__main-wrapper {
    order: 1;
}

/* Main Image Wrapper */
.cpc-product-images__main-wrapper {
    position: relative;
    width: 100%;
    min-width: 0; /* Importante para flex-shrink funcionar corretamente */
}

/* Main Image Container */
.cpc-product-images__main {
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: #f5f5f5;
    cursor: crosshair;
}

/* Aspect Ratios - Proporções Responsivas */
.cpc-product-images__main.cpc-aspect-1-1 {
    aspect-ratio: 1 / 1;
}

.cpc-product-images__main.cpc-aspect-4-3 {
    aspect-ratio: 4 / 3;
}

.cpc-product-images__main.cpc-aspect-3-4 {
    aspect-ratio: 3 / 4;
}

.cpc-product-images__main.cpc-aspect-16-9 {
    aspect-ratio: 16 / 9;
}

.cpc-product-images__main.cpc-aspect-9-16 {
    aspect-ratio: 9 / 16;
}

.cpc-product-images__main.cpc-aspect-auto {
    aspect-ratio: auto;
}

/* Main Image */
.cpc-product-images__main-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Mantém a proporção sem cortar */
    object-position: center;
    transition: opacity 0.3s ease;
}

/* Zoom Overlay */
.cpc-product-images__zoom-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 200%; /* Aumenta o tamanho da imagem de fundo */
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 5;
}

.cpc-product-images__main:hover .cpc-product-images__zoom-overlay {
    opacity: 1;
}

.cpc-product-images__main.zooming .cpc-product-images__main-img {
    opacity: 0;
}

/* Thumbnails Container */
.cpc-product-images__thumbnails {
    display: flex;
    gap: 10px;
}

/* Thumbnail Item */
.cpc-product-images__thumbnail {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #f5f5f5;
}

.cpc-product-images__thumbnail:hover {
    border-color: #999;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.cpc-product-images__thumbnail.active {
    border-color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cpc-product-images__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Preview (Editor do Elementor) */
.cpc-product-images__preview {
    padding: 40px;
    text-align: center;
    background-color: #f5f5f5;
    border: 2px dashed #ccc;
    border-radius: 8px;
}

.cpc-product-images__preview p {
    margin: 10px 0;
    color: #666;
}

/* Responsive: Tablets */
@media (max-width: 1024px) {
    .cpc-product-images__container {
        gap: 15px;
    }
    
    .cpc-product-images__thumbnail {
        width: 70px;
        height: 70px;
    }
    
    .cpc-product-images__container.cpc-thumbnails-left .cpc-product-images__thumbnails,
    .cpc-product-images__container.cpc-thumbnails-right .cpc-product-images__thumbnails {
        max-width: 100px;
    }
}

/* Responsive: Mobile */
@media (max-width: 768px) {
    /* Força layout de miniaturas embaixo em mobile */
    .cpc-product-images__container.cpc-thumbnails-left,
    .cpc-product-images__container.cpc-thumbnails-right {
        flex-direction: column !important;
    }
    
    .cpc-product-images__container.cpc-thumbnails-left .cpc-product-images__thumbnails,
    .cpc-product-images__container.cpc-thumbnails-right .cpc-product-images__thumbnails {
        flex-direction: row !important;
        flex-wrap: wrap;
        max-width: 100% !important;
        order: 2 !important;
    }
    
    .cpc-product-images__container.cpc-thumbnails-left .cpc-product-images__main-wrapper,
    .cpc-product-images__container.cpc-thumbnails-right .cpc-product-images__main-wrapper {
        order: 1 !important;
    }
    
    .cpc-product-images__container {
        gap: 12px;
    }
    
    .cpc-product-images__thumbnail {
        width: 60px;
        height: 60px;
    }
    
    .cpc-product-images__badge {
        top: 10px;
        left: 10px;
        padding: 6px 12px;
        font-size: 12px;
    }
    
    /* Desabilita zoom em mobile */
    .cpc-product-images__main {
        cursor: default;
    }
    
    .cpc-product-images__main:hover .cpc-product-images__zoom-overlay {
        opacity: 0 !important;
    }
}

/* Responsive: Mobile Pequeno */
@media (max-width: 480px) {
    .cpc-product-images__thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .cpc-product-images__thumbnails {
        gap: 8px;
    }
    
    /* Ajusta proporção em telas muito pequenas */
    .cpc-product-images__main.cpc-aspect-16-9,
    .cpc-product-images__main.cpc-aspect-4-3 {
        aspect-ratio: 1 / 1;
    }
}

/* Suporte para Navegadores sem aspect-ratio */
@supports not (aspect-ratio: 1 / 1) {
    .cpc-product-images__main.cpc-aspect-1-1::before {
        content: '';
        display: block;
        padding-top: 100%;
    }
    
    .cpc-product-images__main.cpc-aspect-4-3::before {
        content: '';
        display: block;
        padding-top: 75%;
    }
    
    .cpc-product-images__main.cpc-aspect-3-4::before {
        content: '';
        display: block;
        padding-top: 133.33%;
    }
    
    .cpc-product-images__main.cpc-aspect-16-9::before {
        content: '';
        display: block;
        padding-top: 56.25%;
    }
    
    .cpc-product-images__main.cpc-aspect-9-16::before {
        content: '';
        display: block;
        padding-top: 177.78%;
    }
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.cpc-product-images__main-img {
    animation: fadeIn 0.3s ease-in-out;
}

/* Loading State */
.cpc-product-images__main.loading {
    position: relative;
}

.cpc-product-images__main.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}
