/**
 * MMD Admin Comprehensive RTL Stylesheet for Arabic Locales (ar_EG, ar_SA)
 */

html[lang="ar"],
html[dir="rtl"],
body.admin-rtl,
body[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

/* ==========================================================================
   Main Page Wrapper & Sidebar
   ========================================================================== */
body.admin-rtl {
    overflow-x: hidden;
}

/* The sidebar is fixed and 95px wide; 100% (not 100vw) keeps a vertical scrollbar from causing horizontal overflow. */
body.admin-rtl:not(.page-layout-admin-login) .page-wrapper {
    margin-left: 0 !important;
    margin-right: 95px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: calc(100% - 95px) !important;
    max-width: none !important;
    box-sizing: border-box !important;
}

/* Sidebar Wrapper & Background (Crucial fix: remove left:0 from :before) */
body.admin-rtl .menu-wrapper:before,
body.admin-rtl .menu-wrapper:after {
    left: auto !important;
    right: 0 !important;
    position: fixed !important;
    width: 95px !important;
    content: '' !important;
}

/*
 * Always fixed, never in flow: core globalNavigationScroll adds ._fixed only once the content is taller
 * than the menu, and the content's 95px right margin cannot fit beside an in-flow menu, so the whole
 * page would wrap below the menu (blank screen). top stays overridable for menu-scroll.js.
 */
body.admin-rtl .menu-wrapper {
    position: fixed !important;
    top: 0;
    left: auto !important;
    right: 0 !important;
    width: 95px !important;
    z-index: 1000 !important;
}

body.admin-rtl .menu-wrapper._fixed {
    position: fixed !important;
    left: auto !important;
    right: 0 !important;
    box-shadow: -2px 0 8px rgba(0,0,0,0.08) !important;
}

body.admin-rtl .nav-bar {
    position: static !important;
    width: 100% !important;
}

body.admin-rtl .menu-wrapper._fixed ~ .page-wrapper {
    margin-left: 0 !important;
    margin-right: 95px !important;
}

body.admin-rtl .logo {
    display: block !important;
    text-align: center !important;
    margin: 0 auto !important;
    padding: 15px 0 !important;
}

body.admin-rtl .logo img {
    margin: 0 auto !important;
    display: inline-block !important;
}

body.admin-rtl .admin__menu .level-0 > a {
    text-align: center !important;
}

body.admin-rtl .admin__menu .level-1.submenu {
    left: auto !important;
    right: 95px !important;
    border-left: 1px solid #d6d6d6 !important;
    border-right: none !important;
    text-align: right !important;
    box-shadow: -4px 4px 10px rgba(0,0,0,0.12) !important;
}

body.admin-rtl .admin__menu .submenu .column-title,
body.admin-rtl .admin__menu .submenu a {
    text-align: right !important;
}

body.admin-rtl .admin__menu .level-0 > .submenu,
body.admin-rtl #menu-menuamasty-base-menu .ambase-submenu,
body.admin-rtl #menu-menuamasty-base-menu .ambase-submenu.-second {
    right: 100% !important;
    left: auto !important;
}

body.admin-rtl .admin__menu .level-0:not(._show) > .submenu,
body.admin-rtl #menu-menuamasty-base-menu:not(._show) .ambase-submenu,
body.admin-rtl #menu-menuamasty-base-menu .ambase-submenu:not(._show) {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateX(100%) !important;
}

body.admin-rtl .admin__menu .level-0._show > .submenu,
body.admin-rtl #menu-menuamasty-base-menu._show .ambase-submenu:not(.-second),
body.admin-rtl #menu-menuamasty-base-menu .ambase-submenu._show {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
}

/* ==========================================================================
   Page Header, Search & User Menu (Title on Right, User/Search/Notif on Left)
   ========================================================================== */
body.admin-rtl .page-header,
body.admin-rtl .page-header.row {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 15px 3rem !important;
    margin-bottom: 20px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    direction: rtl !important;
    position: relative !important;
    z-index: 500 !important;
}

/* Headings / Page Title: On the RIGHT side */
body.admin-rtl .page-header-hgroup,
body.admin-rtl .page-header-headings {
    order: 1 !important;
    flex: 1 1 auto !important;
    float: right !important;
    text-align: right !important;
    margin: 0 !important;
    padding-right: 0 !important;
    padding-left: 20px !important;
}

body.admin-rtl .page-title-wrapper {
    text-align: right !important;
    float: right !important;
    width: 100% !important;
}

body.admin-rtl .page-title {
    text-align: right !important;
    margin: 0 !important;
}

/* Actions (User Profile, Search, Notifications): On the LEFT side */
body.admin-rtl .page-header-actions {
    order: 2 !important;
    flex: 0 0 auto !important;
    float: left !important;
    text-align: left !important;
    /* display: flex !important; */
    /* flex-direction: row !important; */
    align-items: center !important;
    /* justify-content: flex-end !important; */
    /* gap: 15px !important; */
    padding-top: 0 !important;
    margin: 0 !important;
}

/* Inside Actions: Far Left is User, then Search, then Notifications towards center */
body.admin-rtl .page-header-actions .admin-user {
    order: 3 !important;
    float: left !important;
    margin: 0 !important;
    position: relative !important;
}

body.admin-rtl .page-header-actions .search-global,
body.admin-rtl .page-header-actions .global-search {
    order: 2 !important;
    float: left !important;
    margin: 0 !important;
    position: relative !important;
}

body.admin-rtl .page-header-actions .notifications-wrapper,
body.admin-rtl .page-header-actions .notifications {
    order: 1 !important;
    float: left !important;
    margin: 0 !important;
    position: relative !important;
}

/* User dropdown button and menu in RTL */
body.admin-rtl .admin-user .admin__action-dropdown {
    padding-right: 35px !important;
    padding-left: 25px !important;
    text-align: right !important;
}

body.admin-rtl .admin-user .admin__action-dropdown:before {
    right: 10px !important;
    left: auto !important;
    margin-right: 0 !important;
}

body.admin-rtl .admin-user .admin__action-dropdown:after {
    left: 10px !important;
    right: auto !important;
}

body.admin-rtl .admin-user .admin__action-dropdown-menu,
body.admin-rtl .admin-user-menu.admin__action-dropdown-menu {
    left: 0 !important;
    right: auto !important;
    text-align: right !important;
}

/* Search input and dropdown in RTL */
body.admin-rtl .search-global-label,
body.admin-rtl .global-search__icon {
    left: 8px !important;
    right: auto !important;
}

body.admin-rtl .search-global-input,
body.admin-rtl .global-search__field {
    padding-right: 12px !important;
    padding-left: 32px !important;
    text-align: right !important;
    direction: rtl !important;
    left: 0 !important;
    right: auto !important;
}

body.admin-rtl .search-global-field .search-global-menu,
body.admin-rtl .search-global-field .autocomplete-results {
    left: 0 !important;
    right: auto !important;
    text-align: right !important;
}

/* Notifications dropdown in RTL */
body.admin-rtl .notifications-wrapper .admin__action-dropdown-menu,
body.admin-rtl .notifications .admin__action-dropdown-menu {
    left: 0 !important;
    right: auto !important;
    text-align: right !important;
}

/* ==========================================================================
   Messages & System Notifications Banner
   ========================================================================== */
body.admin-rtl .messages,
body.admin-rtl .message,
body.admin-rtl .admin__messages .message {
    text-align: right !important;
    direction: rtl !important;
    padding-right: 45px !important;
    padding-left: 15px !important;
}

body.admin-rtl .message:before,
body.admin-rtl .admin__messages .message:before {
    right: 15px !important;
    left: auto !important;
}

body.admin-rtl .message-system-inner {
    text-align: right !important;
}

body.admin-rtl .message-system-action-dropdown {
    left: 10px !important;
    right: auto !important;
}

/* ==========================================================================
   Dashboard Grid & Columns Reset
   ========================================================================== */
body.admin-rtl .dashboard-container {
    display: flex !important;
    flex-wrap: wrap !important;
    direction: rtl !important;
    text-align: right !important;
    margin: 0 -15px !important;
    position: static !important;
}

body.admin-rtl .dashboard-main {
    flex: 0 0 66.666667% !important;
    max-width: 66.666667% !important;
    padding: 0 15px !important;
    left: auto !important;
    right: auto !important;
    float: none !important;
    box-sizing: border-box !important;
}

body.admin-rtl .dashboard-secondary {
    flex: 0 0 33.333333% !important;
    max-width: 33.333333% !important;
    padding: 0 15px !important;
    left: auto !important;
    right: auto !important;
    float: none !important;
    box-sizing: border-box !important;
}

body.admin-rtl .dashboard-store-stats {
    text-align: right !important;
    margin-top: 20px !important;
}

body.admin-rtl .dashboard-totals-wrap,
body.admin-rtl .dashboard-diagram-container {
    text-align: right !important;
}

/* Reset Magento col-m-push and col-m-pull across admin in RTL */
body.admin-rtl [class*="col-m-push-"],
body.admin-rtl [class*="col-m-pull-"] {
    left: auto !important;
    right: auto !important;
}

/* Store switcher and reload data button */
body.admin-rtl .dashboard-container .entry-edit,
body.admin-rtl .store-switcher {
    float: right !important;
    margin-right: 0 !important;
    margin-left: 15px !important;
    text-align: right !important;
}

body.admin-rtl .store-switcher .admin__field-label {
    float: right !important;
    margin-left: 8px !important;
    margin-right: 0 !important;
}

body.admin-rtl .store-switcher .admin__field-control {
    float: right !important;
}

/* Dashboard Tabs */
body.admin-rtl .dashboard-tabs,
body.admin-rtl ul.tabs-horiz {
    display: flex !important;
    list-style: none !important;
    margin: 0 0 15px 0 !important;
    padding: 0 !important;
    border-bottom: 2px solid #e3e3e3 !important;
    text-align: right !important;
}

body.admin-rtl ul.tabs-horiz > li {
    float: none !important;
    margin-left: 5px !important;
    margin-right: 0 !important;
}

body.admin-rtl ul.tabs-horiz > li > a {
    display: inline-block !important;
    padding: 10px 18px !important;
    text-align: center !important;
    font-weight: 600 !important;
    border-radius: 4px 4px 0 0 !important;
}

body.admin-rtl .dashboard-item {
    background: #fff;
    border: 1px solid #e3e3e3;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    text-align: right !important;
}

body.admin-rtl .dashboard-item-title {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 10px;
    text-align: right !important;
}

/* Advanced reports banner */
body.admin-rtl .dashboard-advanced-reports {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    text-align: right !important;
    background: #f8f8f8;
    padding: 15px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid #e3e3e3;
}

body.admin-rtl .dashboard-advanced-reports .dashboard-advanced-reports-title {
    font-size: 1.8rem;
    font-weight: 700;
}

body.admin-rtl .dashboard-advanced-reports .action-secondary {
    margin: 0 !important;
}

/* ==========================================================================
   Page Actions & Main Buttons (Save, Back, Add, Delete)
   ========================================================================== */
body.admin-rtl .page-main-actions {
    /* float: left !important; */
    text-align: left !important;
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
}

body.admin-rtl .page-main-actions .page-actions {
    margin-right: auto;
    margin-left: unset;
}

/* body.admin-rtl .page-actions-buttons {
    display: flex !important;
    gap: 10px !important;
} */

body.admin-rtl .page-main-actions .page-actions._fixed,
body.admin-rtl .sticky-header {
    right: 95px;
    left: 0;
}

body.admin-rtl .action-back:before {
    transform: scaleX(-1) !important;
    display: inline-block !important;
    margin-left: 5px !important;
    margin-right: 0 !important;
}

body.admin-rtl .breadcrumbs {
    text-align: right !important;
}

body.admin-rtl .breadcrumbs ul {
    display: flex !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 0 10px 0 !important;
}

body.admin-rtl .breadcrumbs ul li:after {
    content: " \2039 " !important;
    margin: 0 6px !important;
}

/* ==========================================================================
   Forms & Fieldsets
   ========================================================================== */
body.admin-rtl .admin__fieldset {
    text-align: right !important;
}

body.admin-rtl .admin__field {
    text-align: right !important;
    clear: both !important;
}

body.admin-rtl .admin__field-label {
    float: right !important;
    text-align: right !important;
    padding-left: 15px !important;
    padding-right: 0 !important;
}

body.admin-rtl .admin__field-control {
    float: right !important;
    text-align: right !important;
}

body.admin-rtl .admin__control-text,
body.admin-rtl .admin__control-textarea,
body.admin-rtl .admin__control-select {
    text-align: right !important;
    direction: rtl !important;
}

/* Mirror Magento's three select background layers (arrow sprite, grey box, divider) to the left edge. */
body.admin-rtl .admin__control-select {
    background-position: 12px -34px, 0 0, 3.3rem 0 !important;
    padding-right: 1rem !important;
    padding-left: 4.4rem !important;
}

body.admin-rtl .admin__control-select:active {
    background-position: 12px 13px, 0 0, 3.3rem 0 !important;
}

body.admin-rtl .admin__field-tooltip {
    left: auto !important;
    right: -25px !important;
}

body.admin-rtl .admin__collapsible-title:before {
    float: right !important;
    margin-right: 0 !important;
    margin-left: 8px !important;
    transform: scaleX(-1) !important;
}

/* Form Left-side Navigation Tabs */
body.admin-rtl .admin__page-nav {
    float: none !important;
    width: auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

body.admin-rtl .admin__page-nav-item > a {
    text-align: right !important;
    padding-right: 20px !important;
    padding-left: 10px !important;
}

body.admin-rtl .admin__page-nav-item > a:after {
    left: auto !important;
    right: 0 !important;
}

/* ==========================================================================
   Data Grids, Tables & Pagination
   ========================================================================== */
/* Core leaves the grid wrapper overflow visible, so in RTL a wide grid spills off the left edge where
   body { overflow-x: hidden } clips it. Scroll the grid itself instead. */
body.admin-rtl .admin__data-grid-wrap {
    overflow-x: auto !important;
}

body.admin-rtl .grid,
body.admin-rtl .data-grid,
body.admin-rtl .admin__data-grid-wrap table {
    width: 100% !important;
    direction: rtl !important;
    text-align: right !important;
}

body.admin-rtl .grid th,
body.admin-rtl .grid td,
body.admin-rtl .data-grid th,
body.admin-rtl .data-grid td,
body.admin-rtl .admin__data-grid-wrap th,
body.admin-rtl .admin__data-grid-wrap td {
    text-align: right !important;
    direction: rtl !important;
}

body.admin-rtl .data-grid-search-control-wrap {
    float: right !important;
}

body.admin-rtl .data-grid-filters-actions-wrap {
    float: left !important;
}

body.admin-rtl .admin__data-grid-pager-wrap {
    float: left !important;
}

body.admin-rtl .admin__data-grid-action-bookmarks {
    float: right !important;
}

body.admin-rtl .admin__data-grid-actions-wrap {
    float: left !important;
}

body.admin-rtl .admin__data-grid-header {
    text-align: right !important;
}

body.admin-rtl .action-select:after {
    margin-left: 0 !important;
    margin-right: 5px !important;
}

body.admin-rtl .data-grid-checkbox-cell-inner {
    text-align: center !important;
}

/* ==========================================================================
   Modals & Dynamic Rows
   ========================================================================== */
/* Slide-out modals open from the left edge and leave the sidebar side uncovered (mirror of core's left indent). */
body.admin-rtl .modal-slide {
    left: 0 !important;
    right: 14.8rem !important;
}

body.admin-rtl .modal-slide .modal-inner-wrap {
    transform: translateX(-100%) !important;
}

body.admin-rtl .modal-slide._show .modal-inner-wrap {
    transform: translateX(0) !important;
}

body.admin-rtl .modal-header {
    text-align: right !important;
}

body.admin-rtl .admin__menu .submenu-title {
    margin-left: 5.8rem!important;
    margin-right: 3rem!important;
}

body.admin-rtl .action-close {
    left: 0 !important;
    right: auto !important;
}

body.admin-rtl .modal-footer {
    text-align: left !important;
}

body.admin-rtl .admin__dynamic-rows .admin__control-table th,
body.admin-rtl .admin__dynamic-rows .admin__control-table td {
    text-align: right !important;
}

body.admin-rtl .admin__dynamic-rows .action-delete {
    float: left !important;
}
/* ==========================================================================
   Collapsible section headers (Stores > Configuration, sales rule forms)
   The open/close icon sat on top of the first letters of the title.
   ========================================================================== */
body.admin-rtl .entry-edit-head > a,
body.admin-rtl .admin__collapsible-title {
    padding-right: 3rem !important;
    padding-left: 0 !important;
}

body.admin-rtl .entry-edit-head > a:before,
body.admin-rtl .admin__collapsible-title:before {
    right: 0 !important;
    left: auto !important;
}

/* Menu item icons (Amasty, Branches) are drawn before the label; give them a gap on the RTL side. */
body.admin-rtl .admin__menu .submenu a:before,
body.admin-rtl .admin__menu .submenu a > span:before {
    margin-left: 0.6rem !important;
    margin-right: 0 !important;
}

/* ==========================================================================
   Grid pager
   ========================================================================== */
/* Previous/next chevrons point the reading direction. */
body.admin-rtl .admin__data-grid-pager .action-previous:before,
body.admin-rtl .admin__data-grid-pager .action-next:before {
    display: inline-block;
    transform: scaleX(-1);
}



/* ==========================================================================
   Date pickers (legacy grid filter rows, legacy forms)
   The trigger kept core's -32px left margin and was drawn outside the input, over the next filter.
   ========================================================================== */
body.admin-rtl .ui-datepicker-trigger {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

body.admin-rtl .data-grid-filters .ui-datepicker-trigger {
    left: 6px !important;
    right: auto !important;
}

body.admin-rtl .data-grid-filters .range-line .admin__control-text,
body.admin-rtl .data-grid-filters .date .admin__control-text {
    padding-left: 3rem !important;
}

/* ==========================================================================
   Left-to-right content inside RTL inputs and grid cells
   URLs, e-mails, hex colours, SKUs and English text keep their own direction instead of
   being reordered ("#fff" shown as "fff#", "https://" as "//:https").
   ========================================================================== */
body.admin-rtl .admin__control-text,
body.admin-rtl .admin__control-textarea,
body.admin-rtl .data-grid .data-grid-cell-content,
body.admin-rtl .data-grid td > div {
    unicode-bidi: plaintext;
}

body.admin-rtl input[type="url"],
body.admin-rtl input[type="email"],
body.admin-rtl input[name*="color"],
body.admin-rtl .colorpicker-spectrum input,
body.admin-rtl input[name*="href"],
body.admin-rtl input[name*="url"] {
    direction: ltr;
    text-align: left;
}

/* Back buttons: the arrow points to the start of the reading direction. */
body.admin-rtl .page-actions .back:before,
body.admin-rtl .page-actions .action-back:before {
    display: inline-block;
    transform: scaleX(-1);
}



/* ==========================================================================
   Grid toolbar: mass actions + record count on the right, pager on the left (mirrors core)
   ========================================================================== */
body.admin-rtl .admin__data-grid-header-row [class*="col-xs-"] {
    float: right !important;
}

body.admin-rtl .admin__data-grid-header-row .col-xs-9 {
    text-align: left !important;
}

body.admin-rtl .admin__data-grid-header-row .col-xs-3 .admin__data-grid-actions-wrap,
body.admin-rtl .admin__data-grid-header-row .col-xs-3 .action-select-wrap {
    float: right !important;
}

body.admin-rtl .admin__data-grid-header-row .col-xs-3 .admin__control-support-text {
    margin-left: 0 !important;
    margin-right: 1.5rem !important;
}

body.admin-rtl .admin__data-grid-pager-wrap {
    float: left !important;
}

body.admin-rtl .admin__data-grid-pager {
    margin-left: 0 !important;
    margin-right: 3rem !important;
}

/* ==========================================================================
   Dropdown toggles drawn with a grey arrow box (mass actions, per-page box, dropdown lists):
   the box and its triangle sit on the left, the text pads away from them.
   ========================================================================== */
body.admin-rtl .action-select-wrap .action-select,
body.admin-rtl .admin__action-multiselect-wrap .admin__action-multiselect {
    padding-left: 3.6rem !important;
    padding-right: 1.4rem !important;
    text-align: right !important;
}

body.admin-rtl .action-select-wrap .action-select:before,
body.admin-rtl .admin__action-multiselect-wrap .admin__action-multiselect:before {
    left: 0 !important;
    right: auto !important;
}

body.admin-rtl .action-select-wrap .action-select:after,
body.admin-rtl .admin__action-multiselect-wrap .admin__action-multiselect:after {
    left: 1.2rem !important;
    right: auto !important;
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

body.admin-rtl .admin__action-multiselect-wrap .admin__action-multiselect > .action-close {
    left: 0 !important;
    right: auto !important;
    margin-left: 3.2rem !important;
    margin-right: 0 !important;
}

body.admin-rtl .action-select-wrap .action-menu,
body.admin-rtl .admin__action-multiselect-wrap .action-menu {
    text-align: right !important;
}

body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-toggle {
    left: 0 !important;
    right: auto !important;
}

body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-toggle:before {
    left: 0 !important;
    right: auto !important;
}

body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-toggle:after {
    left: 1.1rem !important;
    right: auto !important;
}

body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-value input {
    text-align: right !important;
}

/* ==========================================================================
   Yes/No switches: track on the right (start), handle moves left when on
   ========================================================================== */
body.admin-rtl .admin__actions-switch-label:before,
body.admin-rtl .admin__actions-switch-label:after {
    left: auto !important;
    right: 0 !important;
}

body.admin-rtl .admin__actions-switch-label:before {
    transition: right .2s ease-in 0s !important;
}

body.admin-rtl .admin__actions-switch-checkbox:checked + .admin__actions-switch-label:before {
    left: auto !important;
    right: 15px !important;
}

body.admin-rtl .admin__actions-switch-text:before {
    padding-left: 0 !important;
    padding-right: 47px !important;
}

/* ==========================================================================
   Date pickers in forms: the calendar button sits inside the input on its left end
   ========================================================================== */
body.admin-rtl .admin__control-text._has-datepicker {
    padding-left: 3.5rem !important;
    padding-right: 1rem !important;
}

/* In-flow overlay: the button follows the input (to its left in RTL) and a negative margin pulls it
   inside the input's left end, wherever the nearest positioned container is. */
body.admin-rtl .admin__control-text._has-datepicker + .ui-datepicker-trigger {
    position: relative !important;
    display: inline-block !important;
    left: auto !important;
    right: auto !important;
    margin: 0 -3.2rem 0 0 !important;
    vertical-align: middle !important;
    z-index: 1;
}

/* ==========================================================================
   Two-column pages (customer, order, product tabs): navigation on the right, content on the left
   ========================================================================== */
/* Only pages that have a side column: floating main-col on one-column pages would shrink-wrap it to
   the grid's full width. The gutter core puts on the left is mirrored to the right. */
body.admin-rtl .page-columns:has(> .side-col) {
    margin-left: 0 !important;
    margin-right: -3rem !important;
}

body.admin-rtl .page-columns > .side-col {
    float: right !important;
    margin-left: 0 !important;
    margin-right: 3rem !important;
}

body.admin-rtl .page-columns:has(> .side-col) > .main-col {
    float: left !important;
}

/* ==========================================================================
   Tables: headers align right; cells keep dates, SKUs and negative numbers in reading order
   ========================================================================== */
body.admin-rtl table th:not(.data-grid-multicheck-cell):not(.data-grid-actions-cell):not(.a-center),
body.admin-rtl table th.a-right,
body.admin-rtl table td.a-right {
    text-align: right !important;
}

body.admin-rtl table td {
    unicode-bidi: plaintext;
}

/* plaintext gives a cell holding Latin text (names, SKUs, amounts) a left-to-right paragraph, so its
   default start alignment would turn left: pin cells to the right like their headers. */
body.admin-rtl table td:not(.a-center):not(.data-grid-checkbox-cell):not(.col-select):not(.data-grid-actions-cell):not([class*="col-actions"]),
body.admin-rtl table td:not(.a-center) > div,
body.admin-rtl table td .data-grid-cell-content {
    text-align: right !important;
}

body.admin-rtl .dashboard-item table th,
body.admin-rtl .dashboard-item table td {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

/* Selected-item tags in dropdown lists: the remove "×" sits at the tag's end (left), in reserved padding. */
body.admin-rtl .admin__action-multiselect-crumb {
    padding-left: 2.4rem !important;
    padding-right: 1rem !important;
}

body.admin-rtl .admin__action-multiselect-crumb .action-close {
    left: 0.2rem !important;
    right: auto !important;
}

/* Flyout menus: the sidebar icons are centred, but panel titles, group headings and items read from the right. */
body.admin-rtl .admin__menu .submenu,
body.admin-rtl .admin__menu .submenu-title,
body.admin-rtl .admin__menu .submenu-group-title,
body.admin-rtl .admin__menu .submenu .column {
    text-align: right !important;
}

body.admin-rtl #menu-menuamasty-base-menu .ambase-title {
    padding-right: 3rem !important;
}

/* ==========================================================================
   Fixed action bar (appears when scrolling a form): title on the right, buttons on the left
   ========================================================================== */
body.admin-rtl .page-actions._fixed .page-actions-inner:before {
    float: right !important;
    text-align: right !important;
    padding-left: 2rem !important;
    padding-right: 0 !important;
}

body.admin-rtl .page-actions._fixed .page-actions-buttons {
    float: left !important;
    justify-content: flex-start !important;
}

body.admin-rtl .page-actions._fixed {
    padding-left: 3rem !important;
    padding-right: 3rem !important;
}

/* ==========================================================================
   Grid toolbar dropdowns (Columns, Export, Views) sit on the left edge: open towards the page
   ========================================================================== */
body.admin-rtl .admin__data-grid-header .admin__data-grid-action-columns-menu,
body.admin-rtl .admin__data-grid-header .admin__data-grid-action-export-menu,
body.admin-rtl .admin__data-grid-header .admin__data-grid-action-bookmarks .admin__action-dropdown-menu {
    left: 0 !important;
    right: auto !important;
    text-align: right !important;
}

body.admin-rtl .admin__data-grid-action-columns-menu .admin__field-option {
    float: right !important;
    padding-left: 1rem !important;
    padding-right: 0 !important;
}

body.admin-rtl .admin__data-grid-header .admin__action-dropdown-footer-main-actions,
body.admin-rtl .admin__data-grid-header .admin__action-dropdown-footer-secondary-actions {
    float: none !important;
}

body.admin-rtl .admin__data-grid-header .admin__action-dropdown-menu-footer {
    display: flex !important;
    justify-content: space-between !important;
}

/* ==========================================================================
   Custom checkboxes and radios: box on the right of its label
   ========================================================================== */
body.admin-rtl .admin__control-checkbox + label,
body.admin-rtl .admin__control-radio + label,
body.admin-rtl .admin__control-checkbox + .admin__field-label,
body.admin-rtl .admin__control-radio + .admin__field-label {
    float: none !important;
    padding-left: 0 !important;
    padding-right: 2.6rem !important;
    text-align: right !important;
}

body.admin-rtl .admin__control-checkbox + label:before,
body.admin-rtl .admin__control-radio + label:before {
    float: right !important;
    margin: 1px -2.6rem 0 1rem !important;
}

body.admin-rtl .admin__control-radio:checked + label:after {
    left: auto !important;
    right: 3px !important;
}

/* Native checkboxes (e.g. "Use system value" in Stores › Configuration): gap on the label side */
body.admin-rtl .use-default input[type="checkbox"],
body.admin-rtl .admin__field-option > input[type="checkbox"]:not(.admin__control-checkbox) {
    margin-left: 0.6rem !important;
    margin-right: 0 !important;
}

/* ==========================================================================
   Grid filter panel: "from/to" labels on the right of their inputs
   ========================================================================== */
body.admin-rtl .admin__data-grid-filters fieldset.admin__form-field > .admin__form-field > .admin__form-field-label {
    float: right !important;
    text-align: left !important;
    padding-left: 1rem !important;
    padding-right: 0 !important;
}

body.admin-rtl .admin__data-grid-filters fieldset.admin__form-field > .admin__form-field > .admin__form-field-control {
    margin-left: 0 !important;
    margin-right: 25% !important;
}

body.admin-rtl .admin__data-grid-filters .admin__form-field-legend,
body.admin-rtl .admin__data-grid-filters .admin__data-grid-filters > .admin__form-field > .admin__form-field-label {
    text-align: right !important;
}


body.admin-rtl .admin__data-grid-filters .admin__control-text._has-datepicker {
    padding-left: 3.5rem !important;
    padding-right: 1rem !important;
}

body.admin-rtl .admin__data-grid-filters .admin__footer-main-actions {
    float: left !important;
    text-align: left !important;
}

/* Grouped fields (e.g. weight + unit, category + "New Category", date ranges): core pins the first
   sub-field's label at left: 0, i.e. the LTR label column. */
body.admin-rtl [class*="admin__control-grouped"] > .admin__field:first-child > .admin__field-label,
body.admin-rtl .admin__control-fields > .admin__field:first-child > .admin__field-label {
    left: auto !important;
    right: 0 !important;
    text-align: right !important;
}

/* Date picker popup: previous month on the right, next month on the left, arrows pointing outwards. */
body.admin-rtl .ui-datepicker .ui-datepicker-prev {
    left: auto !important;
    right: 1rem !important;
}

body.admin-rtl .ui-datepicker .ui-datepicker-next {
    left: 1rem !important;
    right: auto !important;
}

/* Label-less dynamic-row tables (footer builder, content page repeaters) use the full form width
   instead of a half-width control squeezed into the label column. */
body.admin-rtl .admin__field:not(:has(> .admin__field-label)) > .admin__field-control:has(> .admin__control-table-wrapper) {
    float: none !important;
    width: auto !important;
    margin-left: 3rem !important;
    margin-right: 0 !important;
}

/* Modal titles: the close button is on the left, so its reserved space moves there too. */
body.admin-rtl .modal-header .modal-title {
    margin-left: 5.7rem !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Grid select-all control: a text-less checkbox beside its dropdown toggle, kept on one line. */
body.admin-rtl .action-multicheck-wrap .admin__control-checkbox + label {
    float: right !important;
    padding: 0 !important;
}

body.admin-rtl .action-multicheck-wrap .admin__control-checkbox + label:before {
    margin: 0 !important;
}

body.admin-rtl .action-multicheck-wrap .action-multicheck-toggle {
    float: left !important;
    margin-left: 0 !important;
    margin-right: -1px !important;
}

/* Message boxes: padding belongs to each message, not to the wrapper (the wrapper inset them unevenly). */
body.admin-rtl .messages {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Sticky grid header: core copies each grid column width into the sticky header's width attributes, but
   with automatic table layout the (wider) Arabic header text overrides them; a fixed layout honours them. */
body.admin-rtl .sticky-header .data-grid {
    table-layout: fixed !important;
}

/* Sticky grid toolbar (shown while scrolling): Actions, count, filters, views and pager from the right,
   search on the left - the mirror of core's sticky row. */
body.admin-rtl .sticky-header .admin__data-grid-header-row > .action-select-wrap,
body.admin-rtl .sticky-header .admin__data-grid-header-row > .admin__control-support-text,
body.admin-rtl .sticky-header .admin__data-grid-header-row > .data-grid-filters-actions-wrap,
body.admin-rtl .sticky-header .admin__data-grid-header-row > .admin__data-grid-actions-wrap,
body.admin-rtl .sticky-header .admin__data-grid-header-row > .admin__data-grid-pager-wrap {
    float: right !important;
}

body.admin-rtl .sticky-header .admin__data-grid-header-row > .admin__control-support-text {
    margin-left: 0 !important;
    margin-right: 1.5rem !important;
}

body.admin-rtl .sticky-header .admin__data-grid-header-row > .data-grid-search-control-wrap {
    float: left !important;
}

/* Side navigation: the active tab's bar and indent sit on the outer (right) edge; the link covers the
   navigation's inner (left) border towards the content. */
body.admin-rtl .admin__page-nav-item._active,
body.admin-rtl .admin__page-nav-item.ui-state-active {
    border-left: 0 !important;
    border-right: 3px solid #eb5202 !important;
    margin-left: 0 !important;
    margin-right: 7px !important;
}

body.admin-rtl .admin__page-nav-item > a,
body.admin-rtl .admin__page-nav-link {
    border-right: 0 !important;
    margin-right: 0 !important;
}

body.admin-rtl .admin__page-nav-item._active > a,
body.admin-rtl .admin__page-nav-item.ui-state-active > a {
    border-left: 1px solid #fff !important;
    margin-left: -1px !important;
}

/* Grid per-page menu: values read from the right; the space for edit/delete icons moves to the left. */
body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-items {
    text-align: right !important;
}

body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-item-action {
    text-align: right !important;
    padding-left: 6rem !important;
    padding-right: 1.5rem !important;
}

body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-item ._edit,
body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-item .action-edit,
body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-item .action-delete,
body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-item .action-save {
    left: 0 !important;
    right: auto !important;
}

body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-items .action-secondary,
body.admin-rtl .admin__data-grid-pager-wrap .selectmenu-items > .action-default {
    float: right !important;
    margin-right: 1.5rem !important;
    margin-left: 0 !important;
}

/* Notifications dropdown: dismiss button on the left end of each entry. */
body.admin-rtl .notifications-entry .notifications-close {
    left: 0 !important;
    right: auto !important;
}

body.admin-rtl .notifications-entry .notifications-entry-title {
    margin-right: 0 !important;
}

/* Date picker weekday names: IBM Plex Arabic is wider than the default font. */
body.admin-rtl .ui-datepicker .ui-datepicker-calendar {
    table-layout: fixed !important;
}

body.admin-rtl .ui-datepicker .ui-datepicker-calendar th,
body.admin-rtl .ui-datepicker .ui-datepicker-calendar th span {
    font-size: 1rem !important;
    letter-spacing: -0.02em;
    padding-left: 1px !important;
    padding-right: 1px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
}

/* Legacy grids (cache, indexes, cart rules, users): mass action on the right, record count on the left,
   and the select-all control over the checkbox column at the right edge. */
body.admin-rtl ._massaction.admin__data-grid-header-row .admin__grid-massaction {
    float: right !important;
}

body.admin-rtl ._massaction.admin__data-grid-header-row > .admin__control-support-text {
    float: left !important;
    text-align: left !important;
}

body.admin-rtl ._massaction.admin__data-grid-header-row .mass-select-wrap {
    left: auto !important;
    right: 0 !important;
    margin-left: 0 !important;
    margin-right: 1.1rem !important;
}

/* Rule condition trees (cart and catalog price rules): the dotted guide runs beside the conditions on the right. */
body.admin-rtl .rule-tree .rule-param-children,
body.admin-rtl .rule-tree ul {
    border-left: 0 !important;
    border-right: 1px dotted #a6a6a6 !important;
}

/* Order comment history: keep each meta segment (date, time, status, author, notified flag) on one line. */
body.admin-rtl .note-list-item .note-list-date,
body.admin-rtl .note-list-item .note-list-time,
body.admin-rtl .note-list-item .note-list-status,
body.admin-rtl .note-list-item .note-list-customer,
body.admin-rtl .note-list-item .note-list-admin-author {
    white-space: nowrap;
    display: inline-block;
}

/* Configuration navigation group titles with a vendor logo before the text (e.g. Amasty). */
body.admin-rtl .admin__page-nav-title strong:before {
    margin-left: 0.8rem !important;
    margin-right: 0 !important;
}

/* Dynamic tables in forms and configuration: the "add" button sits at the start (right) of the footer. */
body.admin-rtl .admin__control-table tfoot .col-actions-add,
body.admin-rtl .admin__dynamic-rows tfoot td {
    text-align: right !important;
}

/* Content page builder (MMD_ContentPage): stacked section cards read from the right and stay inside the
   content column (the module sets the container to 100% of a row that starts 3rem outside the column). */
body.admin-rtl .mmd-content-page-sections .admin__dynamic-rows .admin__field-label {
    text-align: right !important;
}

body.admin-rtl .mmd-content-page-sections > .admin__field-control {
    width: auto !important;
    margin-left: 3rem !important;
    margin-right: 0 !important;
}

/* Storefront previews for non-Arabic store views render left-to-right, as the storefront does
   (MMD_ContentPage marks Arabic-store previews with _rtl). */
body.admin-rtl .mmd-section-preview__canvas:not(._rtl) {
    direction: ltr;
    text-align: left;
}

/* Native radios and checkboxes (custom templates, legacy forms): gap on the label side. */
body.admin-rtl input[type="radio"]:not(.admin__control-radio),
body.admin-rtl input[type="checkbox"]:not(.admin__control-checkbox) {
    margin-left: 0.6rem;
    margin-right: 0;
}

/* Page action buttons keep their label on one line; the bar wraps whole buttons instead. */
body.admin-rtl .page-actions-buttons {
    flex-wrap: wrap !important;
    row-gap: 1rem;
}

body.admin-rtl .page-actions-buttons > button,
body.admin-rtl .page-actions-buttons > .split-button > button {
    white-space: nowrap !important;
}

/* Legacy grid date/time cells (e.g. Index Management "Updated"): keep the time and its ص/م suffix together. */
body.admin-rtl .data-grid td[class*="col-updated"],
body.admin-rtl .data-grid td[class*="col-created"],
body.admin-rtl .data-grid td[class*="col-date"],
body.admin-rtl .data-grid td[class*="_at"] {
    white-space: nowrap;
}
