/* ===== Modal Container ===== */
.product-modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity .35s ease, visibility .35s ease;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    pointer-events: none; /* اجازه کلیک روی پس‌زمینه */
    backdrop-filter: blur(6px);
    display: none;
}

.product-modal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* فعال کردن کلیک */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Modal Box ===== */
.product-modal-box {
    width: 100%;
    max-width: 600px;
    max-height: 95vh;
    background: #fff;
    border-radius: 5px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(20px);
    transition: transform .35s ease;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 100000;
    pointer-events: auto; /* فعال کردن کلیک روی باکس */
}

.product-modal.show .product-modal-box {
    transform: scale(1) translateY(0);
}

/* ===== GALLERY - FIXED با ساختار جدید ===== */
.product-modal-gallery {
    width: 100%;
    background: #f7f7f7;
    position: relative;
    z-index: 50;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border-radius: 20px 20px 0 0;
    overflow: hidden;
    flex-shrink: 0;
}

.gallery-main {
    position: relative;
    width: 100%;
    height: 48vh;
    min-height: 300px;
    max-height: 420px;
    overflow: hidden;
    background: #f7f7f7;
}

.gallery-image-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

.gallery-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.5s ease;
    visibility: hidden;
    background: #f7f7f7;
}

.gallery-slide.active {
    opacity: 1;
    visibility: visible;
}

/* ===== Navigation Buttons ===== */
.gallery-nav {
    position: absolute;
    padding-top:7px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    font-size: 18px;
    color: #333;
    transition: all 0.3s ease;
    z-index: 10;
}

.gallery-nav:hover {
    background: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transform: translateY(-50%) scale(1.1);
}

.gallery-prev {
    left: 15px;
}

.gallery-next {
    right: 15px;
}

/* ===== Fullscreen Button ===== */
.gallery-fullscreen {
    position: absolute;
    padding-top: 4px;
    bottom: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    font-size: 20px;
    color: #333;
    transition: all 0.3s ease;
    z-index: 10;
}

.gallery-fullscreen:hover {
    background: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transform: scale(1.1);
}

/* ===== Thumbnails ===== */
/*.gallery-thumbnails {
    display: flex;
    gap: 10px;
    padding: 15px 35px;
    overflow-x: auto;
    background: #f7f7f7;
    justify-content: center;
}

.gallery-thumbnails::-webkit-scrollbar {
    height: 4px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.gallery-thumb {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    object-fit: cover;
}

.gallery-thumb.active {
    border-color: #F33C3C;
    transform: scale(1.05);
}

.gallery-thumb:hover {
    transform: scale(1.05);
}*/

/* ===== Pagination ===== */
.gallery-pagination {
    text-align: center;
    /*padding: 10px 0 15px;*/
    background: #f7f7f7;
    font-size: 14px;
    color: #666;
}

.gallery-pagination .current-slide {
    font-weight: 700;
    color: #333;
}

.gallery-pagination .total-slides {
    color: #999;
}

/* ===== Close Button - FIXED ===== */
.product-modal-close {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 15px rgba(0, 0, 0, .15);
    cursor: pointer;
    font-size: 20px;
    color: #333;
    z-index: 100000 !important;
    /*transition: all 0.3s ease;*/
    /*display: flex;*/
    /*align-items: center;*/
    /*justify-content: center;*/
    padding: 4px 0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/*.product-modal-close:hover {*/
/*    transform: scale(1.1) rotate(90deg);*/
/*    background: #fff;*/
/*    box-shadow: 0 8px 25px rgba(0, 0, 0, .2);*/
/*}*/

/* ===== Scrollable Content ===== */
.product-modal-scrollable {
    flex: 1;
    background: #fff;
    overflow-y: auto;
    padding: 0 0 20px 0;
}

.product-modal-content {
    padding: 25px 30px;
}

/* ===== Product Footer ===== */
.product-modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #eee;
    background: #fff;
}

.modal-close-btn {
    width: 100%;
    height: 56px;
    background: #F33C3C;
    color: #fff;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    transition: background 0.3s ease;
}

.modal-close-btn:hover {
    background: #d63030;
}

/* ===== FULLSCREEN OVERLAY ===== */
.gallery-fullscreen-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999999999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.gallery-fullscreen-overlay.active {
    display: flex;
}

.gallery-fullscreen-overlay .gallery-main {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    background: transparent;
    position: relative;
}

.gallery-fullscreen-overlay .gallery-image-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-fullscreen-overlay .gallery-slide {
    object-fit: contain;
    width: 100%;
    height: 100%;
    background: transparent;
}

.gallery-fullscreen-overlay .gallery-nav {
    background: rgba(255,255,255,0.2);
    color: #fff;
    width: 50px;
    height: 50px;
    font-size: 24px;
}

.gallery-fullscreen-overlay .gallery-nav:hover {
    background: rgba(255,255,255,0.3);
}

.gallery-fullscreen-overlay .gallery-fullscreen {
    background: rgba(255,255,255,0.2);
    padding-top: 6px;
    color: #fff;
    font-size: 24px;
    width: 50px;
    height: 50px;
    bottom: 30px;
    right: 30px;
}

.gallery-fullscreen-overlay .gallery-fullscreen:hover {
    background: rgba(255,255,255,0.3);
}

.gallery-fullscreen-overlay .gallery-pagination {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    color: #fff;
    padding: 0;
}

.gallery-fullscreen-overlay .gallery-pagination .current-slide {
    color: #fff;
}

.gallery-fullscreen-overlay .gallery-pagination .total-slides {
    color: rgba(255,255,255,0.6);
}

.gallery-fullscreen-overlay .fullscreen-close-btn {
    position: fixed;
    padding-top: 5px;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    z-index: 9999999999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.gallery-fullscreen-overlay .fullscreen-close-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

/* ===== Pricing Table ===== */
.pricing-table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    margin-top: 10px;
}

.pricing-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 400px;
}

.pricing-table thead {
    background: #f8f9fa;
}

.pricing-table thead th {
    padding: 12px 16px;
    font-weight: 700;
    color: #444;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e8e8e8;
    white-space: nowrap;
}

.pricing-table tbody tr {
    transition: all 0.3s ease;
    border-bottom: 1px solid #f0f0f0;
}

.pricing-table tbody tr:last-child {
    border-bottom: none;
}

.pricing-table tbody tr:hover {
    background: #fafafa;
}

.pricing-table tbody td {
    padding: 12px 16px;
    color: #333;
    vertical-align: middle;
}

.pricing-table tbody tr.popular {
    background: linear-gradient(135deg, #f8f9ff, #f0f4ff);
}

.pricing-table tbody tr.popular:hover {
    background: linear-gradient(135deg, #f0f4ff, #e8eeff);
}

.pricing-table tbody tr.best-value {
    background: linear-gradient(135deg, #fff8f0, #fff3e6);
}

.pricing-table tbody tr.best-value:hover {
    background: linear-gradient(135deg, #fff3e6, #ffedd9);
}

.discount-none {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #999;
    background: #f0f0f0;
}

.discount-save {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    color: #2e7d32;
    background: #e8f5e9;
}

tr.popular .discount-save {
    color: #1565c0;
    background: #e3f2fd;
}

tr.best-value .discount-save {
    color: #e65100;
    background: #fff3e0;
}

/* ============================================ */
/* ===== RESPONSIVE ===== */
/* ============================================ */

@media (max-width: 768px) {
    .product-modal {
        padding: 0;
        align-items: stretch;
        background: #ffffff;
    }

    .product-modal-box {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        transform: translateX(100%);
        transition: transform .35s ease;
        box-shadow: none;
    }

    .product-modal.show .product-modal-box {
        transform: translateX(0);
    }

    .product-modal-gallery {
        border-radius: 0;
    }

    .gallery-main {
        height: 300px;
        min-height: 250px;
        max-height: 400px;
    }

    .product-modal-close {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .product-modal-content {
        padding: 20px;
    }

    .product-modal-footer {
        padding: 15px 20px;
    }

    .pricing-table tbody td,
    .pricing-table thead th {
        padding: 10px 12px;
        font-size: 13px;
    }

    .gallery-fullscreen-overlay .gallery-nav {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .gallery-fullscreen-overlay .fullscreen-close-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
        top: 15px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    .gallery-main {
        height: 250px;
        min-height: 200px;
        max-height: 350px;
    }

    .gallery-thumb {
        width: 50px;
        height: 50px;
    }

    .gallery-nav {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .gallery-prev {
        left: 8px;
    }

    .gallery-next {
        right: 8px;
    }

    .pricing-table {
        font-size: 12px;
        min-width: 320px;
    }

    .pricing-table tbody td,
    .pricing-table thead th {
        padding: 8px 10px;
    }

    .discount-save,
    .discount-none {
        font-size: 11px;
        padding: 2px 8px;
    }
}

/* ===== Modal Overlay ===== */
.modal-overlay-close {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99998;
    cursor: pointer;
    display: none;
}
.product-modal.show .modal-overlay-close {
    display: block;
}
