/**
 * Gallery Thumbnails & Color Swatches CSS
 * Version: 1.1.0 - Compact swatches, thumbnails removed
 * For shop page product cards
 */

/* ========================================
   COLOR SWATCHES - 18x18px compact
   ======================================== */

.xpertenergy-color-swatches {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #fb8104 #f0f0f0;
    -webkit-overflow-scrolling: touch;
}

.xpertenergy-color-swatches::-webkit-scrollbar {
    height: 3px;
}

.xpertenergy-color-swatches::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 2px;
}

.xpertenergy-color-swatches::-webkit-scrollbar-thumb {
    background: #fb8104;
    border-radius: 2px;
}

.xpertenergy-color-swatch {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #ddd;
    transition: all 0.2s ease;
    position: relative;
}

.xpertenergy-color-swatch:hover {
    border-color: rgba(251, 129, 4, 0.5);
    transform: scale(1.15);
}

.xpertenergy-color-swatch.active {
    border-color: #fb8104;
    box-shadow: 0 0 0 2px rgba(251, 129, 4, 0.3);
}

/* Single color - show as active by default */
.xpertenergy-color-swatch.single-color {
    border-color: #fb8104;
    cursor: default;
}

.xpertenergy-color-swatch.single-color:hover {
    transform: none;
}

/* Color swatch tooltip */
.xpertenergy-color-swatch::after {
    content: attr(data-color-name);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 3px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    margin-bottom: 5px;
    z-index: 100;
}

.xpertenergy-color-swatch::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    margin-bottom: -3px;
    z-index: 100;
}

.xpertenergy-color-swatch:hover::after,
.xpertenergy-color-swatch:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   MAIN IMAGE TRANSITIONS
   ======================================== */

.xpertenergy-product-image-wrapper .flip-box-front img {
    transition: opacity 0.3s ease;
}

.xpertenergy-product-image-wrapper .flip-box-front img.changing {
    opacity: 0.5;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .xpertenergy-color-swatches {
        padding: 8px 10px;
        gap: 6px;
        flex-wrap: nowrap;
        justify-content: flex-start;
    }
    
    .xpertenergy-color-swatch {
        width: 24px;
        height: 24px;
    }
    
    /* Hide tooltip on mobile (touch devices) */
    .xpertenergy-color-swatch::after,
    .xpertenergy-color-swatch::before {
        display: none;
    }
}

@media (max-width: 480px) {
    .xpertenergy-color-swatch {
        width: 20px;
        height: 20px;
    }
    
    .xpertenergy-color-swatches {
        padding: 5px 6px;
        gap: 5px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.xpertenergy-color-swatch:focus {
    outline: 2px solid #fb8104;
    outline-offset: 2px;
}

/* ========================================
   EMPTY STATE HANDLING
   ======================================== */

.xpertenergy-color-swatches:empty {
    display: none;
}

/* ========================================
   RELATED PRODUCTS GRID
   ======================================== */

.xpertenergy-related-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.xpertenergy-related-item {
    width: 100%;
}

.xpertenergy-related-item .product {
    margin: 0 !important;
    width: 100% !important;
}

/* Related Products Mobile */
@media (max-width: 992px) {
    .xpertenergy-related-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .xpertenergy-related-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* ========================================
   CAROUSEL PLUGIN COMPATIBILITY
   ======================================== */

.xet-products-grid .xpertenergy-color-swatches,
.xet-carousel-wrapper .xpertenergy-color-swatches,
.swiper-slide .xpertenergy-color-swatches {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
}

/* ========================================
   ADD TO CART BUTTON (bottom of product image)
   50% width, centered, shows on hover/touch
   ======================================== */

/* Add to Cart Button - positioned at bottom of image */
.xpertenergy-image-add-to-cart {
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: 55%;
    padding: 3% 4%;
    background: #FF6B35;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: clamp(11px, 2.5vw, 14px);
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.xpertenergy-image-add-to-cart i {
    font-size: clamp(10px, 2.2vw, 13px);
}

/* Desktop: Show on card hover */
.xpertenergy-product-card:hover .xpertenergy-image-add-to-cart,
.product-item:hover .xpertenergy-image-add-to-cart {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Button hover effect */
.xpertenergy-image-add-to-cart:hover {
    background: #000;
    color: #fff;
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
}

.xpertenergy-image-add-to-cart:active {
    transform: translateX(-50%) scale(0.97);
}

/* Loading state */
.xpertenergy-image-add-to-cart.loading {
    pointer-events: none;
    background: #ccc;
}

.xpertenergy-image-add-to-cart.loading i::before {
    content: '\f110';
    animation: xpert-cart-spin 1s linear infinite;
}

@keyframes xpert-cart-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Added state */
.xpertenergy-image-add-to-cart.added {
    background: #28a745;
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.xpertenergy-image-add-to-cart.added i::before {
    content: '\f00c';
}

.xpertenergy-image-add-to-cart.added span::after {
    content: '!';
}

/* Variable product */
.xpertenergy-image-add-to-cart.product_type_variable {
    background: #fb8104;
}

.xpertenergy-image-add-to-cart.product_type_variable:hover {
    background: #000;
}

/* Disabled/Out of stock */
.xpertenergy-image-add-to-cart.disabled {
    background: #999;
    pointer-events: none;
}

/* ========================================
   MOBILE: Touch interaction
   ======================================== */

@media (max-width: 768px) {
    .xpertenergy-image-add-to-cart {
        width: 60%;
        padding: 3.5% 4%;
        bottom: 6%;
    }
    
    /* Disable hover on mobile */
    .xpertenergy-product-card:hover .xpertenergy-image-add-to-cart,
    .product-item:hover .xpertenergy-image-add-to-cart {
        opacity: 0;
        visibility: hidden;
        transform: translateX(-50%) translateY(20px);
    }
    
    /* Show on touch */
    .xpertenergy-product-card.touched .xpertenergy-image-add-to-cart,
    .product-item.touched .xpertenergy-image-add-to-cart {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }
    
    /* Keep visible if added */
    .xpertenergy-image-add-to-cart.added {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }
}

@media (max-width: 480px) {
    .xpertenergy-image-add-to-cart {
        width: 65%;
        padding: 4% 3%;
        bottom: 5%;
        font-size: clamp(10px, 3vw, 12px);
        gap: 4px;
    }
    
    .xpertenergy-image-add-to-cart i {
        font-size: clamp(9px, 2.5vw, 11px);
    }
}
