/**
 * AS-Safa Group — RTL layout utilities
 * Applied when html[dir="rtl"] or body.rtl-mode is set (Arabic, Urdu).
 */

/* ── Direction root ── */
html[dir="rtl"],
body.rtl-mode {
    direction: rtl;
    text-align: start;
}

/* ── Logical spacing helpers ── */
.ms-auto { margin-inline-start: auto; }
.me-auto { margin-inline-end: auto; }
.ps-4 { padding-inline-start: 1rem; }
.pe-4 { padding-inline-end: 1rem; }
.text-start { text-align: start; }
.text-end { text-align: end; }

/* ── Header mirroring ── */
html[dir="rtl"] .site-header,
body.rtl-mode .site-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .site-header .header-actions,
body.rtl-mode .site-header .header-actions {
    flex-direction: row-reverse;
}

html[dir="rtl"] .site-header .nav-links,
body.rtl-mode .site-header .nav-links {
    flex-direction: row-reverse;
}

/* ── Language switcher ── */
.lang-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.lang-switcher select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 999px;
    padding: 6px 28px 6px 12px;
    font-family: 'Manrope', sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    min-width: 7.5rem;
    transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

html[dir="rtl"] .lang-switcher select,
body.rtl-mode .lang-switcher select {
    padding: 6px 12px 6px 28px;
}

.lang-switcher select:hover,
.lang-switcher select:focus {
    outline: none;
    border-color: rgba(212, 175, 55, 0.75);
    background: rgba(212, 175, 55, 0.08);
    box-shadow: 0 0 18px rgba(212, 175, 55, 0.12);
}

.lang-switcher::after {
    content: '';
    position: absolute;
    inset-inline-end: 12px;
    top: 50%;
    width: 0;
    height: 0;
    margin-top: -2px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid rgba(212, 175, 55, 0.75);
    pointer-events: none;
}

.lang-switcher-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Cart badge: logical corner ── */
html[dir="rtl"] #cartBadge,
body.rtl-mode #cartBadge,
html[dir="rtl"] #marketCartBadge,
body.rtl-mode #marketCartBadge {
    right: auto;
    left: -6px;
}

/* ── Mobile menu ── */
html[dir="rtl"] .mobile-menu a,
body.rtl-mode .mobile-menu a {
    text-align: center;
}

/* ── Flip directional icons when needed ── */
html[dir="rtl"] .icon-flip-rtl,
body.rtl-mode .icon-flip-rtl {
    transform: scaleX(-1);
}

/* ── Grid / flex fallbacks for inline styles using left/right ── */
html[dir="rtl"] [style*="text-align: left"],
body.rtl-mode [style*="text-align: left"] {
    text-align: start !important;
}

html[dir="rtl"] [style*="text-align: right"],
body.rtl-mode [style*="text-align: right"] {
    text-align: end !important;
}

@media (max-width: 768px) {
    .lang-switcher select {
        min-width: 6.5rem;
        font-size: 0.62rem;
        padding-top: 5px;
        padding-bottom: 5px;
    }
}
