/*
 * Bangla text in Kalpurush across the whole system.
 *
 * "AppBangla" covers only the Bengali block (unicode-range), so it is put first in
 * the font lists: every Bangla letter and digit comes from Kalpurush, while English
 * letters and numbers fall through to the font the theme already uses.
 * Icon fonts (Font Awesome, Glyphicons, Tabler) are left alone.
 */
@font-face {
    font-family: 'AppBangla';
    src: local('Kalpurush'),
        url('../fonts/kalpurush/kalpurush.woff2') format('woff2'),
        url('../fonts/kalpurush/kalpurush.ttf') format('truetype');
    unicode-range: U+0980-09FF, U+200C-200D, U+25CC;
    font-display: swap;
    /* Kalpurush draws small next to Latin fonts: enlarge only the Bangla glyphs. */
    size-adjust: 118%;
}

/*
 * Bangla digits on screen only. "BnDigits" is a 10-glyph font built from Kalpurush whose
 * 0-9 draw ০-৯. The page text keeps ASCII digits, so JS maths, copy/paste, CSV/Excel
 * exports and saved data are unchanged; only how the numbers look changes.
 * Used in Bangla mode only, and never in form fields (people type English digits there).
 */
@font-face {
    font-family: 'BnDigits';
    src: url('../fonts/kalpurush/bn-digits.woff') format('woff'),
        url('../fonts/kalpurush/bn-digits.ttf') format('truetype');
    unicode-range: U+0030-0039;
    font-display: block;
    size-adjust: 112%;
    /* Declared for every weight so the browser never fakes a bold: Kalpurush has no
       bold digits, and a synthetic bold smears ৬ ৮ ৯ together at table sizes. */
    font-weight: 100 900;
}

:root {
    --bn-font: 'AppBangla', var(--x-font, Inter, 'Source Sans Pro', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif);
}
/* Bangla mode: every display element below picks up Bangla digits through --bn-font. */
html[lang="bn"] {
    --bn-font: 'BnDigits', 'AppBangla', var(--x-font, Inter, 'Source Sans Pro', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif);
}

html body,
/* Layout blocks too: some skins put their own face on <main>, and a plain <div>
   would inherit that instead of the Bangla stack. */
main, div, section, article, header, footer, aside, nav, #scrollable-container,
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6,
p, a, span, label, small, strong, b, em, li, dt, dd,
table, th, td, caption, legend, .btn, .badge, .label,
input, button, select, textarea, optgroup, option,
.select2-container, .select2-results, .select2-dropdown, .select2-selection__rendered,
.tooltip, .popover, .toast, #toast-container, .swal-modal, .swal2-popup, .sweet-alert,
.modal, .dropdown-menu, .nav, .navbar, .main-sidebar, .main-header, .content-wrapper,
.box, .box-title, .info-box, .small-box, .dataTables_wrapper, .daterangepicker {
    font-family: var(--bn-font) !important;
}

/* Form fields keep English digits: what is typed is what is saved. Also any element
   marked .en-digits (opt-out for codes that must read in English). */
html[lang="bn"] input, html[lang="bn"] textarea, html[lang="bn"] select, html[lang="bn"] option,
html[lang="bn"] [contenteditable="true"], html[lang="bn"] .en-digits, html[lang="bn"] .en-digits * {
    font-family: 'AppBangla', var(--x-font, Inter, 'Source Sans Pro', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif) !important;
}

/* Keep icon fonts on their own glyphs (the rule above would otherwise hit e.g. <span class="fa ...">). */
.fa, .fas, .far, .fal { font-family: 'Font Awesome 5 Free', 'FontAwesome' !important; }
.fab { font-family: 'Font Awesome 5 Brands' !important; }
.glyphicon { font-family: 'Glyphicons Halflings' !important; }
.ion, [class^="ion-"], [class*=" ion-"] { font-family: 'Ionicons' !important; }

/*
 * Kalpurush has only a regular weight and looks thin on screen. In Bangla mode a
 * hair-line stroke in the text colour thickens it a little (it is not synthetic
 * bold, so layouts do not shift). Icons are excluded.
 */
html[lang="bn"] body {
    line-height: 1.55;
    -webkit-text-stroke: 0.3px currentColor;
}
html[lang="bn"] .fa, html[lang="bn"] .fas, html[lang="bn"] .far, html[lang="bn"] .fab,
html[lang="bn"] .glyphicon, html[lang="bn"] svg, html[lang="bn"] canvas {
    -webkit-text-stroke: 0;
}
/* Text that is already bold gets no stroke: bold + stroke turns Bangla into blobs
   (buttons, headings, labels, big figures). */
html[lang="bn"] :is(b, strong, th, h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6,
    button, .btn, label, .badge, .label, .pill, .strong,
    [class*="font-bold"], [class*="font-semibold"], [class*="font-extrabold"], [class*="font-black"],
    [class*="title"], [class*="-label"], [class*="value"], [class*="kpi"], [class*="total"],
    [class*="-head"], [class*="-field"] > span, [class*="kinds"] *),
html[lang="bn"] :is(b, strong, th, button, .btn, label, [class*="title"], [class*="-label"], [class*="value"]) * {
    -webkit-text-stroke: 0;
}
/* Sidebar menu and sub-menu: a light bold (Kalpurush has no bold of its own, and
   a faked bold smears it; a fine stroke reads as semi-bold). */
html[lang="bn"] #side-bar .nav-item,
html[lang="bn"] #side-bar .nav-item .nav-label,
html[lang="bn"] #side-bar .nav-sub,
html[lang="bn"] #side-bar .nav-sub .nav-sub-label {
    -webkit-text-stroke: 0.45px currentColor;
}
html[lang="bn"] #side-bar .nav-head,
html[lang="bn"] #side-bar .nav-head .nav-head-label {
    -webkit-text-stroke: 0.3px currentColor;
}
/* Section headings (বিক্রয়, ক্রয়, খরচসমূহ ...) read a size above the rows under them. */
html[lang="bn"] #side-bar .nav-head {
    font-size: 15px;
}
html[lang="bn"] #side-bar i, html[lang="bn"] #side-bar svg, html[lang="bn"] #side-bar .chev {
    -webkit-text-stroke: 0;
}

/* Letter-spacing pulls Bangla conjuncts apart; Bangla reads best at normal spacing. */
html[lang="bn"] body * {
    letter-spacing: normal !important;
}
