/**
 * Arabic (RTL) desktop: util icons flush to the physical RIGHT edge.
 * Order from the right: Shop → Cart → Garage → Account → Lang → Search
 * Loaded last. Overrides home-premium / nav-utility conflicting flex rules.
 */
@media (min-width: 901px) {
  html[dir="rtl"] .nav-shell.nav-main-row,
  html[dir="rtl"] body.is-home-page .nav-shell.nav-main-row,
  html[dir="rtl"] body.catalog-drawer-open .nav-shell.nav-main-row,
  html[dir="rtl"] body.catalog-drawer-push .nav-shell.nav-main-row,
  html[dir="rtl"] body.catalog-page-open .nav-shell.nav-main-row,
  html[dir="rtl"] body:has(#catalogDrawer.open) .nav-shell.nav-main-row {
    padding-right: 0 !important;
    padding-inline-end: 0 !important;
  }

  html[dir="rtl"] .nav-main-actions,
  html[dir="rtl"] body.is-home-page .nav-main-actions,
  html[dir="rtl"] body.catalog-drawer-open .nav-main-actions,
  html[dir="rtl"] body.catalog-drawer-push .nav-main-actions,
  html[dir="rtl"] body.catalog-page-open .nav-main-actions,
  html[dir="rtl"] body.catalog-branch-mode .nav-main-actions,
  html[dir="rtl"] body:has(#catalogDrawer.open) .nav-main-actions {
    display: grid !important;
    /* Search -2.25cm vs classic 23cm baseline (+1cm vs previous -3.25cm) */
    grid-template-columns: minmax(calc(23cm - 2.25cm), 1fr) auto auto auto auto auto !important;
    grid-template-areas: "search lang account garage cart shop" !important;
    flex-direction: unset !important;
    flex-wrap: nowrap !important;
    align-items: flex-start !important;
    justify-content: unset !important;
    direction: ltr !important;
    width: 100% !important;
    min-width: 0 !important;
    gap: 0 !important;
    column-gap: 10px !important;
    row-gap: 0 !important;
  }

  /* Flatten wrappers so children join the parent grid */
  html[dir="rtl"] .nav-trade-cluster,
  html[dir="rtl"] body.is-home-page .nav-trade-cluster,
  html[dir="rtl"] body.catalog-drawer-open .nav-trade-cluster,
  html[dir="rtl"] body.catalog-drawer-push .nav-trade-cluster,
  html[dir="rtl"] body.catalog-page-open .nav-trade-cluster,
  html[dir="rtl"] body.catalog-branch-mode .nav-trade-cluster,
  html[dir="rtl"] body:has(#catalogDrawer.open) .nav-trade-cluster,
  html[dir="rtl"] .nav-util-cluster,
  html[dir="rtl"] body.is-home-page .nav-util-cluster,
  html[dir="rtl"] body.catalog-drawer-open .nav-util-cluster,
  html[dir="rtl"] body.catalog-drawer-push .nav-util-cluster,
  html[dir="rtl"] body.catalog-page-open .nav-util-cluster,
  html[dir="rtl"] body.catalog-branch-mode .nav-util-cluster,
  html[dir="rtl"] body:has(#catalogDrawer.open) .nav-util-cluster {
    display: contents !important;
    flex: unset !important;
    order: unset !important;
    margin: 0 !important;
    gap: 0 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  html[dir="rtl"] .nav-search-wrap,
  html[dir="rtl"] body.is-home-page .nav-search-wrap,
  html[dir="rtl"] body.catalog-drawer-open .nav-search-wrap,
  html[dir="rtl"] body.catalog-drawer-push .nav-search-wrap,
  html[dir="rtl"] body.catalog-page-open .nav-search-wrap,
  html[dir="rtl"] body:has(#catalogDrawer.open) .nav-search-wrap {
    grid-area: search !important;
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: calc(23cm - 2.25cm) !important;
    max-width: none !important;
    order: unset !important;
  }

  html[dir="rtl"] .nav-search,
  html[dir="rtl"] body.is-home-page .nav-search {
    width: 100% !important;
    max-width: none !important;
  }

  html[dir="rtl"] .nav-lang-wrap,
  html[dir="rtl"] .nav-util-cluster .nav-lang-wrap,
  html[dir="rtl"] body.is-home-page .nav-util-cluster .nav-lang-wrap {
    grid-area: lang !important;
    order: unset !important;
    /* 3mm between Search and Language (accounts for 10px column-gap) */
    margin-inline-start: calc(3mm - 10px) !important;
    margin-inline-end: 0 !important;
  }

  html[dir="rtl"] .nav-account,
  html[dir="rtl"] .nav-btn-auth,
  html[dir="rtl"] .nav-util-cluster .nav-account,
  html[dir="rtl"] .nav-util-cluster .nav-btn-auth,
  html[dir="rtl"] body.is-home-page .nav-util-cluster .nav-account,
  html[dir="rtl"] body.is-home-page .nav-util-cluster .nav-btn-auth {
    grid-area: account !important;
    order: unset !important;
  }

  html[dir="rtl"] .nav-garage-btn,
  html[dir="rtl"] .nav-util-cluster .nav-garage-btn,
  html[dir="rtl"] body.is-home-page .nav-util-cluster .nav-garage-btn {
    grid-area: garage !important;
    order: unset !important;
    /* Icon + جراجي stacked under mark */
    flex-direction: column !important;
    width: auto !important;
    min-width: 44px !important;
    max-width: none !important;
    height: auto !important;
    min-height: 44px !important;
    max-height: none !important;
    gap: 2px !important;
    padding-inline: 2px !important;
  }

  /* RTL desktop: جراجي under garage SVG (other utils stay icon-only) */
  html[dir="rtl"] .nav-util-cluster .nav-garage-btn .nav-util-btn__label,
  html[dir="rtl"] body.is-home-page .nav-util-cluster .nav-garage-btn .nav-util-btn__label {
    display: block !important;
    margin: 0 !important;
    font-size: 15px !important;
    font-family: var(--font-ar, Arial, sans-serif) !important;
    font-weight: 700 !important;
    line-height: 1.1 !important;
    color: inherit !important;
    white-space: nowrap !important;
    text-align: center !important;
  }

  html[dir="rtl"] .nav-cart-btn,
  html[dir="rtl"] .nav-util-cluster .nav-cart-btn,
  html[dir="rtl"] body.is-home-page .nav-util-cluster .nav-cart-btn {
    grid-area: cart !important;
    order: unset !important;
    margin-right: 0 !important;
    margin-inline-end: 0 !important;
  }

  /* Shop = first slot from the right (before Cart when reading RTL) */
  html[dir="rtl"] .nav-shop-btn,
  html[dir="rtl"] body.is-home-page .nav-shop-btn,
  html[dir="rtl"] .nav-trade-cluster .nav-shop-btn {
    grid-area: shop !important;
    order: unset !important;
    align-self: center !important;
    margin: 0 !important;
    margin-inline: 0 !important;
  }
}
