/* =================================================================== */
/* POLICES ARABES PERSONNALISÉES - SOLUTION COMPLÈTE */
/* =================================================================== */

/* Sakkal Majalla est une police système Windows — pas de @font-face nécessaire.
   Le navigateur l'utilise directement si elle est installée sur le système. */

/* Police Samir Khouaja Maghribi — chargée depuis les fichiers locaux */
@font-face {
    font-family: 'Samir Khouaja Maghribi';
    src: url('../fonts/SamirKhouajaMaghribi.woff2') format('woff2'),
         url('../fonts/SamirKhouajaMaghribi.woff') format('woff'),
         url('../fonts/SamirKhouajaMaghribi.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Samir Khouaja Maghribi';
    src: url('../fonts/SamirKhouajaMaghribi-Bold.woff2') format('woff2'),
         url('../fonts/SamirKhouajaMaghribi-Bold.woff') format('woff'),
         url('../fonts/SamirKhouajaMaghribi-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

/* Police alternative Amiri (Google Fonts) */
@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* Police alternative Scheherazade New (Google Fonts) */
@import url('https://fonts.googleapis.com/css2?family=Scheherazade+New:wght@400;700&display=swap');

/* Police alternative Noto Naskh Arabic (Google Fonts) */
@import url('https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;500;600;700&display=swap');

/* Police alternative Cairo (Google Fonts) - moderne et lisible */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200;300;400;500;600;700;800;900&display=swap');

/* Police alternative IBM Plex Sans Arabic (Google Fonts) */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@100;200;300;400;500;600;700&display=swap');

/* =================================================================== */
/* CLASSES UTILITAIRES POUR LES POLICES ARABES */
/* =================================================================== */

/* Classe principale pour texte arabe standard */
.arabic-text {
    font-family: 'Sakkal Majalla', 'Cairo', 'IBM Plex Sans Arabic', 'Amiri', 'Scheherazade New', 'Noto Naskh Arabic', 'Traditional Arabic', 'Arabic Typesetting', 'Tahoma', 'Arial Unicode MS', serif !important;
    direction: rtl;
    text-align: right;
    line-height: 1.6;
}

/* Classe pour titre arabe */
.arabic-title {
    font-family: 'Sakkal Majalla', 'Amiri', 'Scheherazade New', 'Noto Naskh Arabic', 'Cairo', 'Traditional Arabic', 'Arabic Typesetting', serif !important;
    direction: rtl;
    text-align: right;
    font-weight: 700;
    line-height: 1.4;
}

/* Classe pour texte arabe moderne (sans-serif) */
.arabic-modern {
    font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Tahoma', 'Arial Unicode MS', 'Segoe UI', sans-serif !important;
    direction: rtl;
    text-align: right;
    line-height: 1.5;
}

/* Classe pour texte arabe traditionnel */
.arabic-traditional {
    font-family: 'Sakkal Majalla', 'Amiri', 'Scheherazade New', 'Noto Naskh Arabic', 'Traditional Arabic', 'Arabic Typesetting', serif !important;
    direction: rtl;
    text-align: right;
    line-height: 1.7;
}

/* =================================================================== */
/* STYLES SPÉCIFIQUES POUR L'APPLICATION */
/* =================================================================== */

/* Section "Qui sommes-nous" - Texte principal */
html[dir="rtl"] .about-description,
.about-description.arabic-text {
    font-family: 'Sakkal Majalla', 'Cairo', 'Amiri', 'Scheherazade New', 'Noto Naskh Arabic', 'Traditional Arabic', 'Arabic Typesetting', 'Tahoma', 'Arial Unicode MS', serif !important;
    font-size: 2rem !important;
    color: #1e40af !important;
    line-height: 1.9 !important;
    margin-bottom: 0 !important;
    text-align: justify !important;
    text-shadow: 0 1px 3px rgba(30, 64, 175, 0.1) !important;
    font-weight: 400 !important;
    direction: rtl;
    unicode-bidi: embed;
}

/* NOUVELLE CLASSE POUR FORCER LA POLICE SUR LE FRANÇAIS */
.maghribi-font {
    font-family: 'Sakkal Majalla', 'Poppins', 'Inter', 'Cairo', 'Amiri', 'Scheherazade New', 'Noto Naskh Arabic', serif !important;
    font-weight: 400 !important;
    font-display: swap;
}

/* Style spécifique pour la version française qui utilise la police arabe */
html[lang="fr"] .about-description.maghribi-font,
.about-description.maghribi-font {
    font-family: 'Sakkal Majalla', 'Poppins', 'Inter', system-ui, -apple-system, "Segoe UI", Arial, sans-serif !important;
    font-size: 2rem !important;
    color: #1e40af !important;
    line-height: 1.9 !important;
    margin-bottom: 0 !important;
    text-align: justify !important;
    text-shadow: 0 1px 3px rgba(30, 64, 175, 0.1) !important;
    font-weight: 600 !important;
    direction: ltr;
    unicode-bidi: normal;
}

/* =================================================================== */
/* RÈGLE CSS MIXTE AUTOMATIQUE - SOLUTION INTELLIGENTE */
/* =================================================================== */

/* APPLICATION AUTOMATIQUE SELON LA LANGUE - SANS CLASSES MANUELLES */
.about-description {
    /* Propriétés communes */
    font-size: 2rem !important;
    color: #1e40af !important;
    line-height: 1.9 !important;
    margin-bottom: 0 !important;
    text-shadow: 0 1px 3px rgba(30, 64, 175, 0.1) !important;
    font-weight: 600 !important;
    text-align: justify !important;
}

/* Pour les pages en FRANÇAIS - Police mixte intelligente */
html[lang="fr"] .about-description,
html:not([lang="ar"]):not([dir="rtl"]) .about-description {
    /* Tenter Sakkal Majalla d'abord, puis fallback vers polices latines */
    font-family: 'Sakkal Majalla', 'Poppins', 'Inter', 'Segoe UI', Arial, sans-serif !important;
    direction: ltr !important;
    text-align: justify !important;
    unicode-bidi: normal !important;
}

/* Pour les pages en ARABE - Police arabe optimisée */
html[lang="ar"] .about-description,
html[dir="rtl"] .about-description,
.about-description[dir="rtl"] {
    /* Police arabe avec fallbacks arabes */
    font-family: 'Sakkal Majalla', 'Cairo', 'Amiri', 'Scheherazade New', 'Noto Naskh Arabic', 'Traditional Arabic', 'Arabic Typesetting', 'Tahoma', serif !important;
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: embed !important;
    font-size: 2.1rem !important;
    line-height: 1.95 !important;
}

/* SOLUTION DE SECOURS - Si Sakkal Majalla n'a pas de glyphes latins */
@supports not (font-variation-settings: normal) {
    /* Navigateurs anciens ou si la police échoue */
    html[lang="fr"] .about-description {
        font-family: 'Poppins', 'Inter', 'Segoe UI', Arial, sans-serif !important;
    }
}

/* Navbar en arabe */
html[lang="ar"] .navbar-brand,
html[dir="rtl"] .navbar-brand {
    font-family: 'Sakkal Majalla', 'Cairo', 'IBM Plex Sans Arabic', 'Amiri', 'Traditional Arabic', serif !important;
    font-weight: 700 !important;
    font-size: 1.5rem !important;
}

html[lang="ar"] .nav-link,
html[dir="rtl"] .nav-link {
    font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Tahoma', 'Arial Unicode MS', sans-serif !important;
    font-size: 1.1rem !important;
    font-weight: 500 !important;
}

/* Titres principaux en arabe */
html[lang="ar"] .main-title,
html[dir="rtl"] .main-title {
    font-family: 'Sakkal Majalla', 'Amiri', 'Scheherazade New', 'Cairo', 'Traditional Arabic', serif !important;
    font-weight: 700 !important;
}

html[lang="ar"] .main-title .title-blue,
html[dir="rtl"] .main-title .title-blue {
    font-family: 'Sakkal Majalla', 'Amiri', 'Cairo', 'Traditional Arabic', serif !important;
    color: #3498db !important;
    -webkit-text-fill-color: #3498db !important;
    background: none !important;
    text-shadow: 0 2px 4px rgba(52, 152, 219, 0.3) !important;
}

html[lang="ar"] .main-title .highlight-green,
html[dir="rtl"] .main-title .highlight-green {
    font-family: 'Sakkal Majalla', 'Amiri', 'Cairo', 'Traditional Arabic', serif !important;
    color: #3498db !important;
    -webkit-text-fill-color: #3498db !important;
    background: none !important;
    text-shadow: 0 2px 4px rgba(52, 152, 219, 0.3) !important;
}

/* Sous-titres en arabe */
html[lang="ar"] .main-subtitle,
html[dir="rtl"] .main-subtitle,
html[lang="ar"] .lead,
html[dir="rtl"] .lead {
    font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Noto Naskh Arabic', 'Tahoma', sans-serif !important;
    color: #fdfdf9 !important;
    text-shadow: 0 2px 4px rgba(52, 152, 219, 0.3) !important;
}

/* Formulaires en arabe */
html[lang="ar"] .form-control,
html[lang="ar"] .form-select,
html[dir="rtl"] .form-control,
html[dir="rtl"] .form-select {
    font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Tahoma', 'Arial Unicode MS', sans-serif !important;
    font-size: 1rem !important;
    direction: rtl;
    text-align: right;
}

html[lang="ar"] label,
html[dir="rtl"] label {
    font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Tahoma', sans-serif !important;
    font-weight: 500 !important;
    direction: rtl;
    text-align: right;
}

/* Boutons en arabe */
html[lang="ar"] .btn,
html[dir="rtl"] .btn {
    font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Tahoma', sans-serif !important;
    font-weight: 600 !important;
}

/* Cards et contenus généraux */
html[lang="ar"] .card-title,
html[dir="rtl"] .card-title {
    font-family: 'Cairo', 'Amiri', 'Noto Naskh Arabic', serif !important;
    font-weight: 700 !important;
}

html[lang="ar"] .card-text,
html[dir="rtl"] .card-text {
    font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Tahoma', sans-serif !important;
    line-height: 1.6 !important;
}

/* Tous les titres h1-h6 en arabe */
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, 
html[lang="ar"] h4, html[lang="ar"] h5, html[lang="ar"] h6,
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3, 
html[dir="rtl"] h4, html[dir="rtl"] h5, html[dir="rtl"] h6 {
    font-family: 'Sakkal Majalla', 'Amiri', 'Cairo', 'Scheherazade New', 'Traditional Arabic', serif !important;
    font-weight: 700 !important;
    direction: rtl;
    text-align: right;
}

/* Badge "Qui sommes-nous" */
html[lang="ar"] .about-badge,
html[dir="rtl"] .about-badge {
    font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Tahoma', sans-serif !important;
    font-weight: 600 !important;
}

/* =================================================================== */
/* OPTIMISATIONS ET FALLBACKS */
/* =================================================================== */

/* Support pour les anciens navigateurs */
@supports not (font-display: swap) {
    @font-face {
        font-family: 'Sakkal Majalla Fallback';
        src: local('Traditional Arabic'), local('Arabic Typesetting'), local('Tahoma');
    }
}

/* Responsive - Ajustements pour mobile */
@media (max-width: 768px) {
    html[dir="rtl"] .about-description,
    .about-description.arabic-text {
        font-size: 1.7rem !important;
        line-height: 1.75 !important;
    }
    
    html[lang="ar"] .main-title,
    html[dir="rtl"] .main-title {
        font-size: 2rem !important;
        line-height: 1.3 !important;
    }
}

@media (max-width: 576px) {
    html[dir="rtl"] .about-description,
    .about-description.arabic-text {
        font-size: 1.5rem !important;
        line-height: 1.6 !important;
    }
    
    html[lang="ar"] .navbar-brand,
    html[dir="rtl"] .navbar-brand {
        font-size: 1.2rem !important;
    }
}

/* =================================================================== */
/* PRELOADING ET OPTIMISATIONS DE PERFORMANCE */
/* =================================================================== */

/* Optimisation du rendu des polices */
* {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prévention du FOUT (Flash of Unstyled Text) */
html[lang="ar"] body,
html[dir="rtl"] body {
    font-family: 'Tahoma', 'Arial Unicode MS', sans-serif;
}

/* Application progressive des polices personnalisées */
.fonts-loaded html[lang="ar"] body,
.fonts-loaded html[dir="rtl"] body {
    font-family: 'Cairo', 'IBM Plex Sans Arabic', 'Tahoma', sans-serif;
}

/* =================================================================== */
/* UTILITAIRES DE DÉBOGAGE (À RETIRER EN PRODUCTION) */
/* =================================================================== */

/* Classe pour tester l'application des polices */
.debug-font {
    font-family: 'Sakkal Majalla', monospace !important;
    background: yellow;
    color: black;
    padding: 2px 4px;
    font-size: 12px;
}

/* Affichage de la police actuellement utilisée */
.debug-font::after {
    content: " [Police: " attr(data-font) "]";
    font-size: 10px;
    opacity: 0.7;
}
