/**
 * تحسينات إضافية لعرض الصور
 * الصورة الرئيسية ثابتة كخلفية مع إمكانية وضع عناصر أخرى فوقها
 */

/* تحسينات عامة للصور */
.view .image.custom-view-image {
    /* تحسين الأداء */
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    
    /* تحسين الجودة */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    
    /* تحسين التحميل */
    background-attachment: scroll;
    
    /* تحسين التفاعل - منع النقر على الصورة */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none !important;
    cursor: default !important;
    
    /* تحسين إمكانية الوصول */
    tabindex: 0;
    role: img;
    
    /* تحسين العرض لملء الحاوية بالكامل */
    background-size: cover !important; /* ملء الحاوية بالكامل */
    background-position: center !important;
    background-repeat: no-repeat !important;
    
    /* تحسين إضافي لضمان ظهور الصورة كاملة */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100% !important;
}

/* تحسين إضافي لضمان ظهور الصورة كاملة */
.view .image.custom-view-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    pointer-events: none;
    z-index: 1;
}

/* تحسين عرض الصورة للشاشات عالية الدقة */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .view .image.custom-view-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* تحسين عرض الصورة للشاشات عالية الدقة جداً */
@media (-webkit-min-device-pixel-ratio: 3), (min-resolution: 288dpi) {
    .view .image.custom-view-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* تحسين عرض الصورة للشاشات الصغيرة جداً */
@media (max-width: 320px) {
    .view .image.custom-view-image {
        height: 300px !important; /* الحفاظ على الطول الحالي */
        background-size: cover !important; /* ملء الحاوية بالكامل */
        min-height: 300px !important;
    }
}

/* تحسين عرض الصورة للشاشات الكبيرة جداً */
@media (min-width: 1600px) {
    .view .image.custom-view-image {
        height: 300px !important; /* الحفاظ على الطول الحالي */
        background-size: cover !important; /* ملء الحاوية بالكامل */
        min-height: 300px !important;
    }
}

/* تحسين عرض الصورة في الوضع المظلم */
@media (prefers-color-scheme: dark) {
    .view .image.custom-view-image {
        background-color: #1a1a1a !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    }
}

/* تحسين عرض الصورة في الوضع المضيء */
@media (prefers-color-scheme: light) {
    .view .image.custom-view-image {
        background-color: #f5f5f5 !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    }
}

/* تحسين عرض الصورة عند التحميل البطيء */
.view .image.custom-view-image.slow-loading {
    background-color: #3a3a3a !important;
}

.view .image.custom-view-image.slow-loading::after {
    content: 'جاري تحميل الصورة...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #D98F40;
    font-size: 14px;
    text-align: center;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 20px;
    border-radius: 5px;
    white-space: nowrap;
}

/* تحسين عرض الصورة عند عدم وجود اتصال بالإنترنت */
.view .image.custom-view-image.offline::after {
    content: 'لا يمكن تحميل الصورة - تحقق من اتصالك بالإنترنت';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #e74c3c;
    font-size: 12px;
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 8px 16px;
    border-radius: 4px;
    max-width: 200px;
    line-height: 1.4;
}

/* تحسين عرض الصورة للشاشات المتوسطة */
@media (min-width: 768px) and (max-width: 1199px) {
    .view .image.custom-view-image {
        height: 300px !important; /* الحفاظ على الطول الحالي */
        background-size: cover !important; /* ملء الحاوية بالكامل */
        min-height: 300px !important;
    }
}

/* تحسين عرض الصورة للشاشات الكبيرة */
@media (min-width: 1200px) {
    .view .image.custom-view-image {
        height: 300px !important; /* الحفاظ على الطول الحالي */
        background-size: cover !important; /* ملء الحاوية بالكامل */
        min-height: 300px !important;
    }
}

/* تحسين عرض الصورة للشاشات الصغيرة */
@media (max-width: 768px) {
    .view .image.custom-view-image {
        height: 300px !important; /* الحفاظ على الطول الحالي */
        background-size: cover !important; /* ملء الحاوية بالكامل */
        min-height: 300px !important;
    }
}

@media (max-width: 480px) {
    .view .image.custom-view-image {
        height: 300px !important; /* الحفاظ على الطول الحالي */
        background-size: cover !important; /* ملء الحاوية بالكامل */
        min-height: 300px !important;
    }
}

/* مؤشر تحميل للصورة */
.view .image.custom-view-image::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #D98F40;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.view .image.custom-view-image.loading::before {
    opacity: 1;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* تحسين عرض الصورة عند عدم وجود صورة */
.view .image.custom-view-image:empty::after {
    content: 'لا توجد صورة متاحة';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #888;
    font-size: 16px;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 5px;
}

/* تحسين عرض الصورة عند وجود خطأ في التحميل */
.view .image.custom-view-image.error::after {
    content: 'خطأ في تحميل الصورة';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #e74c3c;
    font-size: 14px;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 16px;
    border-radius: 4px;
}

/* تحسينات إضافية للصور في المعرض */
.gallery .thumb {
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}

.gallery .thumb:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

/* تحسين عرض الصور للشاشات المختلفة */
@media (max-width: 480px) {
    .gallery .thumb {
        height: 80px !important;
        width: 160px !important;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .gallery .thumb {
        height: 90px !important;
        width: 180px !important;
    }
}

@media (min-width: 769px) {
    .gallery .thumb {
        height: 100px !important;
        width: 200px !important;
    }
}

/* تحسين إمكانية الوصول */
.view .image.custom-view-image[aria-label] {
    position: relative;
}

.view .image.custom-view-image[aria-label]::after {
    content: attr(aria-label);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    font-size: 12px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.view .image.custom-view-image[aria-label]:hover::after {
    opacity: 1;
}

/* تحسين الأداء */
.view .image.custom-view-image {
    contain: layout style paint;
}

/* تحسين التحميل التدريجي */
.view .image.custom-view-image {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.view .image.custom-view-image.loaded {
    opacity: 1;
}

/* تحسين عرض الصورة للشاشات المطبوعة */
@media print {
    .view .image.custom-view-image {
        background-size: contain !important;
        background-position: center !important;
        page-break-inside: avoid;
    }
}

/* تنسيقات للعناصر التفاعلية فوق الصورة */
.interactive-element {
    position: absolute;
    z-index: 10;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.details-btn {
    background: rgba(217, 143, 64, 0.9) !important;
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 5px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: bold !important;
    bottom: 20px !important;
    right: 20px !important;
}

.details-btn:hover {
    background: rgba(217, 143, 64, 1) !important;
    transform: scale(1.05) !important;
}

/* طبقة شفافة فوق الصورة لتحسين قراءة النص */
.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.3) 100%);
    pointer-events: none;
    z-index: 1;
}

/* تنسيقات إضافية للعناصر فوق الصورة */
.view .image.custom-view-image .overlay-content {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    z-index: 5;
    pointer-events: auto;
}

/* تنسيقات للنصوص فوق الصورة */
.view .image.custom-view-image .overlay-text {
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    font-weight: bold;
    margin-bottom: 10px;
}

/* تنسيقات للأزرار فوق الصورة */
.view .image.custom-view-image .overlay-button {
    background: rgba(217, 143, 64, 0.9);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.3s ease;
    margin: 5px;
}

.view .image.custom-view-image .overlay-button:hover {
    background: rgba(217, 143, 64, 1);
    transform: scale(1.05);
}

/* تنسيقات للشاشات الصغيرة */
@media (max-width: 768px) {
    .details-btn {
        bottom: 10px !important;
        right: 10px !important;
        padding: 8px 16px !important;
        font-size: 12px !important;
    }
    
    .view .image.custom-view-image .overlay-content {
        top: 10px;
        left: 10px;
        right: 10px;
        bottom: 10px;
    }
} 