/* Combined Fonts: IRANSans (Persian) + Poppins (English) */
/* ترکیب فونت‌های IRANSans برای فارسی و Poppins برای انگلیسی */

/* =========================== */
/* IRANSans Font Definitions  */
/* =========================== */

/* IRANSans Regular */
@font-face {
    font-family: 'IRANSans';
    src: url('../fonts/IRANSans-Edit.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE80-FEFC;
}

/* IRANSans Bold */
@font-face {
    font-family: 'IRANSans';
    src: url('../fonts/IRANSansBold-Edit.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE80-FEFC;
}

/* =========================== */
/* Poppins Font Definitions   */
/* =========================== */

/* Poppins Regular */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Poppins Medium */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Poppins SemiBold */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Poppins Bold */
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* =========================== */
/* Combined Font Stack        */
/* =========================== */

:root {
    --combined-font-stack: 'IRANSans', 'Poppins', 'Tahoma', 'Arial Unicode MS', 'Arial', sans-serif;
    --persian-font-stack: 'IRANSans', 'Tahoma', 'Arial Unicode MS', sans-serif;
    --english-font-stack: 'Poppins', 'Arial', 'Helvetica', sans-serif;
}

/* =========================== */
/* Base Styles                */
/* =========================== */

/* اعمال فونت ترکیبی به همه عناصر */
* {
    font-family: var(--combined-font-stack) !important;
}

/* عناصر اصلی */
body, html {
    font-family: var(--combined-font-stack) !important;
    font-size: 14px;
    line-height: 1.6;
    font-weight: 400;
    direction: rtl;
    text-align: right;
}

/* عناصر فرم */
input, textarea, select, button,
.form-control, .form-select, .btn {
    font-family: var(--combined-font-stack) !important;
    direction: rtl;
    text-align: right;
}

/* کامپوننت‌های Bootstrap */
.navbar, .nav-link, .dropdown-menu, .dropdown-item,
.card, .card-body, .card-title, .card-text,
.modal, .modal-header, .modal-body, .modal-footer,
.alert, .badge, .breadcrumb,
table, th, td, .table,
.sidebar, .sidebar .nav-link, .user-info {
    font-family: var(--combined-font-stack) !important;
}

/* عناوین */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--combined-font-stack) !important;
    font-weight: 700;
    line-height: 1.4;
}

h1 { 
    font-size: 2.5rem; 
    font-weight: 700; 
}

h2 { 
    font-size: 2rem; 
    font-weight: 700; 
}

h3 { 
    font-size: 1.75rem; 
    font-weight: 700; 
}

h4 { 
    font-size: 1.5rem; 
    font-weight: 500; 
}

h5 { 
    font-size: 1.25rem; 
    font-weight: 500; 
}

h6 { 
    font-size: 1rem; 
    font-weight: 500; 
}

/* =========================== */
/* Language-Specific Styles   */
/* =========================== */

/* فونت خاص برای متن‌های فارسی */
[lang="fa"], [dir="rtl"], .persian-text, .fa-text {
    font-family: var(--persian-font-stack) !important;
    direction: rtl;
    text-align: right;
    font-feature-settings: 'kern' 1, 'liga' 1;
}

/* فونت خاص برای متن‌های انگلیسی */
[lang="en"], [dir="ltr"], .english-text, .en-text {
    font-family: var(--english-font-stack) !important;
    direction: ltr;
    text-align: left;
    font-feature-settings: 'kern' 1, 'liga' 1;
}

/* =========================== */
/* Font Weight Classes        */
/* =========================== */

.font-light { font-weight: 300; }
.font-regular { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* =========================== */
/* Responsive Font Sizes      */
/* =========================== */

@media (max-width: 1200px) {
    body { font-size: 14px; }
    h1 { font-size: 2.25rem; }
    h2 { font-size: 1.875rem; }
}

@media (max-width: 768px) {
    body { font-size: 13px; }
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
}

@media (max-width: 576px) {
    body { font-size: 12px; }
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
}

/* =========================== */
/* Print Styles               */
/* =========================== */

@media print {
    * {
        font-family: var(--combined-font-stack) !important;
        color: black !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
}

/* =========================== */
/* Font Rendering Optimization */
/* =========================== */

body, * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'kern' 1;
}

/* =========================== */
/* Component-Specific Styles  */
/* =========================== */

/* دکمه‌ها */
.btn {
    font-weight: 500;
    font-size: 0.875rem;
}

.btn-primary, .btn-success, .btn-danger, .btn-warning {
    font-weight: 600;
}

/* کارت‌ها */
.card-title {
    font-weight: 600;
    font-size: 1.125rem;
}

/* نوار ناوبری */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

/* Badge ها */
.badge {
    font-size: 0.75rem;
    font-weight: 500;
}

/* متن کوچک */
.small, small {
    font-size: 0.875em;
    font-weight: 400;
}

/* جداول */
.table {
    font-size: 0.875rem;
}

.table th {
    font-weight: 600;
}

.table td {
    font-weight: 400;
}

/* فرم‌ها */
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
}

.form-control, .form-select {
    font-size: 0.875rem;
    font-weight: 400;
}

/* سایدبار */
.sidebar .nav-link {
    font-size: 0.875rem;
    font-weight: 500;
}

.user-info h6 {
    font-weight: 600;
}

/* =========================== */
/* Utility Classes            */
/* =========================== */

/* اعداد فارسی */
.persian-numbers {
    font-feature-settings: 'tnum' 1;
}

/* جهت متن */
.rtl, [dir="rtl"] {
    direction: rtl;
    text-align: right;
}

.ltr, [dir="ltr"] {
    direction: ltr;
    text-align: left;
}

/* بهبود نمایش در حالت تاریک */
@media (prefers-color-scheme: dark) {
    body, * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* =========================== */
/* Alert Styles               */
/* =========================== */

.alert {
    font-weight: 400;
}

.alert-heading {
    font-weight: 600;
}

/* =========================== */
/* Navigation Styles          */
/* =========================== */

.breadcrumb {
    font-size: 0.875rem;
    font-weight: 400;
}

.dropdown-item {
    font-size: 0.875rem;
    font-weight: 400;
}

/* =========================== */
/* Modal Styles               */
/* =========================== */

.modal-title {
    font-weight: 600;
}

.modal-body {
    font-weight: 400;
}

/* =========================== */
/* Font Loading Indicator     */
/* =========================== */

.font-loaded {
    font-family: var(--combined-font-stack) !important;
}

/* =========================== */
/* Mixed Content Support      */
/* =========================== */

/* برای محتوای ترکیبی فارسی-انگلیسی */
.mixed-content {
    font-family: var(--combined-font-stack) !important;
}

/* برای کد و متن تکنیکی */
code, pre, .code {
    font-family: 'Poppins', 'Consolas', 'Monaco', 'Courier New', monospace !important;
    direction: ltr;
    text-align: left;
}

/* برای اعداد و ارقام */
.numbers, .numeric {
    font-family: 'Poppins', 'Arial', sans-serif !important;
    direction: ltr;
    text-align: left;
}

/* =========================== */
/* Performance Optimizations  */
/* =========================== */

/* بهینه‌سازی بارگذاری فونت */
.font-preload {
    font-display: swap;
}

/* کاهش تأثیر FOUT */
.font-fallback {
    font-family: 'Tahoma', 'Arial', sans-serif;
}

/* =========================== */
/* Debug Classes              */
/* =========================== */

.debug-persian {
    background-color: rgba(255, 0, 0, 0.1);
    font-family: var(--persian-font-stack) !important;
}

.debug-english {
    background-color: rgba(0, 255, 0, 0.1);
    font-family: var(--english-font-stack) !important;
}

/* =========================== */
/* End of Combined Fonts CSS  */
/* =========================== */
/* Apply to common text elements */
p, span, div:not([class*="fa"]):not([class*="icon"]), 
a:not([class*="fa"]):not([class*="icon"]), 
h1, h2, h3, h4, h5, h6,
input, textarea, select, label,
table, th, td, li, ul, ol,
.navbar, .card, .btn:not([class*="fa"]):not([class*="icon"]) {
    font-family: 'IRANSans', 'Poppins', 'Tahoma', Arial, sans-serif !important;
}

/* CRITICAL: Ensure Font Awesome icons use their own font */
i.fa, i.fas, i.far, i.fal, i.fab, i.fad, 
i[class*="fa-"], 
.fa, .fas, .far, .fal, .fab, .fad, 
.fa-solid, .fa-regular, .fa-light, .fa-brands,
[class*="fa-"], 
[class^="fa-"], 
[class*=" fa-"],
span[class*="fa-"],
a[class*="fa-"],
button[class*="fa-"] {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", "Font Awesome 6 Brands", "FontAwesome" !important;
    font-weight: 900 !important;
    font-style: normal !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ensure Bootstrap icons use their own font */
.bi, [class*="bi-"] {
    font-family: "bootstrap-icons" !important;
}