.pswp {
    --pswp-bg: #f0f0f0;
    --pswp-icon-color: #000;
    --pswp-icon-color-secondary: transparent;
    --pswp-placeholder-bg: #222;
    --pswp-error-text-color: #ff0000;
}

.pswp__img {
    object-fit: contain;
}

.pswp__icn {
    color: #fff;
}

.pswp__zoom-level {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 5px 10px;
    border-radius: 3px;
}

/* Gallery styles */
.image-gallery .swiper-slide img {
    height: 100%;
    width: 100%;
    object-fit: cover;
    border-radius: 10px;
    cursor: zoom-in;
}

.product-gallery-flex {
    display: flex;
}

.product-gallery-flex .product-gallery-thumb {
    width: calc(14% - 10px);
    margin: 0px;
    height: 600px;
}

.product-gallery-flex .product-gallery {
    width: calc(86% - 10px);
    height: 600px;
}

.thumbnail-image {
    filter: brightness(1);
    transition: all 0.3s ease-in-out;
}

.swiper-slide-thumb-active .thumbnail-image {
    filter: brightness(0.7);
    border: 1.5px solid #000 !important;
}

.grid-gallery-container {
    width: 100%;
    padding: 0;
    overflow: hidden;
    margin-bottom: 30px;
}

.grid-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
    gap: 15px;
    height: 100%;
    max-height: 600px;
    overflow: hidden;
}

/* Different layouts based on number of images */
.grid-gallery:has(.grid-gallery-item:nth-child(1):nth-last-child(1)) {
    grid-template-columns: 1fr;
}

.grid-gallery:has(.grid-gallery-item:nth-child(2):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
}

.grid-gallery:has(.grid-gallery-item:nth-child(3):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
}

.grid-gallery:has(.grid-gallery-item:nth-child(3):nth-last-child(1)) .grid-gallery-item:first-child {
    grid-column: 1 / 3;
}

.grid-gallery:has(.grid-gallery-item:nth-child(4):nth-last-child(1)) {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

/* For more than 4 images, show only first 4 */
.grid-gallery .grid-gallery-item.hidden-image {
    display: none;
}

.grid-gallery img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 10px;
    border: 1px solid #ebebeb;
    object-fit: cover;
    transition: transform 0.3s ease-in-out, filter 0.3s ease;
}

.grid-gallery-item:hover img {
    transform: scale(1.03);
    filter: brightness(1.05);
}

.grid-gallery-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    height: 100%;
}

.more-images-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
}

.grid-swiper-gallery {
    display: none;
}

.bottom-flex {
    flex-direction: column;
}

.bottom-flex .product-gallery-thumb {
    width: 100%;
    height: 105px;
    margin-top: 15px;
}

.product-gallery-flex .swiper-button-next,
.product-gallery-flex .swiper-button-prev {
    background-color: white;
}

.product-gallery-flex .swiper-button-next::after,
.product-gallery-flex .swiper-button-prev::after {
    color: black;
}

@media (max-width: 776px) {
    .product-thumb-left-right {
        display: none !important;
    }

    .product-gallery {
        width: 100% !important;
    }

    .product-gallery-flex .product-gallery {
        height: 350px !important;
    }

    .product-gallery-flex .swiper-slide {
        width: 80% !important;
    }

    .grid-gallery {
        grid-template-columns: 1fr !important;
        max-height: none;
        overflow: visible;
    }

    .grid-gallery-container {
        max-height: none;
        overflow: visible;
    }

    /* Override grid layouts for mobile */
    .grid-gallery:has(.grid-gallery-item:nth-child(3):nth-last-child(1)) .grid-gallery-item:first-child,
    .grid-gallery:has(.grid-gallery-item:nth-child(4):nth-last-child(1)) .grid-gallery-item:first-child {
        grid-column: 1 / 2;
    }

    .grid-gallery .grid-gallery-item {
        height: auto;
        min-height: 350px;
    }

    .bottom-flex .product-gallery-thumb {
        display: none;
    }

    .product-gallery-flex .swiper-button-next,
    .product-gallery-flex .swiper-button-prev {
        display: none;
    }
}

@media (min-width: 777px) and (max-width: 1024px) {
    .product-thumb-left-right {
        display: none !important;
    }

    .product-gallery {
        width: 100% !important;
    }

    .product-gallery-flex .product-gallery {
        height: 400px !important;
    }

    .product-gallery-flex .swiper-slide {
        width: 80% !important;
    }

    .bottom-flex .product-gallery-thumb {
        display: none;
    }

    .product-gallery-flex .swiper-button-next,
    .product-gallery-flex .swiper-button-prev {
        display: none;
    }

    /* Grid gallery styles for tablets */
    .grid-gallery {
        grid-template-columns: repeat(2, 1fr);
        grid-gap: 15px;
        height: auto;
        max-height: 500px;
    }

    .grid-gallery .grid-gallery-item {
        height: auto;
        min-height: 250px;
    }

    .grid-gallery img {
        height: 100%;
        max-height: 400px;
    }
}