/* إصلاح المساحات الفارغة في البطاقات */
/* ========================================== */

/* إخفاء الـ placeholder عندما تكون الصورة موجودة */
.post-card .card-img-top:not([src=""]) + .card-img-placeholder,
.activity-card .card-img-top:not([src=""]) + .card-img-placeholder,
.featured-post .featured-img:not([src=""]) + .featured-placeholder {
    display: none !important;
}

/* ضمان أن الصور تظهر بشكل صحيح */
.post-card .card-img-top,
.activity-card .card-img-top,
.featured-post .featured-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    border-radius: 15px 15px 0 0;
}

.featured-post .featured-img {
    height: 100%;
    border-radius: 15px 0 0 15px;
}

/* إصلاح الحاويات */
.post-card .position-relative,
.activity-card .position-relative,
.featured-post .position-relative {
    overflow: hidden;
}

/* تحسين الـ placeholder عندما يظهر */
.card-img-placeholder,
.featured-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #dee2e6;
    border-radius: 15px 15px 0 0;
}

.featured-placeholder {
    border-radius: 15px 0 0 15px;
}

/* إخفاء الـ placeholder عند وجود صورة */
.post-card .card-img-top[src]:not([src=""]) + .card-img-placeholder,
.activity-card .card-img-top[src]:not([src=""]) + .card-img-placeholder,
.featured-post .featured-img[src]:not([src=""]) + .featured-placeholder {
    display: none !important;
}

/* تحسين عرض الصور في الشبكة */
.row .col-lg-4 .card,
.row .col-md-6 .card {
    height: 100%;
}

/* إصلاح مشكلة الارتفاع المتغير */
.post-card,
.activity-card {
    display: flex;
    flex-direction: column;
}

.post-card .card-body,
.activity-card .card-body {
    flex-grow: 1;
}

/* إصلاح placeholders في صفحة المعرض */
.gallery-thumbnail-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    border-radius: 15px 15px 0 0;
}

.carousel-featured-img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    display: block;
}

/* إصلاح placeholders في صفحة الشركاء */
.partner-image-container img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    display: block;
}

.partner-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #dee2e6;
    border-radius: 15px;
}

.flag-placeholder {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* إصلاح placeholders في صفحة من نحن */
.image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #dee2e6;
    border-radius: 15px;
}

/* إخفاء الـ placeholders عندما تكون الصور موجودة */
.gallery-thumbnail-img:not([src=""]) + .card-img-placeholder,
.carousel-featured-img:not([src=""]) + .carousel-placeholder,
.partner-image-container img:not([src=""]) + .partner-placeholder,
.flag-placeholder:not([src=""]) + .flag-placeholder,
.image-placeholder:not([src=""]) + .image-placeholder {
    display: none !important;
}

/* تحسين الاستجابة */
@media (max-width: 768px) {
    .post-card .card-img-top,
    .activity-card .card-img-top {
        height: 200px;
    }
    
    .featured-post .featured-img {
        height: 250px;
        border-radius: 15px 15px 0 0;
    }
    
    .featured-placeholder {
        border-radius: 15px 15px 0 0;
    }
    
    .gallery-thumbnail-img {
        height: 180px;
    }
    
    .carousel-featured-img {
        height: 300px;
    }
    
    .partner-image-container img {
        height: 250px;
    }
    
    .gallery-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .gallery-item img {
        height: 180px;
    }
}

/* تحسين معرض الصور في صفحة النشاط */
.gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.gallery-item {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    background: #f8f9fa;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
    transition: all 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* تأثير التحميل لمعرض الصور */
.gallery-item.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* إصلاح مشكلة z-index للـ Lightbox */
.lightbox-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.9) !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    backdrop-filter: blur(5px) !important;
    animation: lightboxFadeIn 0.3s ease-out !important;
}

.lightbox-image {
    max-width: 90% !important;
    max-height: 90% !important;
    object-fit: contain !important;
    border-radius: 10px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    z-index: 100000 !important;
    position: relative !important;
    animation: lightboxImageZoom 0.3s ease-out !important;
    cursor: default !important;
}

.lightbox-image:hover {
    cursor: default !important;
}

@keyframes lightboxFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes lightboxImageZoom {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ضمان أن الـ Lightbox يظهر فوق الفوتر */
.footer-section {
    z-index: 1 !important;
}

.site-header {
    z-index: 1000 !important;
}

.main-navbar {
    z-index: 1000 !important;
}

/* منع التمرير عند فتح الـ Lightbox */
body.lightbox-open {
    overflow: hidden !important;
}

/* إخفاء العناصر */
.hidden {
    display: none !important;
}

/* تنسيق صورة صفحة من نحن */
.about-image-container {
    position: relative;
    width: 100%;
    height: 400px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.about-main-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: all 0.3s ease;
}

.about-image-container:hover .about-main-image {
    transform: scale(1.05);
}

.about-image-container .image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-radius: 15px;
    border: 2px dashed #dee2e6;
}

.about-image-container .image-placeholder.hidden {
    display: none !important;
}
