/* SAFE Arabic font override
   - Applies ONLY on RTL / Arabic pages
   - Does NOT change font-size
   - Does NOT override icon fonts
*/

/* Self-hosted (no external network dependency - required for offline/air-gapped
   operation). Arabic-script glyph subset only, matching what this file actually
   renders text in. */
@font-face {
  font-family: "Cairo";
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url("/assets/grc_tool/fonts/cairo/cairo-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("/assets/grc_tool/fonts/tajawal/tajawal-300-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/grc_tool/fonts/tajawal/tajawal-400-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/grc_tool/fonts/tajawal/tajawal-500-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/grc_tool/fonts/tajawal/tajawal-700-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

html[dir="rtl"], html:lang(ar), html[lang^="ar"] {
  --grc-ar-font: "Cairo","Tajawal","IBM Plex Sans Arabic","Noto Sans Arabic",system-ui,-apple-system,"Segoe UI",Arial,sans-serif;
  /* Several theme files (daroo_risk_center_page.css and its theme variants)
     build their own font stack from this --font variable instead of using
     --grc-ar-font directly. Redefining it here, once, at the same RTL/Arabic
     scope covers them without having to patch each theme file individually. */
  --font: var(--grc-ar-font);
}

/* Apply ONLY to text containers (no universal selector, no !important) */
html[dir="rtl"] body,
html:lang(ar) body,
html[lang^="ar"] body,
html[dir="rtl"] .app-container,
html[dir="rtl"] .layout-main,
html[dir="rtl"] .desk-page,
html[dir="rtl"] .page-container,
html[dir="rtl"] .modal,
/* .modal itself resolves to Cairo correctly, but .modal-content has its own
   explicit Inter font-family that breaks the inheritance chain right there
   — everything inside it (.modal-header, .modal-title, .modal-body, e.g.
   the Keyboard Shortcuts dialog) silently falls back to Inter regardless.
   Confirmed by walking the live computed-style ancestor chain: .modal-dialog
   shows Cairo, its child .modal-content shows Inter. */
html[dir="rtl"] .modal-content,
html[dir="rtl"] .form-dashboard,
html[dir="rtl"] .frappe-control,
html[dir="rtl"] .ql-editor,
html[dir="rtl"] .errp-shell,
html[dir="rtl"] .errp-container,
html[dir="rtl"] .errp-dashboard,
html[dir="rtl"] .form-sidebar,
html[dir="rtl"] .sidebar-section,
html[dir="rtl"] body.daroo-v227c-ai-dialog pre {
  font-family: var(--grc-ar-font);
}

/* Inputs/buttons inherit safely */
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select,
html[dir="rtl"] button {
  font-family: inherit;
}

/* DO NOT break icons.
   font-family: inherit was not enough — the nearest ancestor with an
   explicit font-family is the Cairo/Tajawal rule above, so "inherit"
   resolved to the Arabic text font and broke every icon glyph (icon fonts
   map unicode codepoints to shapes in their own font file only). Each
   icon class is forced back to its own required font explicitly instead. */
html[dir="rtl"] .fa {
  font-family: "FontAwesome" !important;
}
html[dir="rtl"] .fas, html[dir="rtl"] .fa-solid {
  font-family: "Font Awesome 5 Free", "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
}
html[dir="rtl"] .far, html[dir="rtl"] .fa-regular {
  font-family: "Font Awesome 5 Free", "Font Awesome 6 Free" !important;
  font-weight: 400 !important;
}
html[dir="rtl"] .fab, html[dir="rtl"] .fa-brands {
  font-family: "Font Awesome 5 Brands", "Font Awesome 6 Brands" !important;
}
html[dir="rtl"] .octicon {
  font-family: "octicons" !important;
}
html[dir="rtl"] .uil {
  font-family: "Unicons" !important;
}
html[dir="rtl"] .material-icons {
  font-family: "Material Icons" !important;
}
html[dir="rtl"] svg,
html[dir="rtl"] i[class*="icon"] {
  font-family: inherit;
}
