/**
 * تحسينات معرض الصور - نظام متقدم مع ميزات السحب والأزرار وعرض الصور
 * @author Mahfda Team
 * @version 1.0
 */

/* تحسينات المعرض المحسن */
.enhanced-gallery {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #1a1a1a;
    padding: 20px 0;
    margin: 20px 0;
}

/* حاوية السلايدر */
.gallery-slider {
    display: flex;
    overflow: hidden;
    position: relative;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
    padding: 0 10px;
}

.gallery-slider::-webkit-scrollbar {
    display: none;
}

.gallery-slider:active {
    cursor: grabbing;
}

/* الشرائح */
.gallery-slide {
    flex: 0 0 auto;
    width: 200px;
    height: 100px;
    margin: 0 5px;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.gallery-slide:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.gallery-slide .thumb {
    width: 100%;
    height: 100%;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border-radius: 8px;
    transition: all 0.3s ease;
}

/* أزرار التنقل */
.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 10;
    font-size: 18px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.gallery-nav-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.gallery-prev-btn {
    left: 10px;
}

.gallery-next-btn {
    right: 10px;
}

/* نافذة عرض الصور */
.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.gallery-lightbox.show {
    opacity: 1;
}

/* حاوية الصورة في النافذة المنبثقة */
.lightbox-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* الصورة في النافذة المنبثقة */
.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
    opacity: 0;
}

.lightbox-image.loaded {
    opacity: 1;
}

/* زر الإغلاق */
.lightbox-close-btn {
    position: absolute;
    top: -50px;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lightbox-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* أزرار التنقل في النافذة المنبثقة */
.lightbox-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    font-size: 24px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lightbox-nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev-btn {
    left: -60px;
}

.lightbox-next-btn {
    right: -60px;
}

/* عداد الصور */
.lightbox-counter {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* مؤشر التحميل */
.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* تحسينات للشاشات الصغيرة */
@media (max-width: 768px) {
    .enhanced-gallery {
        padding: 15px 0;
    }

    .gallery-slide {
        width: 150px;
        height: 75px;
    }

    .gallery-nav-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }

    .lightbox-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .lightbox-prev-btn {
        left: -50px;
    }

    .lightbox-next-btn {
        right: -50px;
    }

    .lightbox-close-btn {
        top: -40px;
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .gallery-slide {
        width: 120px;
        height: 60px;
    }

    .gallery-nav-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .lightbox-nav-btn {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    .lightbox-prev-btn {
        left: -40px;
    }

    .lightbox-next-btn {
        right: -40px;
    }

    .lightbox-counter {
        font-size: 14px;
        padding: 6px 12px;
    }
}

/* تحسينات للشاشات الكبيرة */
@media (min-width: 1200px) {
    .gallery-slide {
        width: 250px;
        height: 125px;
    }

    .gallery-nav-btn {
        width: 50px;
        height: 50px;
        font-size: 22px;
    }

    .lightbox-nav-btn {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .lightbox-prev-btn {
        left: -80px;
    }

    .lightbox-next-btn {
        right: -80px;
    }
}

/* تحسينات للأداء */
.gallery-slider {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.gallery-slide {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* تحسينات للوضع المظلم */
@media (prefers-color-scheme: dark) {
    .enhanced-gallery {
        background: #0a0a0a;
    }
}

/* تحسينات للوضع المضيء */
@media (prefers-color-scheme: light) {
    .enhanced-gallery {
        background: #f5f5f5;
    }
}

/* تحسينات للطباعة */
@media print {
    .gallery-nav-btn,
    .lightbox-nav-btn,
    .lightbox-close-btn {
        display: none !important;
    }
}

/* تحسينات لإمكانية الوصول */
.gallery-nav-btn:focus,
.lightbox-nav-btn:focus,
.lightbox-close-btn:focus {
    outline: 2px solid #D98F40;
    outline-offset: 2px;
}

/* تحسينات للتحميل */
.gallery-slide.loading {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* تحسينات للتفاعل */
.gallery-slide:active {
    transform: scale(0.95);
}

.gallery-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-close-btn:active {
    transform: scale(0.95);
}

/* تحسينات للشاشات عالية الدقة */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .gallery-slide .thumb {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* تحسينات للشاشات عالية الدقة جداً */
@media (-webkit-min-device-pixel-ratio: 3), (min-resolution: 288dpi) {
    .gallery-slide .thumb {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
} 