/* ============================================================
   DIRECTION.CSS – تنظیم RTL/LTR سراسری
   این فایل باید آخرین CSS لود شده باشد
   ============================================================ */

/* ============================================================
   پایه: تمام عناصر به dir والد احترام می‌گذارند
   ============================================================ */
html[dir="rtl"] {
    direction: rtl !important;
    text-align: right !important;
}

html[dir="ltr"] {
    direction: ltr !important;
    text-align: left !important;
}

/* body */
html[dir="rtl"] body,
body {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] body {
    direction: ltr !important;
    text-align: left !important;
}

/* ============================================================
   متن‌ها
   ============================================================ */
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"] span, html[dir="rtl"] div,
html[dir="rtl"] a, html[dir="rtl"] li, html[dir="rtl"] label {
    text-align: inherit;
}

html[dir="ltr"] h1, html[dir="ltr"] h2, html[dir="ltr"] h3,
html[dir="ltr"] h4, html[dir="ltr"] h5, html[dir="ltr"] h6,
html[dir="ltr"] p, html[dir="ltr"] span, html[dir="ltr"] div,
html[dir="ltr"] a, html[dir="ltr"] li, html[dir="ltr"] label {
    text-align: inherit;
}

/* عناصر خاص که باید همیشه LTR باشند (ایمیل، URL) */
[dir="ltr"],
.dir-ltr,
input[type="email"],
input[type="url"],
input[dir="ltr"] {
    direction: ltr !important;
    text-align: left !important;
}

/* ============================================================
   فلکس‌ها: در LTR برعکس RTL
   ============================================================ */

/* نوار بالایی هدر */
html[dir="rtl"] .top-bar-inner {
    flex-direction: row !important;
}
html[dir="ltr"] .top-bar-inner {
    flex-direction: row !important;
}

/* ترتیب برند/منو/شبکه‌ها در دو حالت متفاوت است */
html[dir="rtl"] .top-right   { order: 1 !important; }
html[dir="rtl"] .top-center  { order: 2 !important; }
html[dir="rtl"] .top-left    { order: 3 !important; }

html[dir="ltr"] .top-right   { order: 3 !important; }
html[dir="ltr"] .top-center  { order: 2 !important; }
html[dir="ltr"] .top-left    { order: 1 !important; }

/* ============================================================
   هیرو صفحه اصلی
   ============================================================ */

/* در RTL: متن راست، کتاب چپ */
html[dir="rtl"] .hero-grid {
    grid-template-columns: 1.1fr 1fr !important;
}

html[dir="rtl"] .hero-text {
    text-align: right !important;
    direction: rtl !important;
}

html[dir="rtl"] .hero-actions {
    justify-content: flex-start !important;
    direction: rtl !important;
}

/* در LTR: متن چپ، کتاب راست */
html[dir="ltr"] .hero-grid {
    grid-template-columns: 1fr 1.1fr !important;
}

html[dir="ltr"] .hero-text {
    text-align: left !important;
    direction: ltr !important;
}

html[dir="ltr"] .hero-actions {
    justify-content: flex-start !important;
    direction: ltr !important;
}

/* نوار ناوبری هیرو */
html[dir="rtl"] .hero-nav { direction: rtl !important; }
html[dir="ltr"] .hero-nav { direction: ltr !important; }

/* توضیح هیرو */
html[dir="rtl"] .hero-desc {
    margin-left: auto !important;
    margin-right: 0 !important;
}
html[dir="ltr"] .hero-desc {
    margin-right: auto !important;
    margin-left: 0 !important;
}

/* ============================================================
   نوار آمار
   ============================================================ */
html[dir="rtl"] .stats-bar { direction: rtl !important; }
html[dir="ltr"] .stats-bar { direction: ltr !important; }

html[dir="rtl"] .stat {
    border-left: 1px solid var(--border, #e8eef5) !important;
    border-right: none !important;
}
html[dir="rtl"] .stat:first-child { border-left: none !important; }

html[dir="ltr"] .stat {
    border-right: 1px solid var(--border, #e8eef5) !important;
    border-left: none !important;
}
html[dir="ltr"] .stat:first-child { border-right: none !important; }

/* ============================================================
   بخش‌های دوستونه
   ============================================================ */
html[dir="rtl"] .two-col-section { direction: rtl !important; }
html[dir="ltr"] .two-col-section { direction: ltr !important; }

html[dir="rtl"] .col-head,
html[dir="rtl"] .col-main,
html[dir="rtl"] .col-side,
html[dir="rtl"] .col-panel {
    text-align: right !important;
    direction: rtl !important;
}

html[dir="ltr"] .col-head,
html[dir="ltr"] .col-main,
html[dir="ltr"] .col-side,
html[dir="ltr"] .col-panel {
    text-align: left !important;
    direction: ltr !important;
}

/* سرستون */
html[dir="rtl"] .section-title-right {
    padding-right: 22px !important;
    padding-left: 0 !important;
    border-right: 5px solid var(--gold, #e0a82e) !important;
    border-left: none !important;
    text-align: right !important;
    direction: rtl !important;
}

html[dir="ltr"] .section-title-right {
    padding-left: 22px !important;
    padding-right: 0 !important;
    border-left: 5px solid var(--gold, #e0a82e) !important;
    border-right: none !important;
    text-align: left !important;
    direction: ltr !important;
}

/* ============================================================
   کارت‌ها
   ============================================================ */
html[dir="rtl"] .card,
html[dir="rtl"] .latest-card,
html[dir="rtl"] .article-card,
html[dir="rtl"] .topic-card,
html[dir="rtl"] .service-card,
html[dir="rtl"] .miracle-card,
html[dir="rtl"] .info-card {
    text-align: right !important;
    direction: rtl !important;
}

html[dir="ltr"] .card,
html[dir="ltr"] .latest-card,
html[dir="ltr"] .article-card,
html[dir="ltr"] .topic-card,
html[dir="ltr"] .service-card,
html[dir="ltr"] .miracle-card,
html[dir="ltr"] .info-card {
    text-align: left !important;
    direction: ltr !important;
}

/* ============================================================
   فوتر
   ============================================================ */
html[dir="rtl"] .site-footer-rich,
html[dir="rtl"] .footer-grid,
html[dir="rtl"] .footer-col,
html[dir="rtl"] .footer-contact-row {
    direction: rtl !important;
    text-align: right !important;
}

html[dir="ltr"] .site-footer-rich,
html[dir="ltr"] .footer-grid,
html[dir="ltr"] .footer-col,
html[dir="ltr"] .footer-contact-row {
    direction: ltr !important;
    text-align: left !important;
}

html[dir="rtl"] .footer-col h4::after {
    right: 0 !important;
    left: auto !important;
}
html[dir="ltr"] .footer-col h4::after {
    left: 0 !important;
    right: auto !important;
}

html[dir="rtl"] .footer-col ul {
    padding-right: 0 !important;
    padding-left: 0 !important;
}
html[dir="ltr"] .footer-col ul {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* ============================================================
   بردکرامب
   ============================================================ */
html[dir="rtl"] .breadcrumb,
html[dir="rtl"] .breadcrumb-bar {
    direction: rtl !important;
    text-align: right !important;
}

html[dir="ltr"] .breadcrumb,
html[dir="ltr"] .breadcrumb-bar {
    direction: ltr !important;
    text-align: left !important;
}

/* ============================================================
   سرچ‌باکس
   ============================================================ */
html[dir="rtl"] .search-form input { text-align: right !important; }
html[dir="ltr"] .search-form input { text-align: left !important; }

/* ============================================================
   دکمه‌های ورود/ثبت‌نام
   ============================================================ */
html[dir="rtl"] .qt-auth-buttons { flex-direction: row !important; }
html[dir="ltr"] .qt-auth-buttons { flex-direction: row-reverse !important; }

/* ============================================================
   منوی موبایل
   ============================================================ */
html[dir="rtl"] .qt-mobile-nav a { text-align: right !important; direction: rtl !important; }
html[dir="ltr"] .qt-mobile-nav a { text-align: left !important; direction: ltr !important; }

html[dir="rtl"] .qt-mobile-header { direction: rtl !important; }
html[dir="ltr"] .qt-mobile-header { direction: ltr !important; }

/* ============================================================
   تم تاریک (فقط برای border رنگ‌ها)
   ============================================================ */
html[data-theme="dark"][dir="rtl"] .stat { border-left-color: #1e2a3d !important; }
html[data-theme="dark"][dir="ltr"] .stat { border-right-color: #1e2a3d !important; }

/* ============================================================
   موبایل: در موبایل هم RTL/LTR حفظ شود
   ============================================================ */
@media (max-width: 900px) {
    html[dir="rtl"] .hero-text,
    html[dir="rtl"] .hero-actions,
    html[dir="rtl"] .section-title-right {
        text-align: center !important;
    }

    html[dir="ltr"] .hero-text,
    html[dir="ltr"] .hero-actions,
    html[dir="ltr"] .section-title-right {
        text-align: center !important;
    }

    html[dir="rtl"] .hero-grid,
    html[dir="ltr"] .hero-grid {
        grid-template-columns: 1fr !important;
    }
}