/**
 * ========================================================================
 * Global El Messiri Font Enforcement
 * ========================================================================
 * 
 * هذا الملف يضمن تطبيق خط El Messiri على كامل المشروع بشكل قوي ومستقر
 * This file ensures El Messiri font is applied project-wide with high priority
 * 
 * يجب تحميله في آخر قائمة CSS files لضمان الأولوية
 * Must be loaded last in CSS files list to ensure priority
 */

/* ========================================================================
   0. ICON FONTS PRESERVATION - MUST BE FIRST!
   ======================================================================== */

/* Font Awesome icons - HIGHEST PRIORITY */
i, i *,
i::before, i::after,
[class*="fa-"], [class*="fa-"] *,
[class*="fa-"]::before, [class*="fa-"]::after,
.fa, .fa *, .fa::before, .fa::after,
.fab, .fab *, .fab::before, .fab::after,
.fal, .fal *, .fal::before, .fal::after,
.far, .far *, .far::before, .far::after,
.fas, .fas *, .fas::before, .fas::after,
.fad, .fad *, .fad::before, .fad::after,
.fat, .fat *, .fat::before, .fat::after,
[class^="fa-"], [class^="fa-"] *,
[class^="fa-"]::before, [class^="fa-"]::after,
[class*=" fa-"], [class*=" fa-"] *,
[class*=" fa-"]::before, [class*=" fa-"]::after,
[class*="icon-"], [class*="icon-"] *,
[class*="icon-"]::before, [class*="icon-"]::after {
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Pro', 'Font Awesome 6 Brands', 'Font Awesome 5 Free', 'Font Awesome 5 Pro', 'FontAwesome' !important;
    font-weight: 900 !important;
}

/* Specific Font Awesome solid icons */
.fas, .fas::before {
    font-family: 'Font Awesome 6 Free' !important;
    font-weight: 900 !important;
}

/* Specific Font Awesome regular icons */
.far, .far::before {
    font-family: 'Font Awesome 6 Free' !important;
    font-weight: 400 !important;
}

/* Specific Font Awesome brands */
.fab, .fab::before {
    font-family: 'Font Awesome 6 Brands' !important;
    font-weight: 400 !important;
}

/* Material Icons if used */
.material-icons,
.material-icons::before,
.material-icons-outlined,
.material-icons-round,
.material-icons-sharp {
    font-family: 'Material Icons' !important;
}

/* Monospace for code - MUST BE EARLY */
code, code *,
kbd, kbd *,
samp, samp *,
pre, pre *,
.code, .code *,
textarea.code-input {
    font-family: 'Courier New', Courier, monospace !important;
}


/* ========================================================================
   1. GLOBAL FONT OVERRIDE - MAXIMUM PRIORITY
   ======================================================================== */

/* Apply to all elements EXCEPT icons and code */
*:not(i):not([class*="fa-"]):not(.fa):not(.fab):not(.fal):not(.far):not(.fas):not(.fad):not(.fat):not(code):not(kbd):not(samp):not(pre),
*:not(i):not([class*="fa-"]):not(.fa):not(.fab):not(.fal):not(.far):not(.fas):not(.fad):not(.fat):not(code):not(kbd):not(samp):not(pre)::before,
*:not(i):not([class*="fa-"]):not(.fa):not(.fab):not(.fal):not(.far):not(.fas):not(.fad):not(.fat):not(code):not(kbd):not(samp):not(pre)::after {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* HTML and Body */
html {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

body {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* All descendants */
html *,
body * {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* Headings */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* Tables */
table, th, td {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* Lists */
ul, ol, li, dl, dt, dd {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* Bootstrap specific classes */
.navbar, .nav, .navbar-brand, .nav-link,
.btn:not([class*="fa-"]), 
.form-control, .form-label, .form-select,
.card, .card-header, .card-body, .card-footer, .card-title,
.modal, .modal-header, .modal-body, .modal-footer,
.alert, .badge, .breadcrumb,
.dropdown, .dropdown-menu, .dropdown-item {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* Admin specific classes */
.admin-body,
.admin-sidebar,
.admin-topbar,
.admin-content,
.content-card,
.stat-card,
.page-header {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* Admin body children (but NOT icons) */
.admin-body *:not(i):not([class*="fa-"]):not(.fa):not(.fab):not(.far):not(.fas):not(code):not(kbd):not(pre) {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* Auth/Login specific */
.login-container,
.login-card,
.login-header,
.login-title,
.welcome-section,
.welcome-title {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}


/* ========================================================================
   2. TEXT ELEMENTS - EXPLICIT EL MESSIRI
   ======================================================================== */

/* Text elements explicitly */
p, p *,
span:not([class*="fa-"]):not(.fa):not(.fab):not(.far):not(.fas),
div:not([class*="fa-"]):not(.fa):not(.fab):not(.far):not(.fas),
a:not([class*="fa-"]):not(.fa):not(.fab):not(.far):not(.fas),
button:not([class*="fa-"]):not(.fa):not(.fab):not(.far):not(.fas),
input, textarea, select, label {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}


/* ========================================================================
   3. ADDITIONAL MONOSPACE PRESERVATION
   ======================================================================== */

/* Code blocks - reaffirm */
kbd,
samp,
pre,
.code,
.code-block,
textarea.code-input,
.monospace {
    font-family: 'Courier New', Courier, 'Lucida Console', Monaco, monospace !important;
}


/* ========================================================================
   4. FONT LOADING & RENDERING OPTIMIZATION
   ======================================================================== */

/* Ensure smooth font rendering */
html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Font display optimization */
@font-face {
    font-family: 'El Messiri';
    font-display: swap;
}


/* ========================================================================
   5. RTL/LTR SUPPORT
   ======================================================================== */

/* RTL specific font settings */
[dir="rtl"],
[dir="rtl"] *,
html[dir="rtl"],
html[dir="rtl"] * {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* LTR specific font settings */
[dir="ltr"],
[dir="ltr"] *,
html[dir="ltr"],
html[dir="ltr"] * {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}


/* ========================================================================
   6. DARK MODE FONT CONSISTENCY
   ======================================================================== */

/* Ensure font stays consistent in dark mode */
[data-theme="dark"],
[data-theme="dark"] *,
[data-bs-theme="dark"],
[data-bs-theme="dark"] * {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}


/* ========================================================================
   7. SPECIAL CASES & OVERRIDES
   ======================================================================== */

/* Livewire components */
[wire\\:id],
[wire\\:id] * {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* Vue/React components if used */
[data-v-],
[data-v-] * {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* Ensure input placeholders use El Messiri */
::placeholder,
::-webkit-input-placeholder,
::-moz-placeholder,
:-ms-input-placeholder,
:-moz-placeholder {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* Select options */
option,
optgroup {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}


/* ========================================================================
   8. PRINT STYLES
   ======================================================================== */

@media print {
    /* Ensure font is applied in print as well */
    *,
    *::before,
    *::after {
        font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    }
}


/* ========================================================================
   9. ACCESSIBILITY & SCREEN READERS
   ======================================================================== */

/* Ensure assistive technology text uses the font */
.sr-only,
.visually-hidden,
[aria-label],
[aria-describedby] {
    font-family: 'El Messiri', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}


/* ========================================================================
   10. DEBUGGING (Comment out in production)
   ======================================================================== */

/* Uncomment to see which elements are NOT using El Messiri
*:not(i):not([class*="fa-"]):not(code):not(pre):not(kbd):not(samp) {
    border: 1px solid red !important;
    outline: 2px dashed blue !important;
}
*/
