/* ========================================
   فونت‌های فارسی و انگلیسی مشترک
   فقط برای همه فرم‌ها
   ======================================== */

/* ---------- فونت‌های فارسی (IRANYekanX) ---------- */
@font-face {
    font-family: 'IRANYekanX';
    src: url('../fonts/IRANYekanX-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANYekanX';
    src: url('../fonts/IRANYekanX-Bold.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANYekanX';
    src: url('../fonts/IRANYekanX-Black.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ---------- فونت‌های انگلیسی (Noto Sans) ---------- */
@font-face {
    font-family: 'Noto';
    src: url('../fonts/noto-sans-v42-latin-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Noto';
    src: url('../fonts/noto-sans-v42-latin-500.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Noto';
    src: url('../fonts/noto-sans-v42-latin-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ========================================
   کلاس‌های زبان برای اعمال فونت
   ======================================== */

/* ---------- فونت پیش‌فرض (انگلیسی) ---------- */
body {
    font-family: 'Noto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ---------- فونت فارسی (فقط وقتی که زبان فارسی انتخاب شده) ---------- */
.fa-body,
.fa-body * {
    font-family: 'IRANYekanX', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}

/* استثناها برای المان‌های خاص */
.fa-body .info-note,
.fa-body .status-pill,
.fa-body .form-type-badge,
.fa-body .header-brand-name,
.fa-body .header-brand-byline,
.fa-body footer,
.fa-body .accordion-content,
.fa-body .stream-item-text,
.fa-body .analysis-item p,
.fa-body .progress-item,
.fa-body table,
.fa-body select,
.fa-body button,
.fa-body input,
.fa-body h1,
.fa-body h2,
.fa-body h3,
.fa-body label,
.lang-fa {
    font-family: 'IRANYekanX', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}

/* ---------- فونت فرانسوی ---------- */
.fr-body,
.fr-body * {
    font-family: 'Noto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
/* --- دکمه بازگشت شناور مدرن (Icon Only) --- */
.floating-back-btn {
    position: fixed; /* ثابت روی صفحه */
    top: 50%;       /* فاصله از بالا */
    z-index: 1000;   /* بالاتر از همه المان‌ها */
    
    width: 48px;
    height: 48px;
    transform: translateY(-50%); /* دقیقاً وسط عمودی */
    
    /* استایل شیشه‌ای و مدرن */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px); /* افکت مات پشت شیشه */
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%; /* کاملا گرد */
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    color: #475569;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); /* سایه نرم */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
}

/* حالت هاور (وقتی موس میره روش) */
.floating-back-btn:hover {
    background: #ffffff;
    color: #10b981; /* سبز */
    transform: translateY(-50%) scale(1.1); 
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.25); /* سایه رنگی */
}

/* --- تنظیم جهت برای زبان‌ها --- */

/* پیش‌فرض (انگلیسی/LTR): گوشه چپ */
.floating-back-btn {
    left: 24px;
    right: auto;
}

/* فارسی (RTL): گوشه راست */
[dir="rtl"] .floating-back-btn {
    left: auto;  /* چپ را غیرفعال کن */
    right: 24px; /* بچسب به راست */
}

/* چرخش فلش در فارسی */
[dir="rtl"] .floating-back-btn svg {
    transform: rotate(180deg);
}

/* --- ریسپانسیو (موبایل) --- */
@media (max-width: 768px) {
    .floating-back-btn {
        width: 40px; /* در موبایل کمی کوچکتر */
        height: 40px;
        top: 50%; /* همچنان وسط عمودی */
        /* فاصله از کناره‌ها در موبایل */
        left: 16px; 
        transform: translateY(-50%); /* دقیقاً وسط عمودی */
    }
    
    [dir="rtl"] .floating-back-btn {
        right: 16px;
        left: auto;
    }
}

/* --- Global Action Buttons (Sticky Bar) --- */
.global-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    padding: 12px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    z-index: 9999;
    box-sizing: border-box;
    font-family: 'IRANYekanX', 'Noto', Tahoma, Geneva, Verdana, sans-serif;
}

.global-action-bar.lang-en, 
.global-action-bar.lang-fr {
    direction: ltr;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 13px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* رنگ‌ها تغییر نکردند */
.btn-canada {
    background-color: #ff574b;
    color: white !important;
    border: 1px solid #ff574b;
}
.btn-canada:hover {
    background-color: #b02117;
}

.btn-iran {
    background-color: #303537;
    color: white !important;
    border: 1px solid #303537;
}
.btn-iran:hover {
    background-color: #383b40;
}

.btn-forms {
    background-color: #f8f9fa;
    color: #333 !important;
    border: 1px solid #ddd;
}
.btn-forms:hover {
    background-color: #e2e6ea;
    color: #000 !important;
}

/* واکنش‌گرا */
@media (max-width: 768px) {
    .global-action-bar {
        padding: 10px;
        flex-direction: column;
        gap: 8px;
    }
    
    .action-btn {
        width: 100%;
    }
    
    /* فاصله بیشتر در پایین صفحه برای موبایل */
    body {
        padding-bottom: 180px !important; 
    }
}

@media (min-width: 769px) {
    body {
        padding-bottom: 80px !important;
    }
}

.ai-loading {
    padding: 20px;
    text-align: center;
    color: var(--primary-color);
    font-weight: 600;
}
#ai-result-box {
    padding: 15px;
    border: 1px dashed var(--primary-light);
    max-height: 400px;
    overflow-y: auto;
}
#ai-result-box strong {
    color: var(--primary-color);
}

/* Floating Action Button (FAB) for Consultation */
.global-fab {
    position: fixed;
    bottom: 24px;
    width: 56px;
    height: 56px;
    background: #dc2626;
    color: white;
    border-radius: 50%;
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.3s ease, background 0.3s;
    right: 20px; /* پیش‌فرض برای انگلیسی */
    left: auto;
}
html[lang="fa"] .global-fab {
    left: 20px;
    right: auto;
}

.global-fab:hover {
    transform: scale(1.1);
    background: #b91c1c;
}
.global-fab.open {
    background: #b91c1c;
    box-shadow: 0 6px 24px rgba(220, 38, 38, 0.6);
}

/* منوی بازشو */
.fab-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* جلوگیری از بیرون زدن از صفحه */
    max-width: calc(100vw - 40px);
    white-space: nowrap;
}
.global-fab.open .fab-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.fab-item {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    background: white;
    border-radius: 28px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
    color: var(--text-main, #111827);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: 0.2s;
    width: fit-content;
}
.fab-item:hover {
    background: #f9fafb;
    transform: translateX(-4px);
}

/* حالت RTL (فارسی) */
html[lang="fa"] .fab-menu {
    align-items: flex-start;
    right: auto;
    left: 0;
}
html[lang="fa"] .fab-item:hover {
    transform: translateX(4px);
}