/* גלריה אינטראקטיבית למוצרים */
.woocommerce-product-gallery {
    position: relative;
    width: 50%;
}

.woocommerce-product-gallery__wrapper {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start;
    align-items: center;
}

/* התמונה הראשית - נשארת גדולה ובמקום הראשון */
.woocommerce-product-gallery__image:first-child {
    width: 100% !important;
    order: 1 !important;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.woocommerce-product-gallery__image:first-child img {
    width: 100% !important;
    height: auto !important;
    display: block;
    transition: transform 0.3s ease;
    cursor: default !important;
}

/* גלריית התמונות הקטנות - תמיד מתחת */
.gallery-thumbnails {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 10px !important;
    order: 2 !important;
    width: 100% !important;
    margin-top: 15px !important;
}

/* כל התמונות הקטנות - כולל הראשונה */
.gallery-thumbnails .woocommerce-product-gallery__image,
.gallery-thumbnails .thumbnail-item {
    width: calc(20% - 8px) !important;
    min-width: 80px;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    display: block !important;
}

.gallery-thumbnails .woocommerce-product-gallery__image img,
.gallery-thumbnails .thumbnail-item img {
    width: 100% !important;
    height: 80px !important;
    object-fit: cover;
    display: block;
    transition: all 0.3s ease;
}

/* אפקט hover על תמונות קטנות */
.gallery-thumbnails .woocommerce-product-gallery__image:hover,
.gallery-thumbnails .thumbnail-item:hover {
    border-color: var(--blue, #00b4d5);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 180, 213, 0.3);
}

.gallery-thumbnails .woocommerce-product-gallery__image:hover img,
.gallery-thumbnails .thumbnail-item:hover img {
    transform: scale(1.1);
    filter: brightness(1.1);
}

/* תמונה פעילה */
.gallery-thumbnails .woocommerce-product-gallery__image.active,
.gallery-thumbnails .thumbnail-item.active {
    border-color: var(--purple, #502d87) !important;
    box-shadow: 0 8px 20px rgba(80, 45, 135, 0.4);
}

.gallery-thumbnails .woocommerce-product-gallery__image.active img,
.gallery-thumbnails .thumbnail-item.active img {
    filter: brightness(1.2);
}

/* אפקט טעינה */
.woocommerce-product-gallery__image:first-child::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    z-index: 1;
    pointer-events: none;
}

.woocommerce-product-gallery__image:first-child.loading::before {
    transform: translateX(100%);
}

/* ****** CSS לאפקט HOVER בארכיב - מעודכן! ****** */

/* אפקט החלפת תמונה בארכיב - תוקן ל-background-image */
.while_pic {
    position: relative;
    overflow: hidden;
    height: 240px;
    width: 100%;
    transition: all 0.3s ease;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

/* תמונה שנייה כ-IMG tag מעל ה-background */
.while_pic .second-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transform: scale(1.1);
    transition: all 0.4s ease;
    z-index: 2;
}

/* אפקט hover בארכיב - מעבר על ה-while_pic */
.while_pic:hover .second-image {
    opacity: 1;
    transform: scale(1);
}

/* אפקט נוסף על כל הקארד */
.while_post {
    transition: all 0.3s ease;
}

.while_post:hover {
    transform: translateY(-5px);
    box-shadow: 5px 5px 15px #c9c9c94d;
}

/* אפקט על הכותרת */
.while_post:hover h3.lesson_cat_title {
    background-color: var(--blue, #00b4d5);
    color: white;
    transition: all 0.3s ease;
}

/* טעינה מוקדמת - מניעת הבהוב */
.while_pic .second-image.loading {
    opacity: 0;
    transform: scale(1.2);
}

.while_pic .second-image.loaded {
    transform: scale(1.1);
}

/* מדיה קוורי לנייד */
@media (max-width: 768px) {
    .woocommerce-product-gallery {
        width: 100%;
        margin-bottom: 30px;
    }

    .woocommerce-product-gallery__image:not(:first-child) {
        width: calc(25% - 8px) !important;
        min-width: 70px;
    }

    .woocommerce-product-gallery__image:not(:first-child) img {
        height: 70px !important;
    }
}

@media (max-width: 480px) {
    .woocommerce-product-gallery__image:not(:first-child) {
        width: calc(33.333% - 8px) !important;
        min-width: 60px;
    }

    .woocommerce-product-gallery__image:not(:first-child) img {
        height: 60px !important;
    }
}

/* אנימציה לשינוי תמונות */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.woocommerce-product-gallery__image:first-child img.fade-in {
    animation: fadeIn 0.4s ease;
}
