/* ==================== ===== BACKDROP ===== ==================== */
#product-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10000;
}

#product-modal.active {
    opacity: 1;
    pointer-events: all;
}

/* ==================== ===== MODAL BOX ===== ==================== */
.modal-content {
    position: relative;
    background: #ffffff;
    max-width: 1100px;
    height: 85vh;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 30px;
    border-radius: 20px;
    margin: 100px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: fadeIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==================== ===== LEFT (IMAGE & SLIDER) ===== ==================== */
.modal-left {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Şəkil və ox düymələrini bükən əsas blok - Desktop */
#modal-img-wrapper {
    position: relative;
    width: 100% !important;
    flex: 1 !important;
    background-color: white !important;
    border: 1px solid #f1f5f9 !important;
    border-radius: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
}

/* Əsas Modal Şəkli - Bütün əlavə təsirlərdən qorunur */
#modal-img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    display: block !important;
    transform: none !important;
    transition: none !important;
}

/* Naviqasiya Ox Düymələri */
.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e2e8f0;
    color: #334155;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 5;
}

.modal-nav-btn:hover {
    background: #ffffff;
    color: #0594b1;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

#modal-prev-btn {
    left: 15px;
}

#modal-next-btn {
    right: 15px;
}

/* Kiçik Şəkillər (Thumbnails) */
.modal-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 2px 0;
    scrollbar-width: thin;
    margin: auto;
    margin-bottom: 7px;
}

.modal-thumbnails img {
    width: 65px !important;
    height: 65px !important;
    object-fit: contain !important;
    background: #f8fafc !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 8px !important;
    cursor: pointer;
    padding: 4px !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important;
    transform: none !important;
}

.modal-thumbnails img.active {
    border-color: #0594b1 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(5, 148, 177, 0.15) !important;
}

/* ==================== ===== RIGHT (INFO & FOOTER) ===== ==================== */
.modal-right {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    height: 100%;
    padding: 20px 0;
    padding-right: 10px;
}

#modal-firma {
    color: #9ca3af;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 4px;
}

#modal-name {
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    margin: 0;
}

#modal-desc {
    font-size: 15px;
    line-height: 1.6;
    color: #475569;
    overflow-y: auto;
    max-height: 280px;
    padding-right: 8px;
    margin-top: 15px;
}

#modal-price {
    color: #0594b1;
    font-size: 26px;
    font-weight: 800;
    padding-top: 4px;
}

/* ==================== ===== BUTTON ===== ==================== */
#modal-add {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #276c91, #0594b1);
    color: white;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(5, 148, 177, 0.2);
}

#modal-add:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(5, 148, 177, 0.3);
}

#modal-add:active {
    transform: translateY(0);
}

/* Desktop Close Button */
#modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 22px;
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
}

#modal-close:hover {
    color: #ef4444;
}

/* Tam Ekran Şəkil Qatı (Lightbox) */
#fullscreen-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    /* Tam qara premium fon */
    z-index: 20000;
    /* Ana modaldan da üst qatda dursun */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    animation: zoomIn 0.25s ease;
}

#lightbox-close {
    position: absolute;
    top: 20px;
    right: 25px;
    color: white;
    font-size: 30px;
    cursor: pointer;
    transition: transform 0.2s;
}

#lightbox-close:hover {
    transform: scale(1.1);
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   YALNIZ MOBİL ÜÇÜN MODAL KODLARI (768px və daha kiçik ekranlar)
   ========================================================================== */
@media (max-width: 768px) {
    #product-modal {
        align-items: flex-end;
    }

    .modal-content {
        width: 100vw;
        height: 100vh;
        border-radius: 24px 24px 0 0;
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        gap: 15px;
        margin: 0;
        padding: 0 20px 180px 20px !important;
        /* Alt panellər üçün təhlükəsiz boşluq */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        animation: slideUp 0.35s cubic-bezier(0.32, 0.94, 0.6, 1);
    }

    /* 🔥 MÜKƏMMƏL STICKY CLOSE DÜYMƏSİ 🔥 */
    #modal-close {
        position: sticky !important;
        top: 0 !important;
        left: 100% !important;
        margin-top: 15px !important;
        margin-bottom: -20px !important;
        background: #f1f5f9 !important;
        width: 38px !important;
        height: 38px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 15px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
        z-index: 1001 !important;
        right: auto;
    }

    /* 🔥 MOBİL ŞƏKİL QARANTİLİ GÖRÜNÜŞÜ 🔥 */
    .modal-left {
        height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        flex: none !important;
        margin-top: 15px !important;
        overflow: visible !important;
    }

    #modal-img-wrapper {
        height: 250px !important;
        min-height: 250px !important;
        width: 100% !important;
        flex: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #modal-img {
        width: auto !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
    }

    .modal-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    /* Klas və ID uyğunlaşdırılması */
    #modal-thumbnails.modal-thumbnails {
        display: flex !important;
        gap: 10px !important;
        overflow-x: auto !important;
        width: 100% !important;
        margin-top: 10px !important;
        margin-bottom: 5px !important;
    }

    #modal-thumbnails.modal-thumbnails img {
        width: 55px !important;
        height: 55px !important;
        flex-shrink: 0 !important;
    }

    /* MOBİL MƏTNLƏR */
    .modal-right {
        height: auto !important;
        flex: none !important;
        padding: 0 !important;
    }

    #modal-name {
        font-size: 21px;
    }

    #modal-desc {
        max-height: none !important;
        overflow-y: visible !important;
        margin-bottom: 20px;
    }

    /* MOBİL FOOTER PANELİ (Sabit) */
    #modal-price {
        position: fixed !important;
        bottom: 80px !important;
        left: 0 !important;
        width: 100% !important;
        background: #ffffff !important;
        padding: 15px 24px 5px 24px !important;
        margin: 0 !important;
        font-size: 24px !important;
        z-index: 998 !important;
    }

    #modal-add {
        position: fixed !important;
        bottom: 20px !important;
        left: 20px !important;
        width: calc(100% - 40px) !important;
        padding: 15px !important;
        font-size: 16px !important;
        z-index: 999 !important;
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.05) !important;
    }

    /* Arxa fondan keçən elementləri gizləyən ağ örtük layeri */
    .modal-content::after {
        content: "";
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 155px;
        background: #ffffff;
        border-top: 1px solid #f1f5f9;
        z-index: 997;
        pointer-events: none;
        border-radius: 24px 24px 0 0;
    }
}

/* Animasiya */
@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}