/* ============================================
   FABRILIFE LAZY LOADING - MODERN SHIMMER EFFECT
   Sleek, minimal, high-performance skeleton loader
   ============================================ */

/* Base lazy image container */
.lazy-container {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #f6f7f8 0%, #edeef1 100%);
}

/* The lazy image itself */
img.lazy {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

img.lazy.loaded {
    opacity: 1;
}

/* ============================================
   SHIMMER ANIMATION - Modern gradient sweep
   ============================================ */
.lazy-shimmer {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
}

.lazy-shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.4) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: translateX(-100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Stop shimmer when loaded */
.lazy-shimmer.loaded::before {
    animation: none;
    opacity: 0;
}

/* ============================================
   PRODUCT CARD SKELETON
   For product grids on shop/homepage
   ============================================ */
.product-skeleton {
    position: relative;
    background: #fafafa;
    border-radius: 8px;
    overflow: hidden;
}

.product-skeleton .skeleton-image {
    width: 100%;
    padding-bottom: 100%; /* 1:1 aspect ratio */
    background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
    position: relative;
    overflow: hidden;
}

.product-skeleton .skeleton-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.5) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: shimmer 1.5s infinite;
}

/* Placeholder icon in center */
.product-skeleton .skeleton-image::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d0d0d0' stroke-width='1.5'%3E%3Crect x='3' y='3' width='18' height='18' rx='2' ry='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 0.5;
}

.product-skeleton .skeleton-text {
    padding: 12px;
}

.product-skeleton .skeleton-title {
    height: 14px;
    background: linear-gradient(90deg, #e8e8e8 0%, #f5f5f5 50%, #e8e8e8 100%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.product-skeleton .skeleton-price {
    height: 18px;
    width: 60%;
    background: linear-gradient(90deg, #e8e8e8 0%, #f5f5f5 50%, #e8e8e8 100%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    animation-delay: 0.2s;
    border-radius: 4px;
}

@keyframes skeleton-pulse {
    0%, 100% {
        background-position: 200% 0;
    }
    50% {
        background-position: 0 0;
    }
}

/* ============================================
   GALLERY/CATEGORY IMAGE SKELETON
   For larger promotional images
   ============================================ */
.gallery-skeleton {
    position: relative;
    width: 100%;
    background: linear-gradient(135deg, #f5f5f5 0%, #ebebeb 100%);
    overflow: hidden;
}

.gallery-skeleton::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.6) 50%,
        transparent 100%
    );
    animation: gallery-shimmer 2s infinite;
}

@keyframes gallery-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Center icon for gallery skeleton */
.gallery-skeleton::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ccc' stroke-width='1'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    opacity: 0.4;
}

.gallery-skeleton.loaded::before,
.gallery-skeleton.loaded::after {
    display: none;
}

/* ============================================
   PRODUCT PAGE MAIN IMAGE SKELETON
   ============================================ */
.main-image-skeleton {
    position: relative;
    width: 100%;
    min-height: 400px;
    background: linear-gradient(180deg, #f8f8f8 0%, #f0f0f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.main-image-skeleton::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        -45deg,
        transparent 40%,
        rgba(255, 255, 255, 0.8) 50%,
        transparent 60%
    );
    background-size: 300% 300%;
    animation: diagonal-shimmer 2s ease infinite;
}

@keyframes diagonal-shimmer {
    0% {
        background-position: 100% 100%;
    }
    100% {
        background-position: 0% 0%;
    }
}

/* Pulsing image icon */
.main-image-skeleton .skeleton-icon {
    width: 80px;
    height: 80px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d5d5d5' stroke-width='1'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    animation: pulse-icon 1.5s ease-in-out infinite;
    z-index: 1;
}

@keyframes pulse-icon {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.05);
    }
}

/* ============================================
   THUMBNAIL SKELETON
   For product thumbnails/swatches
   ============================================ */
.thumb-skeleton {
    position: relative;
    width: 60px;
    height: 60px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.thumb-skeleton::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.5) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: shimmer 1.2s infinite;
}

/* ============================================
   INLINE SHIMMER FOR EXISTING ELEMENTS
   Add class 'shimmer-bg' to any element
   ============================================ */
.shimmer-bg {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e8e8e8 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer-bg 1.5s infinite;
}

@keyframes shimmer-bg {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   GALLERY THUMB WRAPPER ENHANCEMENT
   Works with existing gallerythumbWrapper class
   ============================================ */
.gallerythumbWrapper {
    position: relative;
    overflow: hidden;
}

.gallerythumbWrapper:not(.gallerythumbWrapperLoaded)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: shimmer 1.5s infinite;
    z-index: 1;
    pointer-events: none;
}

/* ============================================
   HOME PRODUCT IMAGE ENHANCEMENT
   ============================================ */
.home-product {
    position: relative;
}

.home-product img {
    transition: opacity 0.3s ease;
}

.home-product img:not(.loaded) {
    opacity: 0;
}

.home-product img.loaded {
    opacity: 1;
}

/* Skeleton behind home product images */
.home-product::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding-bottom: 100%;
    background: linear-gradient(135deg, #f5f5f5 0%, #ebebeb 100%);
    z-index: 0;
}

.home-product::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding-bottom: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.5) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: shimmer 1.5s infinite;
    z-index: 0;
    pointer-events: none;
}

.home-product.image-loaded::before,
.home-product.image-loaded::after {
    display: none;
}

/* ============================================
   FLEX CATEGORY BLOCK ENHANCEMENT
   ============================================ */
.flex-cat-img {
    position: relative;
    overflow: hidden;
    min-height: 100px;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

.flex-cat-img::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    z-index: 0;
    transition: opacity 0.3s ease;
}

.flex-cat-img::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.5) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: shimmer 1.8s infinite;
    z-index: 1;
    pointer-events: none;
}

.flex-cat-img.loaded {
    background: transparent;
}

.flex-cat-img.loaded::before,
.flex-cat-img.loaded::after {
    opacity: 0;
    pointer-events: none;
}

.flex-cat-img img {
    position: relative;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.4s ease;
    width: 100%;
    display: block;
}

.flex-cat-img img.loaded,
.flex-cat-img.loaded img {
    opacity: 1;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
    .product-skeleton .skeleton-image::after {
        width: 36px;
        height: 36px;
    }

    .gallery-skeleton::after {
        width: 48px;
        height: 48px;
    }

    .main-image-skeleton {
        min-height: 300px;
    }

    .main-image-skeleton .skeleton-icon {
        width: 60px;
        height: 60px;
    }
}

/* ============================================
   REDUCED MOTION SUPPORT
   Respects user preferences for animations
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .lazy-shimmer::before,
    .product-skeleton .skeleton-image::before,
    .gallery-skeleton::before,
    .main-image-skeleton::before,
    .thumb-skeleton::before,
    .gallerythumbWrapper:not(.gallerythumbWrapperLoaded)::before,
    .home-product::after,
    .flex-cat-img::after {
        animation: none;
        background: rgba(255, 255, 255, 0.3);
        transform: none;
    }

    .product-skeleton .skeleton-title,
    .product-skeleton .skeleton-price,
    .shimmer-bg {
        animation: none;
        background: #e8e8e8;
    }

    .main-image-skeleton .skeleton-icon {
        animation: none;
        opacity: 0.4;
    }
}

/* ============================================
   INTERSECTION OBSERVER FADE-IN
   Applied when image enters viewport
   ============================================ */
.lazy-fade-in {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.lazy-fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}
