/* ==========================================================================
   PerfectQRCode — RTL + Arabic typography
   Loaded on every page; all RTL rules are scoped under html[dir="rtl"], so it
   is inert in English. The Tajawal webfont is only requested when Arabic is active.
   ========================================================================== */

/* --- Arabic font: flip the design tokens so the whole site uses Tajawal --- */
html[dir="rtl"] {
    --font-display: 'Tajawal', 'Sora', sans-serif;
    --font-body: 'Tajawal', 'DM Sans', sans-serif;
}

html[dir="rtl"] body {
    direction: rtl;
    line-height: 1.8; /* Arabic breathes a little better with more leading */
}

/* Uppercase Latin letter-spacing looks wrong applied to Arabic — neutralize it
   (but NOT on the logo, which is a Latin brand mark and keeps its own styling). */
html[dir="rtl"] [style*="letter-spacing"] {
    letter-spacing: normal;
}

/* Tajawal ships no 600 weight and reads a little lighter than the Latin UI font, so
   nav text looked thin in Arabic. Map the nav links (Latin 500), buttons + language
   switcher (Latin 600) up to Tajawal's bold (700) so Arabic reads as boldly as the
   English nav. This is our standing rule for chrome text weight in Arabic. */
html[dir="rtl"] .nav-link,
html[dir="rtl"] .btn,
html[dir="rtl"] .nav-lang,
html[dir="rtl"] .nav-lang-item,
html[dir="rtl"] .lang-item.active {
    font-weight: 700;
}

/* --- Directional arrows (→) should point the other way in RTL --- */
html[dir="rtl"] .btn svg,
html[dir="rtl"] .nav-link svg {
    transform: scaleX(-1);
}

/* Section labels, FAQ questions and showcase tabs use the Latin 600 weight — apply
   our rule (bump to Tajawal 700 in Arabic). Also right-align FAQ question text and
   drop the Latin letter-spacing on section tags, which harms Arabic letter joining. */
html[dir="rtl"] .section-tag,
html[dir="rtl"] .faq-question,
html[dir="rtl"] .ss-tab {
    font-weight: 700;
}
html[dir="rtl"] .faq-question {
    text-align: right;
}
html[dir="rtl"] .section-tag {
    letter-spacing: normal;
}

/* "Popular" badge on type cards is absolutely positioned on the right — move it to the
   left in RTL and drop the Latin letter-spacing. */
html[dir="rtl"] .popular-badge {
    right: auto;
    left: 12px;
    letter-spacing: normal;
}

/* FAQ page (its own .faq-p-* classes): right-align questions, bold in Arabic,
   and flip the answer list indentation. */
html[dir="rtl"] .faq-p-question {
    text-align: right;
    font-weight: 700;
}
html[dir="rtl"] .faq-p-answer-inner ul {
    padding-left: 0;
    padding-right: 18px;
}

/* Legal pages (Privacy/Terms .legal): flip list indentation to the right and bump
   the 600-weight subheadings to Tajawal bold. */
html[dir="rtl"] .legal ul {
    padding-left: 0;
    padding-right: 20px;
}
html[dir="rtl"] .legal h3 {
    font-weight: 700;
}

/* --- Navbar: flex reverses automatically under dir=rtl; keep the logo LTR --- */
html[dir="rtl"] .nav-logo-text {
    direction: ltr; /* brand name stays "perfect QRCODE" */
    text-align: left;
}

/* The logo is a fixed Latin brand mark — it must NEVER switch to the Arabic font,
   even though the rest of the site does. Pin it back to the brand typeface. */
html[dir="rtl"] .nav-logo-name,
html[dir="rtl"] .nav-logo-sub {
    font-family: 'Sora', sans-serif;
}

/* Auth pages use their own logo classes for the same brand mark — pin them too. */
html[dir="rtl"] .logo-word,
html[dir="rtl"] .logo-sub {
    font-family: 'Sora', sans-serif;
}
html[dir="rtl"] .dash-logo-text {
    font-family: 'Sora', sans-serif;
}

/* --- Footer: right-align columns and keep the brand lockup readable --- */
html[dir="rtl"] .footer-col,
html[dir="rtl"] .footer-brand,
html[dir="rtl"] .footer-tagline {
    text-align: right;
}
html[dir="rtl"] .footer-brand .nav-logo-text {
    direction: ltr;
    text-align: left;
}
html[dir="rtl"] .footer-bottom {
    direction: rtl;
}

/* ==========================================================================
   Language switcher — shown in BOTH directions (kept unscoped).
   Scales to any number of languages discovered in /Resources.
   ========================================================================== */

/* --- Trigger button (used by desktop <summary> and standalone) --- */
.nav-lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--slate-600);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--slate-200);
    background: #fff;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    transition: border-color .15s, color .15s, background .15s;
}
.nav-lang:hover {
    border-color: var(--blue-300);
    color: var(--blue-700);
    background: var(--blue-50);
}
.nav-lang svg { width: 16px; height: 16px; flex: none; }
.nav-lang .lang-caret { width: 14px; height: 14px; transition: transform .15s; }

/* --- Desktop dropdown (native <details>, no JS needed) --- */
.lang-switch { position: relative; }
.lang-switch > summary { list-style: none; }
.lang-switch > summary::-webkit-details-marker { display: none; }
.lang-switch[open] .lang-caret { transform: rotate(180deg); }

.lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
    padding: 6px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
html[dir="rtl"] .lang-menu { right: auto; left: 0; }

.lang-item {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--slate-700);
    text-decoration: none;
    white-space: nowrap;
    transition: background .12s, color .12s;
}
.lang-item:hover { background: var(--slate-100); color: var(--slate-900); }
.lang-item.active {
    background: var(--blue-50);
    color: var(--blue-700);
    font-weight: 600;
}

/* --- Mobile: inline pills inside the burger menu --- */
.nav-lang-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.nav-lang-item {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--slate-200);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    color: var(--slate-600);
    text-decoration: none;
    transition: all .12s;
}
.nav-lang-item:hover { border-color: var(--blue-300); color: var(--blue-700); }
.nav-lang-item.active {
    background: var(--blue-600);
    border-color: var(--blue-600);
    color: #fff;
}

/* ==========================================================================
   Dashboard (RTL): mirror the fixed sidebar, content offset, burger, tables.
   ========================================================================== */
html[dir="rtl"] .dash-sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--slate-100);
}
html[dir="rtl"] .dash-main {
    margin-left: 0;
    margin-right: 240px;
}
html[dir="rtl"] .qr-table th {
    text-align: right;
}
html[dir="rtl"] .dash-burger {
    left: auto;
    right: 14px;
}
html[dir="rtl"] .form-label .required {
    margin-left: 0;
    margin-right: 2px;
}
html[dir="rtl"] .dash-nav-section {
    letter-spacing: normal;
}

@media (max-width: 900px) {
    html[dir="rtl"] .dash-sidebar { transform: translateX(100%); }
    html[dir="rtl"] body.dash-nav-open .dash-sidebar { transform: translateX(0); }
    html[dir="rtl"] .dash-main { margin-right: 0; }
    html[dir="rtl"] .dash-topbar { padding-left: 16px; padding-right: 68px; }
}
@media (max-width: 640px) {
    html[dir="rtl"] .qr-table td::before { text-align: right; }
}
