/*!
 * ملف CSS محسن للأداء والـ SEO
 * يحتوي على تحسينات الخطوط والتنسيق
 */

/* خط Droid Arabic Kufi محسن */
@font-face {
    font-family: 'Droid Arabic Kufi';
    src: url('../font/Droid.Arabic.Kufi_DownloadSoftware.iR_.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0600-06FF, U+FE70-FEFF;
}

/* خط احتياطي للأحرف الإنجليزية */
@font-face {
    font-family: 'Droid Arabic Kufi Fallback';
    src: local('Arial'), local('Helvetica'), local('sans-serif');
    font-display: swap;
    unicode-range: U+0000-007F;
}

/* تحسين الأداء العام */
* {
    box-sizing: border-box;
}

html {
    font-size: 18px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-size: 1rem;
    line-height: 1.7;
    font-family: 'Droid Arabic Kufi', 'Droid Arabic Kufi Fallback', Arial, sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-feature-settings: "kern" 1;
    font-feature-settings: "kern" 1;
}

/* تحسين العناوين */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Droid Arabic Kufi', Arial, sans-serif;
    line-height: 1.3;
    margin: 0 0 1rem 0;
}

h1 { font-size: 2.2rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.3rem; }
h4, h5, h6 { font-size: 1.1rem; }

/* تحسين النصوص */
p, span, div, a, ul, ol, li, table, th, td, label, 
strong, em, b, i, blockquote, pre, code, 
input, textarea, button, select {
    font-family: 'Droid Arabic Kufi', Arial, sans-serif !important;
    font-size: 1rem;
}

/* استثناء أيقونات Font Awesome */
.fa, .fas, .far, .fal, .fab, [class*="fa-"] {
    font-family: 'Font Awesome 5 Free', 'Font Awesome 5 Brands', 'FontAwesome', sans-serif !important;
    font-weight: 900;
}

/* تحسين الصور */
img {
    max-width: 100%;
    height: auto;
    border-style: none;
    vertical-align: middle;
}

img[loading="lazy"] {
    transition: opacity 0.3s ease;
}

img[loading="lazy"]:not(.loaded) {
    opacity: 0.7;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* تحسين الأزرار */
button, .btn {
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

button:focus-visible, .btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* تحسين الروابط */
a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* تحسين للجوال */
@media (max-width: 600px) {
    html { font-size: 15px; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.2rem; }
    h3 { font-size: 1.05rem; }
    h4, h5, h6 { font-size: 1rem; }
    
    p, span, div, a, ul, ol, li, table, th, td, label, 
    strong, em, b, i, blockquote, pre, code, 
    input, textarea, button, select {
        font-size: 0.97rem;
    }
}

/* تحسين الأداء للـ animations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* تحسين للطباعة */
@media print {
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a, a:visited {
        text-decoration: underline;
    }
    
    img {
        max-width: 100% !important;
    }
    
    @page {
        margin: 0.5cm;
    }
}

/* تحسين للوحة المفاتيح */
.keyboard-navigation *:focus {
    outline: 2px solid #2563eb !important;
    outline-offset: 2px !important;
}

/* تحسين تباين الألوان */
.high-contrast {
    filter: contrast(1.2);
}

/* تحسين loading states */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* تحسين الشبكة */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 768px) {
    .container {
        padding: 0 2rem;
    }
}

/* تحسين المسافات */
.section-spacing {
    padding: 2rem 0;
}

@media (min-width: 768px) {
    .section-spacing {
        padding: 4rem 0;
    }
}

/* تحسين الجداول للجوال */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* تحسين النماذج */
input, textarea, select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* تحسين إمكانية الوصول للنماذج */
label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

/* تحسين رسائل الخطأ */
.error-message {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* تحسين رسائل النجاح */
.success-message {
    color: #16a34a;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* تحسين الـ modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

/* تحسين الإعلانات */
.banner-container {
    position: relative;
    overflow: hidden;
}

.banner-container img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* تحسين أداء CSS Grid و Flexbox */
.grid {
    display: grid;
    gap: 1rem;
}

.flex {
    display: flex;
    gap: 1rem;
}

/* تحسين للشاشات الكبيرة */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}