/**
 * 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 — segmented pill */
.eman-lang-switcher {
    display: inline-flex;
    align-items: stretch;
    gap: 3px;
    padding: 4px;
    border-radius: 999px;
    background: #f3eef8;
    border: 1px solid rgba(106, 27, 154, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    line-height: 1;
    flex-direction: row;
    flex-shrink: 0;
}
.eman-lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    min-height: 32px;
    padding: 6px 14px;
    border-radius: 999px;
    color: #5c4b6e;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 750;
    letter-spacing: 0.01em;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.eman-lang-btn:hover {
    color: var(--eman-purple);
    background: rgba(106, 27, 154, 0.08);
}
.eman-lang-btn.is-active,
.eman-lang-btn[aria-current="true"] {
    color: #fff !important;
    background: var(--eman-purple, #6a1b9a);
    box-shadow: 0 4px 12px rgba(106, 27, 154, 0.28);
}
.eman-lang-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(106, 27, 154, 0.28));
}
.eman-lang-sep {
    display: none;
}
.eman-lang-switcher-wrap {
    display: inline-flex;
    flex-shrink: 0;
}

.eman-mobile-drawer__lang,
.eman-dash-sidebar__lang {
    display: flex;
    width: 100%;
}
.eman-mobile-drawer__lang .eman-lang-switcher,
.eman-dash-sidebar__lang .eman-lang-switcher {
    width: 100%;
    min-height: 40px;
    padding: 4px;
}
.eman-mobile-drawer__lang .eman-lang-btn,
.eman-dash-sidebar__lang .eman-lang-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 32px;
    font-size: 13px;
}
html.-dark-mode .eman-lang-switcher,
.-dark-mode .eman-lang-switcher {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: none;
}
html.-dark-mode .eman-lang-btn,
.-dark-mode .eman-lang-btn {
    color: rgba(255, 255, 255, 0.72);
}
html.-dark-mode .eman-lang-btn:hover,
.-dark-mode .eman-lang-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}
html.-dark-mode .eman-lang-btn.is-active,
html.-dark-mode .eman-lang-btn[aria-current="true"],
.-dark-mode .eman-lang-btn.is-active,
.-dark-mode .eman-lang-btn[aria-current="true"] {
    color: #fff !important;
    background: var(--eman-purple, #6a1b9a);
}

/* 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,
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;
}

html[dir="rtl"] .header-menu .eman-mobile-drawer__nav-icon .lucide-icon,
html[dir="ltr"] .header-menu .eman-mobile-drawer__nav-icon .lucide-icon,
html[dir="rtl"] .header-menu .eman-mobile-drawer__nav-icon svg,
html[dir="ltr"] .header-menu .eman-mobile-drawer__nav-icon svg,
html[dir="rtl"] .header .menu__nav li > a .lucide-icon,
html[dir="ltr"] .header .menu__nav li > a .lucide-icon {
    margin: 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,
html[dir="rtl"] .header .menu__nav,
html[dir="rtl"] .eman-header-actions,
html[dir="rtl"] .header-left,
html[dir="rtl"] .header-right {
    direction: rtl;
}

html[dir="rtl"] .header .menu__nav li > a,
html[dir="ltr"] .header .menu__nav li > a,
html[dir="rtl"] .header .eman-header-btn,
html[dir="rtl"] .header .eman-header-btn-login {
    flex-direction: row;
}

html[dir="rtl"] .header .eman-header-btn-login .lucide-icon[data-lucide="log-in"],
html[dir="rtl"] .header .eman-header-btn-login svg.lucide-log-in {
    transform: scaleX(-1);
}

@media (min-width: 1200px) {
    html[dir="rtl"] .header.-type-4 .header-menu,
    html[dir="ltr"] .header.-type-4 .header-menu {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        inset: auto;
    }

    html[dir="rtl"] .header.-type-4 .header-menu .menu,
    html[dir="ltr"] .header.-type-4 .header-menu .menu {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
    }
}

/* Level / catalog pages */
html[dir="rtl"] .eman-level-page,
html[dir="rtl"] .catalog-filter-bar {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .catalog-page-header {
    direction: rtl;
    text-align: center;
}

html[dir="rtl"] .catalog-page-header__title,
html[dir="rtl"] .catalog-section-title {
    font-family: 'Cairo', 'Work Sans', sans-serif;
}
