/* =========================================================
   FINAL & OPTIMIZED RTL FONT + ICON FIX
   - Persian digits everywhere (FaNum)
   - All Font Awesome icons safe
   - Lightweight & update-proof
   ========================================================= */


/* =====================
   1) Font Faces (FaNum)
   ===================== */

@font-face {
  font-family: "IRANYekanXFaNum";
  src: url("../pfonts/IRANYekanXFaNum-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IRANYekanXFaNum";
  src: url("../pfonts/IRANYekanXFaNum-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}


/* =========================================
   2) Apply Persian font (RTL – text only)
   ========================================= */

html[dir="rtl"] body {
  font-family: "IRANYekanXFaNum", Tahoma, Arial, sans-serif;
}

/* متن‌ها، کانتینرهای محتوا، فرم‌ها */
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"] a,
html[dir="rtl"] li,
html[dir="rtl"] span,
html[dir="rtl"] div,
html[dir="rtl"] label,
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select,
html[dir="rtl"] button,
html[dir="rtl"] table,
html[dir="rtl"] th,
html[dir="rtl"] td,
html[dir="rtl"] .item-page,
html[dir="rtl"] .page-content,
html[dir="rtl"] .entry-content,
html[dir="rtl"] .sp-page-builder,
html[dir="rtl"] .sppb-section,
html[dir="rtl"] .sppb-addon,
html[dir="rtl"] .sppb-addon-title,
html[dir="rtl"] .sppb-addon-text {
  font-family: inherit;
}


/* =========================================
   3) GLOBAL FONT AWESOME FIX (ALL TYPES)
   ========================================= */

/* --- Solid / Regular / Light --- */
html[dir="rtl"] .fa,
html[dir="rtl"] .fas,
html[dir="rtl"] .far,
html[dir="rtl"] .fal,
html[dir="rtl"] .fa-solid {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
}

/* --- Brands (LinkedIn, Twitter, …) --- */
html[dir="rtl"] .fab {
  font-family: "Font Awesome 6 Brands" !important;
  font-weight: 400 !important;
}

/* --- Ensure pseudo-elements are correct --- */
html[dir="rtl"] .fa::before,
html[dir="rtl"] .fas::before,
html[dir="rtl"] .far::before,
html[dir="rtl"] .fal::before,
html[dir="rtl"] .fab::before,
html[dir="rtl"] .fa-solid::before {
  font-family: inherit !important;
}


/* =========================================
   4) Safety for other icon systems
   ========================================= */

html[dir="rtl"] .icon,
html[dir="rtl"] [class^="icon-"],
html[dir="rtl"] [class*=" icon-"],
html[dir="rtl"] .sppb-icon,
html[dir="rtl"] .material-icons,
html[dir="rtl"] .lnr,
html[dir="rtl"] .lni {
  font-family: inherit !important;
}

/* =====================================================
   GLOBAL RTL DIGITS (FaNum) + ICON SAFE
   Put at the VERY END of custom.css
   ===================================================== */

/* 1) Force FaNum on all text elements in RTL */
html[dir="rtl"] body,
html[dir="rtl"] body :where(p,span,div,a,li,ul,ol,small,strong,b,em,label,button,input,textarea,select,h1,h2,h3,h4,h5,h6,td,th){
  font-family: "IRANYekanXFaNum", Tahoma, Arial, sans-serif !important;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
}

/* 2) Keep Font Awesome icons intact (all types) */
html[dir="rtl"] .fa,
html[dir="rtl"] .fas,
html[dir="rtl"] .far,
html[dir="rtl"] .fal,
html[dir="rtl"] .fa-solid{
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
}
html[dir="rtl"] .fab{
  font-family: "Font Awesome 6 Brands" !important;
  font-weight: 400 !important;
}
html[dir="rtl"] .fa::before,
html[dir="rtl"] .fas::before,
html[dir="rtl"] .far::before,
html[dir="rtl"] .fal::before,
html[dir="rtl"] .fab::before,
html[dir="rtl"] .fa-solid::before{
  font-family: inherit !important;
}


/* =====================================================
   PATCH: Fix RTL menu icon squares (Joomla/Helix menu)
   Put AFTER your current code (very end)
   ===================================================== */

/* 1) Restore icon-font in menu area (do NOT inherit text font) */
html[dir="rtl"] .sp-megamenu-parent .icon,
html[dir="rtl"] .sp-megamenu-parent [class^="icon-"],
html[dir="rtl"] .sp-megamenu-parent [class*=" icon-"]{
  font-family: "IcoMoon" !important;   /* Joomla core icon font */
  font-style: normal !important;
  font-weight: normal !important;
}

/* 2) If dropdown caret/arrow is Font Awesome via pseudo-element, force it back */
html[dir="rtl"] .sp-megamenu-parent > li > a::after,
html[dir="rtl"] .sp-megamenu-parent > li > a::before{
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
}

/* 3) Also ensure any FA icon inside the menu keeps FA (extra safety) */
html[dir="rtl"] .sp-megamenu-parent .fa,
html[dir="rtl"] .sp-megamenu-parent .fas,
html[dir="rtl"] .sp-megamenu-parent .far,
html[dir="rtl"] .sp-megamenu-parent .fal,
html[dir="rtl"] .sp-megamenu-parent .fa-solid{
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
}
html[dir="rtl"] .sp-megamenu-parent .fab{
  font-family: "Font Awesome 6 Brands" !important;
  font-weight: 400 !important;
}
