/* =====================================================================
   Custom Gallery Modal (CGM) — استایل مستقل و قابل استفاده مجدد
   یک پاپ‌آپ گالری تمام‌صفحه با دو تب «تصاویر» و «ویدئو»، بدون وابستگی
   به هیچ کتابخونه‌ی شخص ثالثی (PhotoSwipe / fancybox و ...).

   نحوه استفاده:
   1) این فایل رو لینک کن:      <link rel="stylesheet" href="custom-gallery-modal.css">
   2) custom-gallery-modal.js رو هم لینک کن (بعد از jQuery).
   3) مارک‌آپ HTML مودال (بخش #customGalleryModal) رو از پروژه‌ی اصلی کپی کن.
   4) CGM.open($product, 'images' | 'video') رو صدا بزن.

   نکته: کلاس‌های .video-popup-inner / .video-popup-file / .video-popup-embed
   برای نمایش محتوای ویدئو (تگ <video> یا آیفریم Embed) داخل تب ویدئو هستن.
   ===================================================================== */

.video-popup-inner {
    border-radius: 20px;
    box-shadow: none;
    padding: 5px;
}

.video-popup-inner.video-popup-file video {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    border: 0;
    border-radius: 13px;
}

.video-popup-inner.video-popup-embed .iframe-wrapper {
    position: relative;
    width: 100%;
}

.video-popup-inner.video-popup-embed .iframe-wrapper iframe {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ===== پاپ‌آپ گالری ===== */

.cgm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;

    direction: rtl;
    opacity: 0;
    transition: opacity .28s ease;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: opacity .25s ease, visibility .25s;
}

    .cgm-overlay.open {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .cgm-overlay.show {
        opacity: 1;
    }

    .cgm-overlay.show .cgm-box {
        transform: scale(1);
    }

.cgm-box {
    position: relative;
    width: 100%;
    height: 100%;
    transform: scale(.96);
    transition: transform .28s ease;
    display: flex;
    flex-direction: column;
}

.cgm-header {
    position: relative;
    flex: 0 0 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
}

.cgm-tabs {
    display: flex;
    gap: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 30px;
    padding: 4px;
}

    .cgm-tabs .cgm-tab {
        border: 0;
        background: transparent;
        color: #fff;
        font-family: inherit;
        font-size: 14px;
        padding: 7px 20px;
        border-radius: 30px;
        cursor: pointer;
        transition: background .25s, color .25s;
        opacity: .75;
    }

        .cgm-tabs .cgm-tab.active {
            background: #b094cc;
            opacity: 1;
        }

.cgm-counter {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #ddd;
    font-size: 13px;
}

.cgm-close {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s;
}

    .cgm-close:hover {
        background: rgba(255,255,255,0.2);
    }

.cgm-body {
    flex: 1 1 auto;
    position: relative;
    min-height: 0;
}

.cgm-panel {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
}

    .cgm-panel.active {
        display: flex;
    }

.cgm-panel-images {
    padding: 0;
}

.cgm-image-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
}

    .cgm-image-wrap img {
        max-width: 100%;
        max-height: 82vh;
        border-radius: 12px;
        -webkit-user-drag: none;
        user-select: none;
        transition: opacity .22s ease, transform .22s ease;
        opacity: 1;
        transform: translateX(0) scale(1);
    }

        .cgm-image-wrap img.cgm-out-next {
            opacity: 0;
            transform: translateX(-26px) scale(.97);
        }

        .cgm-image-wrap img.cgm-out-prev {
            opacity: 0;
            transform: translateX(26px) scale(.97);
        }

        .cgm-image-wrap img.cgm-in-next {
            transition: none;
            opacity: 0;
            transform: translateX(26px) scale(.97);
        }

        .cgm-image-wrap img.cgm-in-prev {
            transition: none;
            opacity: 0;
            transform: translateX(-26px) scale(.97);
        }

.cgm-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: background .2s;
}

    .cgm-arrow:hover {
        background: rgba(0,0,0,0.6);
    }

    .cgm-arrow.cgm-hidden {
        display: none;
    }

.cgm-arrow-prev {
    right: 14px;
}

.cgm-arrow-next {
    left: 14px;
}

.cgm-panel-video {
    padding: 20px;
}

    .cgm-panel-video .video-popup-inner.video-popup-file video {
        max-height: 82vh;
    }

    .cgm-panel-video .video-popup-inner.video-popup-embed {
        width: min(90vw, 800px);
    }

@media (max-width:767px) {
    .cgm-arrow {
        width: 36px;
        height: 36px;
        font-size: 14px;
        background: rgba(0,0,0,0.45);
    }

    .cgm-arrow-prev {
        right: 8px;
    }

    .cgm-arrow-next {
        left: 8px;
    }

    .cgm-tabs .cgm-tab {
        font-size: 13px;
        padding: 6px 16px;
    }

    .cgm-counter {
        display: none;
    }
}

@media (min-width:768px) {
    .cgm-image-wrap img {
        max-height: 93vh;
    }

    .cgm-panel-video .video-popup-inner.video-popup-file video {
        max-height: 93vh;
    }
}

/* ===== بادج قد و سایز مدل ===== */

.model-size-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(255, 255,255, 0.7);
    color: #333;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    padding: 8px 15px;
    border-radius: 30px;

}

    .model-size-badge i {
        font-size: 13px;
    }

.cgm-model-badge {
    position: absolute;
    bottom: 22px;
    right: 50%;
    transform: translateX(50%);
    z-index: 6;
}

@media (max-width:767px) {
    .cgm-model-badge {
        bottom: 14px;
        font-size: 11px;
        padding: 7px 12px;
    }
}
