/**
 * Grocero RTL Stylesheet for Arabic Language
 * Font: Tajawal
 * Supports Arabic typography, directional mirroring, and layout adjustments.
 */

/* 1. Global Font and Typography for Arabic */
[dir="rtl"],
[dir="rtl"] body,
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6,
[dir="rtl"] p,
[dir="rtl"] span,
[dir="rtl"] a,
[dir="rtl"] button,
[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea,
[dir="rtl"] label,
[dir="rtl"] .font-heading,
[dir="rtl"] [data-nav-link],
[dir="rtl"] [role="menuitem"],
[dir="rtl"] [role="menuitemradio"] {
    font-family: 'Tajawal', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* Crucial for Arabic: Never detach cursive Arabic letters with Latin letter-spacing */
[dir="rtl"] * {
    letter-spacing: normal !important;
}

/* 2. Base Direction & Text Alignment */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

/* 3. Directional Icon Mirroring (flip left/right arrows for RTL reading direction) */
[dir="rtl"] .fa-arrow-right,
[dir="rtl"] .fa-arrow-right-long,
[dir="rtl"] .fa-chevron-right,
[dir="rtl"] .fa-angle-right,
[dir="rtl"] .fa-angles-right,
[dir="rtl"] .fa-caret-right {
    transform: scaleX(-1);
    display: inline-block;
}

[dir="rtl"] .fa-arrow-left,
[dir="rtl"] .fa-arrow-left-long,
[dir="rtl"] .fa-chevron-left,
[dir="rtl"] .fa-angle-left,
[dir="rtl"] .fa-angles-left,
[dir="rtl"] .fa-caret-left {
    transform: scaleX(-1);
    display: inline-block;
}

/* 4. Swiper / Carousel RTL Adjustments */
[dir="rtl"] .swiper-button-next,
[dir="rtl"] .swiper-button-prev {
    transform: scaleX(-1);
}

/* Hero Carousel Navigation Arrows in RTL:
   Flip arrow SVGs so Prev points right (backward) and Next points left (forward) */
[dir="rtl"] [data-hero-prev] img,
[dir="rtl"] [data-hero-next] img {
    transform: scaleX(-1);
}

/* Hero Carousel Gradient in RTL */
[dir="rtl"] .bg-linear-to-r {
    background-image: linear-gradient(to left, var(--tw-gradient-stops, rgba(250, 43, 45, 0.2) 0%, transparent 100%)) !important;
}

/* 5. Dropdown Menus and Popovers */
[dir="rtl"] [data-dropdown-menu],
[dir="rtl"] [role="menu"],
[dir="rtl"] [role="dialog"] {
    text-align: right;
}

[dir="rtl"] [role="menuitem"],
[dir="rtl"] [role="menuitemradio"],
[dir="rtl"] [data-menu-dropdown-option] {
    text-align: right;
}

/* 6. Form Fields & Search Bars */
[dir="rtl"] input[type="search"]:not(.text-center),
[dir="rtl"] input[type="text"]:not(.text-center),
[dir="rtl"] input[type="email"]:not(.text-center),
[dir="rtl"] input[type="tel"]:not(.text-center),
[dir="rtl"] input[type="password"]:not(.text-center),
[dir="rtl"] textarea:not(.text-center) {
    text-align: right;
}

/* 7. Header Badge Counters (Cart & Wishlist) */
[dir="rtl"] .absolute.-top-1.-right-1 {
    right: auto !important;
    left: -0.25rem !important;
}

/* 8. Phone Number and Directional LTR Numbers */
[dir="rtl"] a[href^="tel:"],
[dir="rtl"] .phone-number,
[dir="rtl"] .ltr-text {
    direction: ltr;
    display: inline-flex;
    unicode-bidi: embed;
}

/* 9. Delivery Schedule Times and Sliders */
[dir="rtl"] [data-delivery-schedule-times] {
    text-align: right;
}

/* 10. Star Ratings in RTL (keep left-to-right filling for visual consistency) */
[dir="rtl"] .rating-stars,
[dir="rtl"] [data-rating] {
    direction: ltr;
    display: inline-flex;
}

/* In RTL, the language dropdown is located on the far-left edge of the navbar.
   Aligning it to the left edge ensures it opens inward onto the screen without clipping. */
[dir="rtl"] #header-language-menu,
[dir="rtl"] [data-language-dropdown] [data-dropdown-menu][popover] {
    left: anchor(left) !important;
    right: auto !important;
    margin-top: 0.5rem !important;
}

/* 11. Category Navbar & Fixed Portal Dropdowns in RTL
   When JS positions a portal dropdown via fixed coordinates (left: ...px),
   classes such as "inset-s-0" (inset-inline-start: 0) force right: 0 in RTL,
   causing the browser to ignore the computed left coordinate and pin the menu to the far right.
   Setting right: auto and inset-inline-start: auto ensures the computed left coordinate is respected
   and the menu aligns directly beneath its parent category. */
[dir="rtl"] .group\/cat [data-dropdown-menu],
[dir="rtl"] [data-dropdown-anchor="container"] [data-dropdown-menu] {
    right: auto !important;
    inset-inline-start: auto !important;
}
