/**
 * EcommPaaS Porto — RTL (Right-to-Left) Overrides (PORTO-057)
 *
 * Applied automatically when the HTML element carries [dir="rtl"], which
 * Magento sets for RTL store locales (Arabic, Hebrew, Persian, etc.).
 *
 * Strategy:
 *   - Flip horizontal margins, paddings, borders, and positions using
 *     [dir="rtl"] descendant selectors.
 *   - Flip flex-direction for horizontal flex containers.
 *   - Override text-align: left → right (and right → left where needed).
 *   - Float: left → right and vice-versa.
 *   - Swiper: set direction programmatically via JS (handled in slider.js).
 *   - CSS logical properties (margin-inline-start, padding-inline-end, etc.)
 *     are used where they replace repetitive override pairs.
 *
 * All selectors use [dir="rtl"] so this file can always be loaded without
 * cost when the page is LTR — none of these rules will match.
 */

/* =============================================================
 * TOP BAR
 * ============================================================= */

[dir="rtl"] .pt-topbar__links {
    margin-right: 0;
    margin-left: auto;
}

[dir="rtl"] .pt-topbar__links a + a {
    margin-left: 0;
    margin-right: 16px;
}

[dir="rtl"] .pt-topbar__right {
    margin-left: 0;
    margin-right: auto;
    flex-direction: row-reverse;
}

/* =============================================================
 * HEADER MAIN
 * ============================================================= */

[dir="rtl"] .pt-header__main {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-header__search {
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .pt-header__actions {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-header__actions-item + .pt-header__actions-item {
    margin-left: 0;
    margin-right: 16px;
}

[dir="rtl"] .pt-header__logo {
    margin-right: 0;
    margin-left: 32px;
}

/* =============================================================
 * MEGA MENU / NAV
 * ============================================================= */

[dir="rtl"] .pt-nav {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-nav__item {
    direction: rtl;
    text-align: right;
}

/* Mega dropdown: mirror horizontal positions */
[dir="rtl"] .pt-megamenu__dropdown {
    left: auto;
    right: 0;
}

[dir="rtl"] .pt-megamenu__col + .pt-megamenu__col {
    border-left: none;
    border-right: 1px solid var(--pt-border, #eee);
}

/* Caret indicator on right side items */
[dir="rtl"] .pt-nav__item--has-children > a::after {
    margin-left: 0;
    margin-right: 6px;
}

/* Mobile menu panel */
[dir="rtl"] .pt-mobile-menu {
    left: auto;
    right: 0;
    transform: translateX(100%);
}
[dir="rtl"] .pt-mobile-menu.pt-is-open {
    transform: translateX(0);
}

/* =============================================================
 * STICKY HEADER BAR
 * ============================================================= */

[dir="rtl"] .pt-sticky-bar__nav {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-sticky-bar__nav-link + .pt-sticky-bar__nav-link {
    margin-left: 0;
    margin-right: 24px;
}

[dir="rtl"] .pt-sticky-bar__cat-panel {
    left: auto;
    right: 0;
}

/* =============================================================
 * BREADCRUMBS
 * ============================================================= */

[dir="rtl"] .breadcrumbs .items {
    flex-direction: row-reverse;
}

[dir="rtl"] .breadcrumbs .item + .item::before {
    content: '\\2039'; /* ‹ — flipped chevron */
    margin: 0 4px 0 8px;
}

/* =============================================================
 * SIDEBAR
 * ============================================================= */

[dir="rtl"] .pt-sidebar-toggle {
    left: auto;
    right: 0;
    border-radius: 0 4px 4px 0;
}

[dir="rtl"] .pt-sidebar--left .pt-sidebar__panel {
    left: auto;
    right: -100%;
}
[dir="rtl"] .pt-sidebar--left .pt-sidebar__panel.pt-is-open {
    right: 0;
    left: auto;
}

/* =============================================================
 * PRODUCT CARD
 * ============================================================= */

[dir="rtl"] .pt-product-card__actions {
    flex-direction: row-reverse;
    right: auto;
    left: 0;
}

[dir="rtl"] .pt-product-card__info {
    text-align: right;
}

[dir="rtl"] .pt-product-card__price {
    text-align: right;
}

/* Badges */
[dir="rtl"] .pt-badge--top {
    left: auto;
    right: 8px;
}

/* =============================================================
 * CATEGORY TOOLBAR (sort, view mode)
 * ============================================================= */

[dir="rtl"] .pt-toolbar {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-view-mode__btn + .pt-view-mode__btn {
    margin-left: 0;
    margin-right: 4px;
}

/* =============================================================
 * PRODUCT PAGE
 * ============================================================= */

[dir="rtl"] .pt-product-tabs__nav {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-sticky-product-info__actions {
    flex-direction: row-reverse;
}

/* =============================================================
 * FOOTER
 * ============================================================= */

[dir="rtl"] .pt-footer-middle__grid {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-footer-middle__col {
    text-align: right;
}

[dir="rtl"] .pt-footer-bottom__inner {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-social-links {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-social-links__link + .pt-social-links__link {
    margin-left: 0;
    margin-right: 12px;
}

/* =============================================================
 * CART / CHECKOUT
 * ============================================================= */

[dir="rtl"] .pt-atc-toast {
    left: 20px;
    right: auto;
}

[dir="rtl"] .pt-atc-toast__icon {
    margin-right: 0;
    margin-left: 10px;
}

[dir="rtl"] .pt-atc-toast__close {
    margin-left: 0;
    margin-right: auto;
}

/* =============================================================
 * QUICK VIEW MODAL
 * ============================================================= */

[dir="rtl"] .pt-quickview__close {
    left: 12px;
    right: auto;
}

[dir="rtl"] .pt-quickview__body {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-quickview__info {
    text-align: right;
}

[dir="rtl"] .pt-quickview__price {
    text-align: right;
}

/* =============================================================
 * NEWSLETTER POPUP (PORTO-054)
 * ============================================================= */

[dir="rtl"] .pt-newsletter__close {
    left: 12px;
    right: auto;
}

[dir="rtl"] .pt-newsletter__body {
    flex-direction: row-reverse;
}

[dir="rtl"] .pt-newsletter__image {
    border-radius: 0 6px 6px 0;
}

[dir="rtl"] .pt-newsletter__info {
    text-align: right;
}

/* =============================================================
 * PAGINATION
 * ============================================================= */

[dir="rtl"] .pages .items {
    flex-direction: row-reverse;
}

/* =============================================================
 * SWIPER (direction override via JS — see slider.js)
 * Provide RTL CSS hint so JS can detect the requirement.
 * ============================================================= */

[dir="rtl"] .swiper {
    direction: rtl; /* Swiper reads this to set its own RTL mode */
}
