/* 
 * ملف تحسينات التوافق مع المتصفحات لموقع مهام لتقنية المعلومات
 * تم إنشاؤه بتاريخ: 27 مايو 2025
 */

/* ===== تحسينات توافق المتصفحات ===== */

/* تحسينات لمتصفح Safari */
@supports (-webkit-overflow-scrolling: touch) {
    /* تحسينات خاصة بأجهزة iOS */
    input, textarea {
        -webkit-appearance: none;
        border-radius: var(--border-radius);
    }
    
    /* تصحيح مشكلة الارتفاع 100vh في Safari على iOS */
    .full-height {
        height: -webkit-fill-available;
    }
    
    /* تحسين تأثيرات الحركة */
    .fade-in, .slide-up, .slide-right, .slide-left, .zoom-in {
        -webkit-backface-visibility: hidden;
    }
}

/* تحسينات لمتصفح Firefox */
@-moz-document url-prefix() {
    /* تحسين عرض الخطوط */
    body {
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* تحسين تمرير الصفحة */
    html {
        scrollbar-width: thin;
        scrollbar-color: var(--primary-color) #f1f1f1;
    }
}

/* تحسينات لمتصفح Edge */
@supports (-ms-ime-align: auto) {
    /* تصحيح مشكلة العناصر المرنة */
    .flex-container {
        display: -ms-flexbox;
        -ms-flex-wrap: wrap;
    }
    
    /* تحسين التدرجات اللونية */
    .bg-gradient {
        background: -ms-linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    }
}

/* تحسينات لمتصفح Internet Explorer */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    /* تصحيح مشكلة العناصر المرنة */
    .flex-container {
        display: -ms-flexbox;
        -ms-flex-wrap: wrap;
    }
    
    /* تصحيح مشكلة الشبكة */
    .grid-container {
        display: -ms-grid;
    }
    
    /* تحسين التدرجات اللونية */
    .bg-gradient {
        background: -ms-linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    }
    
    /* تصحيح مشكلة النص المتدرج */
    .text-gradient {
        background: none;
        color: var(--primary-color);
    }
}

/* ===== تحسينات الطباعة ===== */
@media print {
    /* إخفاء العناصر غير الضرورية للطباعة */
    .header, .footer, .scroll-top-btn, .search-box, .social-links {
        display: none !important;
    }
    
    /* تحسين عرض المحتوى */
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }
    
    /* تحسين عرض الروابط */
    a {
        text-decoration: none;
        color: #000;
    }
    
    /* إظهار روابط URL بعد النص */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 90%;
    }
    
    /* عدم إظهار URL للروابط الداخلية والصور */
    a[href^="#"]:after,
    a[href^="javascript:"]:after,
    a.no-print-url:after {
        content: "";
    }
    
    /* تحسين عرض الصور */
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
    
    /* تحسين فواصل الصفحات */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        page-break-inside: avoid;
    }
    
    p, blockquote, ul, ol, dl, table {
        page-break-inside: avoid;
    }
    
    /* تحسين هوامش الطباعة */
    @page {
        margin: 2cm;
    }
}

/* ===== تحسينات الأداء ===== */

/* تحسين تحميل الصور */
img.lazy {
    opacity: 0;
    transition: opacity 0.5s ease;
}

img.lazy.loaded {
    opacity: 1;
}

/* تحسين تحميل الخطوط */
.fonts-loaded body {
    opacity: 1;
}

/* تحسين تحميل الصفحة */
.page-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loading.loaded {
    opacity: 0;
    visibility: hidden;
}

/* ===== تحسينات إمكانية الوصول ===== */

/* تحسين التركيز */
:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* تحسين التباين */
.high-contrast {
    --primary-color: #0056b3;
    --secondary-color: #004494;
    --accent-color: #ff5252;
    --dark-color: #000000;
    --light-color: #ffffff;
    --gray-color: #444444;
}

/* تحسين قراءة النص */
.readable-text {
    font-size: 1.1em;
    line-height: 1.8;
    letter-spacing: 0.01em;
}

/* تحسين التنقل بلوحة المفاتيح */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background-color: var(--primary-color);
    color: #ffffff;
    padding: 8px 16px;
    z-index: 1001;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
}

/* ===== تحسينات الأمان ===== */

/* منع تحديد النص في بعض العناصر */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* منع سحب الصور */
.no-drag {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* ===== تحسينات الاتجاه من اليمين إلى اليسار ===== */
[dir="rtl"] {
    /* تصحيح اتجاه الأيقونات */
    .fa-arrow-right:before {
        content: "\f060"; /* رمز السهم لليسار */
    }
    
    .fa-arrow-left:before {
        content: "\f061"; /* رمز السهم لليمين */
    }
    
    /* تصحيح اتجاه التدرجات */
    .bg-gradient {
        background: linear-gradient(-135deg, var(--primary-color), var(--secondary-color));
    }
    
    /* تصحيح اتجاه الظلال */
    .text-shadow {
        text-shadow: -2px 2px 4px rgba(0, 0, 0, 0.2);
    }
    
    /* تصحيح اتجاه الحركات */
    .slide-right {
        transform: translateX(40px);
    }
    
    .slide-right.animated {
        transform: translateX(0);
    }
    
    .slide-left {
        transform: translateX(-40px);
    }
    
    .slide-left.animated {
        transform: translateX(0);
    }
}

/* ===== تحسينات الأجهزة ذات الشاشات عالية الدقة ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* تحسين حجم الخط */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* تحسين حدود الصور */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ===== تحسينات وضع الظلام ===== */
@media (prefers-color-scheme: dark) {
    .dark-mode-support {
        --primary-color: #2196f3;
        --secondary-color: #42a5f5;
        --accent-color: #ff7b7b;
        --dark-color: #f8f9fa;
        --light-color: #121212;
        --gray-color: #aaaaaa;
        
        background-color: #121212;
        color: #f8f9fa;
    }
    
    .dark-mode-support a {
        color: #42a5f5;
    }
    
    .dark-mode-support .card,
    .dark-mode-support .service-card,
    .dark-mode-support .project-card,
    .dark-mode-support .testimonials-slider {
        background-color: #1e1e1e;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    }
}

/* ===== تحسينات تقليل الحركة ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .fade-in, .slide-up, .slide-right, .slide-left, .zoom-in {
        opacity: 1;
        transform: none;
        transition: none;
    }
    
    .animated {
        animation: none !important;
    }
}
