/* CSS محسن للصور */

/* تحسين تحميل الصور */
img {
    max-width: 100%;
    height: auto;
    display: block;
    opacity: 1; /* تأكد من ظهور الصور بشكل افتراضي */
}

/* تأثيرات تحميل الصور */
img[loading="lazy"] {
    opacity: 1; /* تغيير إلى 1 لضمان الظهور */
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* إصلاح مشكلة عدم ظهور الصور */
.article-images img {
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
}

/* استايل placeholder للصور أثناء التحميل */
.image-placeholder {
    background: linear-gradient(45deg, #f0f0f0 25%, #e0e0e0 25%, #e0e0e0 50%, #f0f0f0 50%, #f0f0f0 75%, #e0e0e0 75%);
    background-size: 20px 20px;
    animation: loading 1s linear infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.9rem;
}

@keyframes loading {
    0% { background-position: 0 0; }
    100% { background-position: 20px 20px; }
}

/* تحسين عرض الصور في المقالات */
.article-images {
    position: relative;
}

.article-images img {
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
}

/* تحسين lightbox */
.lightbox {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.lightbox img {
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* تحسين الصور في الصفحة الرئيسية */
.blog-card .blog-image {
    position: relative;
    background: #f8f9fa;
}

.blog-card .blog-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1), rgba(44, 62, 80, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.blog-card:hover .blog-image::before {
    opacity: 1;
}

/* دعم الشاشات عالية الكثافة */
@media 
  (-webkit-min-device-pixel-ratio: 2), 
  (min-resolution: 192dpi) {
    
    .article-images img,
    .blog-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* دعم الطباعة */
@media print {
    .article-images {
        display: block !important;
        grid-template-columns: none !important;
    }
    
    .article-images img {
        max-width: 100%;
        height: auto !important;
        object-fit: contain !important;
        page-break-inside: avoid;
        margin-bottom: 1rem;
    }
}

/* تحسين إمكانية الوصول */
img:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* تحسين أداء التمرير */
.article-images,
.blog-image {
    transform: translateZ(0);
    will-change: transform;
}

/* التعامل مع الأخطاء في تحميل الصور */
img::before {
    content: '🖼️ فشل في تحميل الصورة';
    display: block;
    text-align: center;
    padding: 2rem;
    background: #f8f9fa;
    border: 2px dashed #ddd;
    color: #999;
    font-size: 0.9rem;
}

/* تحسين الصور للشاشات الصغيرة */
@media (max-width: 480px) {
    .article-images img {
        height: 150px !important;
    }
    
    .blog-image {
        height: 150px !important;
    }
}