/**
 * Professional Bilingual Font System
 * Automatically applies different fonts for Arabic and English content
 * Created: 2026-01-25
 */

/* ===================================
   ARABIC FONT STYLING
   =================================== */

/* Apply Arabic font to Arabic text and RTL elements */
*[lang="ar"],
*[dir="rtl"],
.arabic-text,
.rtl-content,
html[lang="ar"] body,
html[lang="ar"] * {
    font-family: var(--arabic-font-family), 'Cairo', 'Tajawal', 'Almarai', sans-serif !important;
    font-weight: var(--arabic-font-weight, 400);
    letter-spacing: 0;
    word-spacing: 0;
}

/* ===================================
   ENGLISH FONT STYLING
   =================================== */

/* Apply English font to English text and LTR elements */
*[lang="en"],
*[dir="ltr"],
.english-text,
.ltr-content,
html[lang="en"] body,
html[lang="en"] * {
    font-family: var(--english-font-family), 'Poppins', 'Roboto', 'Inter', sans-serif !important;
    font-weight: var(--english-font-weight, 400);
    letter-spacing: 0.02em;
    word-spacing: 0.05em;
}

/* ===================================
   MIXED CONTENT DETECTION
   =================================== */

/* Headings with mixed content */
h1, h2, h3, h4, h5, h6 {
    font-family: inherit;
    font-weight: 600;
    line-height: 1.3;
}

/* Paragraphs and text content */
p, span, div, a, li, td, th, label, input, textarea, select, button {
    font-family: inherit;
}

/* ===================================
   FONT WEIGHT VARIATIONS
   =================================== */

/* Light weight */
.font-light,
.fw-300 {
    font-weight: 300 !important;
}

/* Normal weight */
.font-normal,
.fw-400 {
    font-weight: 400 !important;
}

/* Medium weight */
.font-medium,
.fw-500 {
    font-weight: 500 !important;
}

/* Semi-bold */
.font-semibold,
.fw-600 {
    font-weight: 600 !important;
}

/* Bold */
.font-bold,
.fw-700,
strong, b {
    font-weight: 700 !important;
}

/* Extra bold */
.font-extrabold,
.fw-800 {
    font-weight: 800 !important;
}

/* ===================================
   RESPONSIVE FONT SIZES
   =================================== */

/* Desktop */
@media (min-width: 1200px) {
    html[lang="ar"] body {
        font-size: 16px;
    }
    
    html[lang="en"] body {
        font-size: 16px;
    }
    
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.75rem; }
    h4 { font-size: 1.5rem; }
    h5 { font-size: 1.25rem; }
    h6 { font-size: 1rem; }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1199px) {
    html[lang="ar"] body {
        font-size: 15px;
    }
    
    html[lang="en"] body {
        font-size: 15px;
    }
    
    h1 { font-size: 2.25rem; }
    h2 { font-size: 1.875rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    h5 { font-size: 1.125rem; }
    h6 { font-size: 1rem; }
}

/* Mobile */
@media (max-width: 767px) {
    html[lang="ar"] body {
        font-size: 14px;
    }
    
    html[lang="en"] body {
        font-size: 14px;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    h5 { font-size: 1.125rem; }
    h6 { font-size: 1rem; }
}

/* ===================================
   SPECIAL ELEMENTS
   =================================== */

/* Buttons */
.btn, button, .button {
    font-family: inherit;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Forms */
input, textarea, select {
    font-family: inherit;
    font-weight: 400;
}

/* Navigation */
nav, .navbar, .menu {
    font-family: inherit;
    font-weight: 500;
}

/* Product titles */
.product-title,
.product-name,
.item-title {
    font-family: inherit;
    font-weight: 600;
    line-height: 1.4;
}

/* Prices */
.price,
.product-price,
.amount {
    font-family: inherit;
    font-weight: 700;
    font-feature-settings: "tnum" 1, "lnum" 1;
}

/* ===================================
   ENHANCED READABILITY
   =================================== */

/* Arabic text optimization */
html[lang="ar"] body,
*[lang="ar"],
*[dir="rtl"] {
    text-align: right;
    direction: rtl;
    line-height: 1.8;
    word-spacing: 0;
    letter-spacing: 0;
}

/* English text optimization */
html[lang="en"] body,
*[lang="en"],
*[dir="ltr"] {
    text-align: left;
    direction: ltr;
    line-height: 1.6;
    word-spacing: 0.05em;
    letter-spacing: 0.02em;
}

/* ===================================
   SMOOTH FONT RENDERING
   =================================== */

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-variant-ligatures: common-ligatures;
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    * {
        font-family: inherit;
        color: #000 !important;
        background: #fff !important;
    }
}
