/* تنسيق معرض الصور الديناميكي */

/* الحاوي الرئيسي */
.dynamic-image-gallery {
    width: 100%;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* تبويبات الفلترة */
.dig-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    padding: 0;
    border-bottom: 2px solid #f1f1f1;
    padding-bottom: 15px;
}

.dig-filter-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    color: #495057;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    position: relative;
    overflow: hidden;
}

.dig-filter-btn:hover {
    background: #e9ecef;
    border-color: #dee2e6;
    color: #212529;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dig-filter-btn.active {
    background: linear-gradient(135deg, #007cba 0%, #0073aa 100%);
    border-color: #0073aa;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 115, 170, 0.3);
}

.dig-filter-btn.active:hover {
    background: linear-gradient(135deg, #005a87 0%, #004d73 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 115, 170, 0.4);
}

/* حاوي الصور */
.dig-images-container {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

/* شبكة الصور - تخطيط تلقائي */
.dynamic-image-gallery[data-columns="2"] .dig-images-container {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.dynamic-image-gallery[data-columns="3"] .dig-images-container {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.dynamic-image-gallery[data-columns="4"] .dig-images-container {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.dynamic-image-gallery[data-columns="5"] .dig-images-container {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* عنصر صورة واحدة */
.dig-image-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    opacity: 1;
    transform: scale(1);
}

.dig-image-item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* إخفاء الصور المفلترة */
.dig-image-item.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

/* رابط الصورة */
.dig-lightbox-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* حاوي الصورة */
.dig-image-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* نسبة عرض إلى ارتفاع 4:3 */
    overflow: hidden;
}

.dig-image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.dig-image-item:hover .dig-image-wrapper img {
    transform: scale(1.1);
}

/* طبقة العنوان */
.dig-image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 20px 15px 15px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.dig-image-item:hover .dig-image-overlay {
    transform: translateY(0);
}

.dig-image-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    display: block;
}

/* أيقونة التكبير */
.dig-image-wrapper::before {
    content: "🔍";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    background: rgba(255, 255, 255, 0.9);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.dig-image-item:hover .dig-image-wrapper::before {
    opacity: 1;
}

/* رسالة عدم وجود معارض */
.dig-no-galleries {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* تحسينات للشاشات الصغيرة */
@media (max-width: 768px) {
    .dig-filter-tabs {
        justify-content: center;
    }
    
    .dig-filter-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .dynamic-image-gallery[data-columns="2"] .dig-images-container,
    .dynamic-image-gallery[data-columns="3"] .dig-images-container,
    .dynamic-image-gallery[data-columns="4"] .dig-images-container,
    .dynamic-image-gallery[data-columns="5"] .dig-images-container {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .dig-image-wrapper {
        padding-bottom: 100%; /* مربع في الشاشات الصغيرة */
    }
}

@media (max-width: 480px) {
    .dig-filter-tabs {
        flex-direction: column;
        align-items: stretch;
    }
    
    .dig-filter-btn {
        text-align: center;
        margin-bottom: 5px;
    }
    
    .dynamic-image-gallery[data-columns="2"] .dig-images-container,
    .dynamic-image-gallery[data-columns="3"] .dig-images-container,
    .dynamic-image-gallery[data-columns="4"] .dig-images-container,
    .dynamic-image-gallery[data-columns="5"] .dig-images-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* تحسينات الأداء */
.dig-image-item {
    will-change: transform, opacity;
}

.dig-image-wrapper img {
    will-change: transform;
}

/* تأثيرات التحميل */
.dig-image-wrapper img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dig-image-wrapper img[loading="lazy"].loaded {
    opacity: 1;
}

/* تنسيق Lightbox */
.dig-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.dig-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.dig-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.dig-lightbox-image {
    width: 100%;
    height: auto;
    display: block;
}

.dig-lightbox-info {
    padding: 15px;
    background: white;
    text-align: center;
}

.dig-lightbox-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 5px 0;
}

.dig-lightbox-gallery {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.dig-lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.dig-lightbox-close:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* أزرار التنقل في Lightbox */
.dig-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.dig-lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.1);
}

.dig-lightbox-prev {
    left: 15px;
}

.dig-lightbox-next {
    right: 15px;
}

