/**
 * Direction-aware layout — works with html[dir="rtl"] and html[dir="ltr"]
 */

html.eman-page {
    scroll-behavior: smooth;
}

html[dir="rtl"] body,
html[dir="rtl"] body.eman-page,
html[dir="rtl"] .eman-page {
    font-family: 'Cairo', 'Work Sans', sans-serif;
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] body,
html[dir="ltr"] body.eman-page,
html[dir="ltr"] .eman-page {
    font-family: 'Work Sans', 'Cairo', sans-serif;
    direction: ltr;
    text-align: left;
}

/* Fixed language switcher (auth pages) */
.eman-lang-fixed {
    position: fixed;
    top: 16px;
    inset-inline-end: 16px;
    z-index: 10000;
}

/* Language switcher */
.eman-lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(106, 27, 154, 0.08);
    border: 1px solid rgba(106, 27, 154, 0.15);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    flex-direction: row;
}
html[dir="rtl"] .eman-lang-switcher {
    flex-direction: row-reverse;
}
.eman-lang-btn {
    color: #666;
    text-decoration: none;
    padding: var(--space-1) 6px;
    border-radius: 6px;
    transition: color var(--transition-fast), background var(--transition-fast);
}
.eman-lang-btn:hover,
.eman-lang-btn.is-active {
    color: var(--eman-purple);
    background: rgba(106, 27, 154, 0.12);
}
.eman-lang-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}
.eman-lang-sep {
    color: #ccc;
    user-select: none;
}
html.-dark-mode .eman-lang-switcher,
.-dark-mode .eman-lang-switcher {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}
html.-dark-mode .eman-lang-btn,
.-dark-mode .eman-lang-btn {
    color: rgba(255, 255, 255, 0.7);
}
html.-dark-mode .eman-lang-btn.is-active,
.-dark-mode .eman-lang-btn.is-active {
    color: #fff;
}

/* Logical spacing for icons */
html[dir="rtl"] .header a .lucide-icon,
html[dir="rtl"] .header button .lucide-icon,
html[dir="rtl"] .header-menu a .lucide-icon {
    margin-inline-end: 10px !important;
    margin-inline-start: 0 !important;
}
html[dir="ltr"] .header a .lucide-icon,
html[dir="ltr"] .header button .lucide-icon,
html[dir="ltr"] .header-menu a .lucide-icon {
    margin-inline-end: 10px !important;
    margin-inline-start: 0 !important;
}

/* Dashboard */
html[dir="rtl"] .dashboard__main,
html[dir="rtl"] .dashboard__content {
    direction: rtl;
    text-align: right;
}
html[dir="ltr"] .dashboard__main,
html[dir="ltr"] .dashboard__content {
    direction: ltr;
    text-align: left;
}

html[dir="rtl"] .wallet-table thead th,
html[dir="rtl"] .wallet-table tbody td {
    text-align: right;
}
html[dir="ltr"] .wallet-table thead th,
html[dir="ltr"] .wallet-table tbody td {
    text-align: left;
}
html[dir="rtl"] .wallet-table .amount-col { text-align: left; }
html[dir="ltr"] .wallet-table .amount-col { text-align: right; }

html[dir="rtl"] .tabs__controls { flex-direction: row-reverse; }
html[dir="ltr"] .tabs__controls { flex-direction: row; }

/* Text alignment helpers — follow document direction */
.text-start { text-align: start !important; }
.text-end { text-align: end !important; }

/* Watch lesson: remove forced RTL when in English */
html[dir="ltr"] .rtl-text,
html[dir="ltr"] .rtl-text-center {
    direction: ltr;
    text-align: start;
}
html[dir="rtl"] .rtl-text,
html[dir="rtl"] .rtl-text-center {
    direction: rtl;
    text-align: right;
}

/* Footer icons */
html[dir="rtl"] .footer .footer-icon {
    margin-inline-end: 10px;
    margin-inline-start: 0;
}
html[dir="ltr"] .footer .footer-icon {
    margin-inline-end: 10px;
    margin-inline-start: 0;
}

html[dir="rtl"] .icon-nav-gap,
html[dir="ltr"] .icon-nav-gap { margin-inline-end: 15px; }

/* Homepage & public sections follow document direction */
html[dir="rtl"] .hero-content,
html[dir="rtl"] .feature-card,
html[dir="rtl"] .step-item,
html[dir="rtl"] .about-content {
    text-align: right;
}
html[dir="ltr"] .hero-content,
html[dir="ltr"] .feature-card,
html[dir="ltr"] .step-item,
html[dir="ltr"] .about-content {
    text-align: left;
}

html[dir="rtl"] .hero-buttons .button {
    margin-inline-end: 15px;
    margin-inline-start: 0;
}
html[dir="ltr"] .hero-buttons .button {
    margin-inline-end: 15px;
    margin-inline-start: 0;
}

html[dir="rtl"] .lesson-card-badges,
html[dir="rtl"] .lesson-card-badge {
    left: auto;
    right: 10px;
}
html[dir="ltr"] .lesson-card-badges,
html[dir="ltr"] .lesson-card-badge {
    right: auto;
    left: 10px;
}

html[dir="rtl"] .step-item:not(:last-child)::after {
    left: auto;
    right: calc(50% + 50px);
}
html[dir="ltr"] .step-item:not(:last-child)::after {
    right: auto;
    left: calc(50% + 50px);
}

/* Footer follows document direction */
html[dir="rtl"] .footer.-type-1 {
    direction: rtl;
    text-align: right;
}
html[dir="ltr"] .footer.-type-1 {
    direction: ltr;
    text-align: left;
}
html[dir="rtl"] .footer .footer-icon,
html[dir="ltr"] .footer .footer-icon {
    margin-inline-end: 10px;
    margin-inline-start: 0;
}

/* Legacy rtl-* classes follow active locale */
html[dir="ltr"] .rtl-text,
html[dir="ltr"] .rtl-text-center,
html[dir="ltr"] .rtl-title,
html[dir="ltr"] .arabic-text,
html[dir="ltr"] .arabic-title,
html[dir="ltr"] .arabic-paragraph {
    direction: ltr;
    text-align: start;
}
html[dir="rtl"] .rtl-text,
html[dir="rtl"] .rtl-text-center,
html[dir="rtl"] .rtl-title,
html[dir="rtl"] .arabic-text,
html[dir="rtl"] .arabic-title,
html[dir="rtl"] .arabic-paragraph {
    direction: rtl;
    text-align: right;
}
html[dir="rtl"] .rtl-text-center {
    text-align: center;
}

/* Prevent mixed-direction glitches during Barba transitions */
html.eman-page, html.eman-page body {
    transition: none;
}

/* ── Watch lesson page ── */
html[dir="rtl"] .eman-watch .watch-sidebar,
html[dir="rtl"] .eman-watch .watch-sidebar-content,
html[dir="rtl"] .eman-watch .watch-content-item,
html[dir="rtl"] .eman-watch .watch-content-item-btn {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] .eman-watch .watch-content-item,
html[dir="ltr"] .eman-watch .watch-content-item-btn {
    direction: ltr;
    text-align: left;
}

html[dir="rtl"] .eman-watch .watch-sidebar-header-title h3,
html[dir="rtl"] .eman-watch .watch-content-details h1,
html[dir="rtl"] .eman-watch .watch-lesson-parent-title,
html[dir="rtl"] .eman-watch .watch-section-header,
html[dir="rtl"] .eman-watch .watch-content-item-title {
    font-family: 'Cairo', 'Work Sans', sans-serif;
}

html[dir="rtl"] .eman-watch-stat {
    text-align: start;
}

html[dir="rtl"] .eman-watch-toolbar__back svg,
html[dir="rtl"] .eman-watch-toolbar__back .lucide-icon {
    transform: scaleX(1);
}

html[dir="ltr"] .eman-watch-toolbar__back svg,
html[dir="ltr"] .eman-watch-toolbar__back .lucide-icon {
    transform: scaleX(-1);
}

/* ── Lesson detail page ── */
html[dir="rtl"] body.eman-lesson-detail,
html[dir="rtl"] .eman-lesson-detail .lesson-detail-hero,
html[dir="rtl"] .eman-lesson-detail .lesson-purchase-card {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] body.eman-lesson-detail {
    direction: ltr;
    text-align: left;
}

html[dir="rtl"] .eman-lesson-detail h1,
html[dir="rtl"] .eman-lesson-detail h2,
html[dir="rtl"] .eman-lesson-detail h3,
html[dir="rtl"] .eman-lesson-detail .lesson-purchase-card {
    font-family: 'Cairo', 'Work Sans', sans-serif;
}

html[dir="rtl"] #purchase-alert-box {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] #purchase-alert-box {
    direction: ltr;
    text-align: left;
}

/* ── Public header (desktop nav) ── */
html[dir="rtl"] .header.-type-4 .header__container .row {
    direction: rtl;
}

html[dir="rtl"] .header .menu__nav {
    direction: rtl;
}

html[dir="rtl"] .header .menu__nav li > a {
    flex-direction: row;
}

html[dir="rtl"] .eman-header-actions {
    direction: rtl;
}

html[dir="ltr"] .header .menu__nav li > a {
    flex-direction: row;
}

/* Level / catalog pages */
html[dir="rtl"] .eman-level-page,
html[dir="rtl"] .catalog-page-header,
html[dir="rtl"] .catalog-filter-bar {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .catalog-page-header__title,
html[dir="rtl"] .catalog-section-title {
    font-family: 'Cairo', 'Work Sans', sans-serif;
}
