/**
 * MemarBash Product Gallery CSS
 */

/* Gallery Container */
.memarbash-product-gallery {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 200px;
    overflow: hidden;
    border-radius: 10px;
    z-index: 1;
}

/* Gallery Wrapper */
.memarbash-gallery-container {
    position: relative;
    width: 100%;
    height: auto;
    overflow: hidden;
}

.memarbash-gallery-wrapper {
    position: relative;
    width: 100%;
    height: auto;
}

/* Gallery Item */
.memarbash-gallery-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.memarbash-gallery-item.active {
    opacity: 1;
    visibility: visible;
    z-index: 1;
    position: relative;
}

/* Gallery Images */
.memarbash-gallery-item img {
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

/* Video Container */
.memarbash-gallery-video-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #0000000c;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.memarbash-gallery-video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
    position: relative;
}

/* Video overlay to ensure play button is always visible */
.memarbash-gallery-video-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg,
            rgba(0, 0, 0, 0.1) 0%,
            rgba(0, 0, 0, 0.05) 50%,
            rgba(0, 0, 0, 0.1) 100%);
    z-index: 4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.memarbash-gallery-video-container:hover::before {
    opacity: 1;
}

/* Video Placeholder for Lazy Loading */
.memarbash-gallery-video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #0000000c;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

/* Video Thumbnail */
.memarbash-gallery-video-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.3s ease;
    z-index: 3;
}

/* Video Poster (fallback when no thumbnail) */
.memarbash-gallery-video-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
}

.memarbash-gallery-video-poster video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.memarbash-gallery-video-thumb:hover {
    opacity: 0.8;
}

/* Ensure play button is visible on video thumbnails */
.memarbash-gallery-video-thumb .memarbash-gallery-video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
}

/* Add a subtle overlay to make play button more visible */
.memarbash-gallery-video-thumb::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    transition: background 0.3s ease;
    z-index: 5;
}

.memarbash-gallery-video-thumb:hover::after {
    background: rgba(0, 0, 0, 0.3);
}

/* Video Play Button */
.memarbash-gallery-video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Video Watch Text */
.memarbash-gallery-video-watch-text {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 11;
    animation: fadeInText 0.6s ease 0.3s forwards;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes fadeInText {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }

    to {
        opacity: 0.9;
        transform: translateX(-50%) translateY(0);
    }
}

.memarbash-gallery-video-play-button:hover {
    background-color: rgba(0, 0, 0, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
    border-color: #fff;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.memarbash-gallery-video-play-button:hover .memarbash-gallery-video-watch-text {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

.memarbash-gallery-video-play-button i {
    font-size: 36px;
    margin-left: 4px;
    /* Slight offset to center the play triangle visually */
}

.memarbash-gallery-video-play-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-left: 20px solid #fff;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    margin-left: 3px;
    /* Center the triangle */
}

/* Hide the icon when we have the CSS triangle */
.memarbash-gallery-video-play-button i {
    display: none;
}

/* Navigation Arrows */
.memarbash-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    z-index: 2;
    transition: background-color 0.3s ease;
}

.memarbash-gallery-nav:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.memarbash-gallery-prev {
    left: 15px;
}

.memarbash-gallery-next {
    right: 15px;
}

.memarbash-gallery-nav svg {
    width: 24px;
    height: 24px;
}

/* Pagination Dots */
.memarbash-gallery-pagination {
    position: absolute;
    bottom: 15px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    border: radius 16px;
    z-index: 2;
}

.pagination-dot {
    width: 10px;
    height: 10px;
    background-color: #ccc;
    border-radius: 5px;
    margin: 0 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.pagination-dot.active {
    background-color: #fff;
    width: 30px !important;
    height: 10px !important;
    transform: scale(1.2);
}

/* Single Item Gallery */
.memarbash-product-gallery[data-single-item="true"] .memarbash-gallery-item {
    position: relative;
    opacity: 1;
    visibility: visible;
}

.memarbash-product-gallery[data-single-item="true"] .memarbash-gallery-item img {
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* Responsive Styles */
@media screen and (max-width: 767px) {
    .memarbash-gallery-nav {
        width: 30px;
        height: 30px;
    }

    .memarbash-gallery-nav svg {
        width: 18px;
        height: 18px;
    }

    .pagination-dot {
        width: 8px;
        height: 8px;
        margin: 0 3px;
    }

    .memarbash-gallery-video-play-button {
        width: 60px;
        height: 60px;
        border-width: 2px;
    }

    .memarbash-gallery-video-play-button::before {
        border-left-width: 16px;
        border-top-width: 10px;
        border-bottom-width: 10px;
        margin-left: 2px;
    }

    .memarbash-gallery-video-play-button i {
        font-size: 28px;
    }

    .memarbash-gallery-video-watch-text {
        font-size: 11px;
        top: -40px;
        padding: 4px 8px;
        border-radius: 16px;
    }
}

/* RTL Support */
html[dir="rtl"] .memarbash-gallery-prev {
    left: auto;
    right: 15px;
    transform: translateY(-50%) scaleX(-1);
}

html[dir="rtl"] .memarbash-gallery-next {
    right: auto;
    left: 15px;
    transform: translateY(-50%) scaleX(-1);
}

html[dir="rtl"] .memarbash-gallery-prev:hover {
    transform: translateY(-50%) scaleX(-1);
}

html[dir="rtl"] .memarbash-gallery-next:hover {
    transform: translateY(-50%) scaleX(-1);
}

/* Hover pause effect */
.memarbash-product-gallery[data-pause-on-hover="true"]:hover .memarbash-gallery-item.active {
    animation-play-state: paused;
}

/* Fully justified gallery styles */
.memarbash-gallery-justified {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

.memarbash-gallery-justified::after {
    content: "";
    flex: auto;
}

/* Zoom effect on hover */
.memarbash-gallery-item img {
    transition: transform 0.5s ease;
}

.memarbash-gallery-item:hover img {
    transform: scale(1.05);
}

/* Lightbox */
.memarbash-gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.memarbash-gallery-lightbox.active {
    display: flex;
    opacity: 1;
}

.memarbash-gallery-lightbox-content {
    position: relative;
    width: 90%;
    height: 90%;
    max-width: 1200px;
    max-height: 800px;
}

.memarbash-gallery-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 30px;
    height: 30px;
    color: #fff;
    cursor: pointer;
    z-index: 10;
}

.memarbash-gallery-lightbox-close svg {
    width: 100%;
    height: 100%;
}

.memarbash-gallery-lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.memarbash-gallery-lightbox-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.memarbash-gallery-lightbox-item.active {
    opacity: 1;
    visibility: visible;
}

.memarbash-gallery-lightbox-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.memarbash-gallery-lightbox-video,
.memarbash-gallery-lightbox-aparat {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.memarbash-gallery-lightbox-video video {
    max-width: 100%;
    max-height: 100%;
}

.memarbash-gallery-aparat-embed {
    width: 100%;
    height: 100%;
    background-color: #000;
}

.memarbash-gallery-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    z-index: 2;
    transition: background-color 0.3s ease;
}

.memarbash-gallery-lightbox-nav:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.memarbash-gallery-lightbox-prev {
    left: 20px;
}

.memarbash-gallery-lightbox-next {
    right: 20px;
}

.memarbash-gallery-lightbox-nav svg {
    width: 30px;
    height: 30px;
}

/* Aparat Video Container */
.memarbash-gallery-aparat-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #000000;
}

.memarbash-gallery-aparat-placeholder {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000000;
    background-size: cover;
    background-position: center;
    cursor: pointer;
}

.memarbash-gallery-aparat-placeholder::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23ffffff" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><path d="M22.54 6.42a2.78 2.78 0 0 0-1.94-2C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 2A29 29 0 0 0 1 11.75a29 29 0 0 0 .46 5.33A2.78 2.78 0 0 0 3.4 19c1.72.46 8.6.46 8.6.46s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-2 29 29 0 0 0 .46-5.25 29 29 0 0 0-.46-5.33z"></path><polygon points="9.75 15.02 15.5 11.75 9.75 8.48 9.75 15.02"></polygon></svg>');
    background-size: 80px;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.5;
}

/* RTL Support for Lightbox */
html[dir="rtl"] .memarbash-gallery-lightbox-close {
    right: auto;
    left: 0;
}

html[dir="rtl"] .memarbash-gallery-lightbox-prev {
    left: auto;
    right: 20px;
    transform: translateY(-50%) scaleX(-1);
}

html[dir="rtl"] .memarbash-gallery-lightbox-next {
    right: auto;
    left: 20px;
    transform: translateY(-50%) scaleX(-1);
}

html[dir="rtl"] .memarbash-gallery-lightbox-prev:hover {
    transform: translateY(-50%) scaleX(-1);
}

html[dir="rtl"] .memarbash-gallery-lightbox-next:hover {
    transform: translateY(-50%) scaleX(-1);
}