/* Global Font Configuration */

/* FontAwesome Icons - Highest priority */
.fa, .fas, .far, .fab, .fal, .fad,
[class^="fa-"], [class*=" fa-"],
i[class^="fa"], i[class*=" fa"] {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", "FontAwesome" !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Specific font weights for different FA styles */
.fas, i.fas { font-weight: 900 !important; }
.far, i.far { font-weight: 400 !important; }
.fab, i.fab { 
    font-weight: 400 !important; 
    font-family: "Font Awesome 6 Brands", "Font Awesome 5 Brands" !important;
}
.fal, i.fal { font-weight: 300 !important; }
.fad, i.fad { font-weight: 900 !important; }

/* Default Arial font for everything else */
body, html {
    font-family: Arial, sans-serif;
}

h1, h2, h3, h4, h5, h6, p, span, div, input, textarea, button, .btn,
a, label, td, th, li, ul, ol {
    font-family: Arial, sans-serif !important;
}

/* RTL specific Cairo font for Arabic content */
html[dir="rtl"] body,
html[dir="rtl"] h1, 
html[dir="rtl"] h2, 
html[dir="rtl"] h3, 
html[dir="rtl"] h4, 
html[dir="rtl"] h5, 
html[dir="rtl"] h6, 
html[dir="rtl"] p, 
html[dir="rtl"] span, 
html[dir="rtl"] div, 
html[dir="rtl"] input, 
html[dir="rtl"] textarea, 
html[dir="rtl"] button, 
html[dir="rtl"] .btn,
html[dir="rtl"] a,
html[dir="rtl"] label,
html[dir="rtl"] td,
html[dir="rtl"] th,
html[dir="rtl"] li {
    font-family: 'Cairo', Arial, sans-serif !important;
}

/* FontAwesome must stay as FontAwesome even in RTL */
html[dir="rtl"] .fa, 
html[dir="rtl"] .fas, 
html[dir="rtl"] .far, 
html[dir="rtl"] .fab, 
html[dir="rtl"] .fal, 
html[dir="rtl"] .fad, 
html[dir="rtl"] [class^="fa-"], 
html[dir="rtl"] [class*=" fa-"],
html[dir="rtl"] i[class^="fa"], 
html[dir="rtl"] i[class*=" fa"] {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", "Font Awesome 6 Brands", "FontAwesome" !important;
}

/* Font Awesome icons should always use FA font, even in RTL */
html[dir="rtl"] .fa, 
html[dir="rtl"] .fas, 
html[dir="rtl"] .far, 
html[dir="rtl"] .fab, 
html[dir="rtl"] .fal, 
html[dir="rtl"] .fad, 
html[dir="rtl"] [class*="fa-"] {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", "Font Awesome 5 Free", "Font Awesome 5 Pro", "FontAwesome" !important;
}

/* Additional FontAwesome protection */
i[class^="fa"], 
i[class*=" fa"], 
i.fas, 
i.far, 
i.fab, 
i.fal, 
i.fad {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", "Font Awesome 5 Free", "Font Awesome 5 Pro", "FontAwesome" !important;
    font-weight: 900; /* For solid icons */
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
}

/* RTL specific Cairo font for Arabic content (excluding Font Awesome) */
html[dir="rtl"] *:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]),
html[dir="rtl"] body,
html[dir="rtl"] h1:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] h2:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] h3:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] h4:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] h5:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] h6:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] p:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] span:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] div:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] input:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] textarea:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] button:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]), 
html[dir="rtl"] .btn:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not(.fad):not([class*="fa-"]) {
    font-family: 'Cairo', Arial, sans-serif !important;
}

/* Language specific letter spacing */
html[lang="ar"] {
    --font-letter-spacing: -0.5px;
}

html[lang="en"] {
    --font-letter-spacing: normal;
}

html[dir="rtl"] * {
    letter-spacing: -0.5px;
}

html[dir="ltr"] * {
    letter-spacing: normal;
}
