/**
 * Hushmand ERP — RTL shell overrides for Dari (fa).
 * Loaded only when html[dir="rtl"] via header.blade.php.
 * Typography: Bahij Helvetica Neue (see persian-font.css).
 * Scoped to erp-app-v4 shell; module forms may remain LTR until localized.
 */

html[dir="rtl"] body.erp-app-v4,
html[dir="rtl"] body.erp-rtl,
html[dir="rtl"] body.login-page-v3 {
    --brand-font: "Bahij Helvetica Neue", Tahoma, "Segoe UI", sans-serif;
    --persian-font: "Bahij Helvetica Neue", Tahoma, "Segoe UI", sans-serif;
    font-family: var(--brand-font) !important;
    font-synthesis: none;
}

html[dir="rtl"] body.erp-app-v4 {
    --erp-shell-offset: calc(var(--app-sidebar-width) + (var(--app-sidebar-gap) * 2));
}

/* Inherit Bahij across shell chrome; keep Font Awesome / glyph icons intact */
html[dir="rtl"] body.erp-app-v4 .right_col,
html[dir="rtl"] body.erp-app-v4 .top_nav,
html[dir="rtl"] body.erp-app-v4 .left_col,
html[dir="rtl"] body.erp-app-v4 .x_panel,
html[dir="rtl"] body.erp-app-v4 .x_title h2,
html[dir="rtl"] body.erp-app-v4 .form-control,
html[dir="rtl"] body.erp-app-v4 .btn,
html[dir="rtl"] body.erp-app-v4 label,
html[dir="rtl"] body.erp-app-v4 .table,
html[dir="rtl"] body.erp-app-v4 .modal-content,
html[dir="rtl"] body.erp-app-v4 .chosen-container,
html[dir="rtl"] body.erp-app-v4 .select2-container,
html[dir="rtl"] body.erp-app-v4 .dataTables_wrapper,
html[dir="rtl"] body.erp-app-v4 .nav.side-menu,
html[dir="rtl"] body.erp-app-v4 .nav.child_menu,
html[dir="rtl"] body.erp-app-v4 .TabbedPanelsTab,
html[dir="rtl"] body.erp-app-v4 .TabbedPanelsTabGroup,
html[dir="rtl"] body.erp-rtl .form-control,
html[dir="rtl"] body.erp-rtl .btn,
html[dir="rtl"] body.erp-rtl label,
html[dir="rtl"] body.erp-rtl .table,
html[dir="rtl"] body.login-page-v3 .login-shell {
    font-family: var(--brand-font);
    font-synthesis: none;
}

/* Beat style.css Poppins rules on body / tables / labels */
html[dir="rtl"] body.erp-app-v4,
html[dir="rtl"] body.erp-app-v4 .well h4,
html[dir="rtl"] body.erp-app-v4 .well p,
html[dir="rtl"] body.erp-app-v4 .panel-title,
html[dir="rtl"] body.erp-app-v4 .table th,
html[dir="rtl"] body.erp-app-v4 .table td,
html[dir="rtl"] body.erp-app-v4 .label,
html[dir="rtl"] body.erp-rtl,
html[dir="rtl"] body.erp-rtl .table th,
html[dir="rtl"] body.erp-rtl .table td,
html[dir="rtl"] body.erp-rtl .label,
html[dir="rtl"] body.login-page-v3 {
    font-family: var(--brand-font) !important;
    font-synthesis: none;
}

/* Icons must keep Font Awesome */
html[dir="rtl"] .fa,
html[dir="rtl"] [class^="fa-"],
html[dir="rtl"] [class*=" fa-"] {
    font-family: FontAwesome !important;
    font-synthesis: weight style;
}

/* Sidebar column — viewport right; inner content flush to physical right edge (desktop) */
@media (min-width: 992px) {
    html[dir="rtl"] body.erp-app-v4.nav-md .container.body .col-md-3.left_col {
        float: right !important;
        left: auto !important;
        right: var(--app-sidebar-gap) !important;
        display: flex !important;
        flex-direction: column !important;
        direction: ltr !important;
        padding: 0 !important;
    }
}

@media (min-width: 992px) {
    html[dir="rtl"] body.erp-app-v4.nav-md .container.body .col-md-3.left_col.erp-dual-nav {
        flex-direction: row-reverse !important;
        direction: ltr !important;
    }

    html[dir="rtl"] body.erp-app-v4 .erp-subnav.scroll-view {
        direction: rtl !important;
        text-align: right;
    }

    html[dir="rtl"] body.erp-app-v4 .erp-rail__item.is-active {
        box-shadow: inset -3px 0 0 var(--brand-primary);
    }

    /* Content-facing edge on RTL (sidebar is on the right) */
    html[dir="rtl"] body.erp-app-v4 .erp-subnav__toggle {
        right: auto !important;
        left: -14px !important;
    }

    html[dir="rtl"] body.erp-app-v4 .erp-subnav__toggle i {
        transform: scaleX(-1);
    }
}

html[dir="rtl"] body.erp-app-v4 .left_col.scroll-view,
html[dir="rtl"] body.erp-app-v4 .erp-subnav.scroll-view {
    direction: rtl !important;
    text-align: right;
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 auto !important;
    align-items: stretch !important;
}

html[dir="rtl"] body.erp-app-v4 .left_col.scroll-view > .nav_title,
html[dir="rtl"] body.erp-app-v4 .left_col.scroll-view > .sidebar-profile,
html[dir="rtl"] body.erp-app-v4 .left_col.scroll-view > #sidebar-menu,
html[dir="rtl"] body.erp-app-v4 .erp-subnav.scroll-view > .nav_title,
html[dir="rtl"] body.erp-app-v4 .erp-subnav.scroll-view > .sidebar-profile,
html[dir="rtl"] body.erp-app-v4 .erp-subnav.scroll-view > #sidebar-menu {
    width: 100% !important;
    max-width: 100% !important;
    align-self: stretch !important;
    box-sizing: border-box;
}

html[dir="rtl"] body.erp-app-v4 .nav_title {
    float: none !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
}

html[dir="rtl"] body.erp-app-v4 .site_title--logo {
    padding: 22px 6px 16px 20px !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-drawer-header .site_title--logo {
    padding: 0 !important;
}

html[dir="rtl"] body.erp-app-v4 .site_title__logo-wrap {
    width: 100% !important;
    margin: 0 auto !important;
    justify-content: center !important;
}

html[dir="rtl"] body.erp-app-v4 .sidebar-profile {
    margin: 12px 0 10px 14px !important;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu.main_menu_side {
    direction: rtl !important;
    text-align: right;
    padding: 8px 12px 20px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .menu_section {
    padding: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .menu_section h3,
html[dir="rtl"] body.erp-app-v4 #sidebar-menu .menu_section h3.erp-subnav__section-title {
    text-align: right;
    margin: 8px 10px 14px 4px !important;
    padding: 4px 2px !important;
    line-height: 1.6 !important;
    letter-spacing: 0 !important;
    overflow: visible;
    white-space: normal;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu {
    width: 100% !important;
    max-width: 100% !important;
    padding-right: 0 !important;
    margin-right: 0 !important;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu > li {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .parent_menue {
    text-align: right;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu > li > a {
    direction: rtl !important;
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 11px 10px 11px 14px !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu > li > a > i.fa {
    margin-right: 0 !important;
    margin-left: 0 !important;
    flex-shrink: 0 !important;
}

/* Sidebar menu chevrons — flex auto-margin; do not mirror for dir=rtl */
html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu > li > a > span.fa,
html[dir="rtl"] body.erp-app-v4 #sidebar-menu .main_menu span.fa {
    float: none !important;
    margin-left: auto !important;
    margin-right: 0 !important;
    flex-shrink: 0 !important;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.child_menu {
    padding-right: 0 !important;
    padding-left: 6px !important;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.child_menu li a {
    padding: 8px 36px 8px 12px !important;
    margin-right: 0 !important;
    margin-left: 8px !important;
    text-align: right;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.child_menu li {
    padding-right: 0 !important;
    padding-left: 0 !important;
}

html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu > li.active > a,
html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu > li.current-page > a {
    padding-right: 10px !important;
    padding-left: 12px !important;
}

html[dir="rtl"] body.erp-app-v4 .nav.side-menu > li > a:hover,
html[dir="rtl"] body.erp-app-v4 .nav.side-menu > li > a:focus {
    transform: translateX(-1px);
}

/* Bootstrap 3 utility flips */
html[dir="rtl"] .pull-right {
    float: left !important;
}

html[dir="rtl"] .pull-left {
    float: right !important;
}

html[dir="rtl"] .text-right {
    text-align: left !important;
}

html[dir="rtl"] .text-left {
    text-align: right !important;
}

/* Module forms — x_panel toolbars, labels, tables */
html[dir="rtl"] body.erp-app-v4 .right_col .x_title h2,
html[dir="rtl"] body.erp-app-v4 .right_col .x_content,
html[dir="rtl"] body.erp-app-v4 .x_panel .form-group label,
html[dir="rtl"] body.erp-app-v4 .x_panel .control-label {
    text-align: right;
}

html[dir="rtl"] body.erp-app-v4 .right_col .x_title h2,
html[dir="rtl"] body.erp-app-v4 .x_panel > .x_title h2 {
    float: right;
}

/* Horizontal forms — label right of input (Bootstrap 3 form-label-left) */
html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left .form-group,
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left .form-group {
    direction: rtl;
}

html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left .control-label,
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left .control-label {
    float: right;
    /* Label column is to the right of the input — align text toward the input, not the page edge */
    text-align: left !important;
    padding-left: 0;
    padding-right: 12px;
}

html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left .form-group > [class*="col-"],
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left .form-group > [class*="col-"] {
    float: right;
}

html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left .form-control,
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left .form-control,
html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left .select2-container,
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left .select2-container,
html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left .chosen-container,
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left .chosen-container {
    text-align: right;
}

html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left [class*="col-md-offset-"],
html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left [class*="col-sm-offset-"],
html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left [class*="col-xs-offset-"],
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left [class*="col-md-offset-"],
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left [class*="col-sm-offset-"],
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left [class*="col-xs-offset-"] {
    margin-left: 0;
}

html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left .col-md-offset-2,
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left .col-md-offset-2 {
    margin-right: 16.66666667%;
}

html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left .col-md-offset-3,
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left .col-md-offset-3 {
    margin-right: 25%;
}

html[dir="rtl"] body.erp-app-v4 .right_col .form-horizontal.form-label-left .col-sm-offset-2,
html[dir="rtl"] body.erp-app-v4 .x_panel .form-horizontal.form-label-left .col-sm-offset-2 {
    margin-right: 16.66666667%;
}

/* Popup / Bootstrap panel forms (layouts.popup_layout has erp-rtl, not erp-app-v4) */
html[dir="rtl"] body.erp-rtl .panel,
html[dir="rtl"] body.erp-rtl .panel-body,
html[dir="rtl"] body.erp-rtl .panel-heading {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left .form-group {
    direction: rtl;
}

html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left .control-label {
    float: right !important;
    /* Toward the input (left edge of the label column), not the far page edge */
    text-align: left !important;
    padding-left: 0 !important;
    padding-right: 12px !important;
}

html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left .form-group > [class*="col-"] {
    float: right !important;
}

html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left .form-control,
html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left textarea,
html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left .note-editor .note-editable {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left [class*="col-md-offset-"],
html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left [class*="col-sm-offset-"],
html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left [class*="col-xs-offset-"] {
    margin-left: 0 !important;
}

html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left .col-md-offset-2 {
    margin-right: 16.66666667% !important;
}

html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left .col-md-offset-3 {
    margin-right: 25% !important;
}

html[dir="rtl"] body.erp-rtl .panel .form-horizontal.form-label-left .col-sm-offset-2 {
    margin-right: 16.66666667% !important;
}

html[dir="rtl"] body.erp-rtl .note-editor.note-frame {
    direction: rtl;
}

html[dir="rtl"] body.erp-rtl .note-toolbar {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] body.erp-rtl .note-editable {
    direction: rtl !important;
    text-align: right !important;
}

html[dir="rtl"] body.erp-app-v4 .x_panel h4.text-primary[style*="margin-left"] {
    margin-left: 0 !important;
    margin-right: 80px;
}

html[dir="rtl"] body.erp-app-v4 .nav.navbar-right.panel_toolbox {
    float: left !important;
}

html[dir="rtl"] body.erp-app-v4 .x_content > .row .pull-right.btn,
html[dir="rtl"] body.erp-app-v4 .x_content .pull-right.btn {
    float: left !important;
}

html[dir="rtl"] body.erp-app-v4 .x_content > .row .pull-left.btn,
html[dir="rtl"] body.erp-app-v4 .x_content .pull-left.btn {
    float: right !important;
}

html[dir="rtl"] body.erp-app-v4 .table th,
html[dir="rtl"] body.erp-app-v4 .table td {
    text-align: right;
}

html[dir="rtl"] body.erp-app-v4 .dataTables_wrapper .dataTables_filter {
    text-align: left;
}

html[dir="rtl"] body.erp-app-v4 .dataTables_wrapper .dataTables_filter input {
    margin-left: 0;
    margin-right: 0.5em;
}

html[dir="rtl"] body.erp-app-v4 .dataTables_wrapper .dataTables_length {
    text-align: right;
}

html[dir="rtl"] body.erp-app-v4 .dataTables_wrapper .dataTables_info {
    text-align: right;
}

html[dir="rtl"] body.erp-app-v4 .dataTables_wrapper .dataTables_paginate {
    text-align: left;
    float: left !important;
}

html[dir="rtl"] body.erp-app-v4 .dataTables_wrapper .dataTables_paginate .pagination {
    direction: rtl;
}

html[dir="rtl"] body.erp-app-v4 .dataTables_wrapper .dataTables_length select {
    margin-left: 0.5em;
    margin-right: 0;
}

html[dir="rtl"] body.erp-app-v4 .dataTables_wrapper .dataTables_scrollHeadInner,
html[dir="rtl"] body.erp-app-v4 .dataTables_wrapper .dataTables_scrollBody {
    direction: rtl;
}

/* Chosen.js */
html[dir="rtl"] .chosen-container {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .chosen-container-single .chosen-single {
    direction: rtl;
    text-align: right;
    padding-right: 12px;
    padding-left: 28px;
}

html[dir="rtl"] .chosen-container-single .chosen-single div {
    left: 0;
    right: auto;
}

html[dir="rtl"] .chosen-container-single .chosen-single span {
    margin-right: 0;
    margin-left: 26px;
}

html[dir="rtl"] .chosen-container .chosen-drop {
    direction: rtl;
    text-align: right;
    /* Keep drop in-flow for RTL; never park it at left:-9999px */
    left: 0;
}

html[dir="rtl"] .chosen-container-single .chosen-search input[type="text"] {
    background-position: -38px -20px, left 6px center;
    padding-left: 28px;
    padding-right: 8px;
}

html[dir="rtl"] .chosen-container .chosen-results li {
    text-align: right;
}

html[dir="rtl"] .chosen-container-multi .chosen-choices li.search-choice {
    float: right;
    margin: 3px 0 3px 5px;
}

/* Select2 */
html[dir="rtl"] .select2-container--default .select2-selection--single {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    text-align: right;
    padding-right: 12px;
    padding-left: 28px;
}

html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__arrow {
    left: 6px;
    right: auto;
}

html[dir="rtl"] .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .select2-dropdown {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .select2-results__option {
    text-align: right;
}

/* Modals */
html[dir="rtl"] .modal-header .close {
    float: left;
    margin-left: 0;
    margin-right: -2px;
}

html[dir="rtl"] .modal-footer {
    text-align: left;
}

html[dir="rtl"] .modal-footer .btn + .btn {
    margin-left: 0;
    margin-right: 5px;
}

html[dir="rtl"] .modal-header {
    direction: rtl;
    text-align: right;
}

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

/* Modal horizontal forms — process mapping popups, notification modals, etc. */
html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left .form-group,
html[dir="rtl"] .modal .form-horizontal.form-label-left .form-group {
    direction: rtl;
}

html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left .control-label,
html[dir="rtl"] .modal .form-horizontal.form-label-left .control-label {
    float: right;
    text-align: left !important;
    padding-left: 0;
    padding-right: 12px;
}

html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left .form-group > [class*="col-"],
html[dir="rtl"] .modal .form-horizontal.form-label-left .form-group > [class*="col-"] {
    float: right;
}

html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left .form-control,
html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left textarea,
html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left select,
html[dir="rtl"] .modal .form-horizontal.form-label-left .form-control,
html[dir="rtl"] .modal .form-horizontal.form-label-left textarea,
html[dir="rtl"] .modal .form-horizontal.form-label-left select {
    text-align: right;
}

html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left .form-control[dir="auto"],
html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left textarea[dir="auto"],
html[dir="rtl"] .modal .form-horizontal.form-label-left .form-control[dir="auto"],
html[dir="rtl"] .modal .form-horizontal.form-label-left textarea[dir="auto"] {
    text-align: start;
    unicode-bidi: plaintext;
}

html[dir="ltr"] .modal .form-horizontal.form-label-left .form-control[dir="auto"],
html[dir="ltr"] .modal .form-horizontal.form-label-left textarea[dir="auto"] {
    text-align: start;
    unicode-bidi: plaintext;
}

html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left [class*="col-md-offset-"],
html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left [class*="col-sm-offset-"],
html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left [class*="col-xs-offset-"],
html[dir="rtl"] .modal .form-horizontal.form-label-left [class*="col-md-offset-"],
html[dir="rtl"] .modal .form-horizontal.form-label-left [class*="col-sm-offset-"],
html[dir="rtl"] .modal .form-horizontal.form-label-left [class*="col-xs-offset-"] {
    margin-left: 0;
}

html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left .col-md-offset-2,
html[dir="rtl"] .modal .form-horizontal.form-label-left .col-md-offset-2 {
    margin-right: 16.66666667%;
}

html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left .col-md-offset-3,
html[dir="rtl"] .modal .form-horizontal.form-label-left .col-md-offset-3 {
    margin-right: 25%;
}

html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left .col-md-offset-4,
html[dir="rtl"] .modal .form-horizontal.form-label-left .col-md-offset-4 {
    margin-right: 33.33333333%;
}

html[dir="rtl"] body.erp-app-v4 .modal .form-horizontal.form-label-left .col-sm-offset-2,
html[dir="rtl"] .modal .form-horizontal.form-label-left .col-sm-offset-2 {
    margin-right: 16.66666667%;
}

html[dir="ltr"] .modal-header,
html[dir="ltr"] .modal-body {
    direction: ltr;
    text-align: left;
}

html[dir="ltr"] .modal .form-horizontal.form-label-left .form-group {
    direction: ltr;
}

html[dir="ltr"] .modal .form-horizontal.form-label-left .control-label {
    text-align: right;
}

html[dir="ltr"] .modal .form-horizontal.form-label-left .form-control,
html[dir="ltr"] .modal .form-horizontal.form-label-left textarea,
html[dir="ltr"] .modal .form-horizontal.form-label-left select {
    text-align: left;
}

html[dir="rtl"] body.erp-app-v4 .title_left,
html[dir="rtl"] body.erp-app-v4 .page-title {
    text-align: right;
    float: right;
}

/* Desktop shell — content area */
html[dir="rtl"] body.erp-app-v4.nav-md .container.body .right_col {
    margin-left: 0 !important;
    margin-right: var(--erp-shell-offset) !important;
}

html[dir="rtl"] .erp-app-v4 .top_nav.erp-topbar {
    margin-left: 0 !important;
    margin-right: var(--erp-shell-offset) !important;
}

html[dir="rtl"] .erp-app-v4 footer {
    margin-left: 0 !important;
    margin-right: var(--erp-shell-offset);
}

html[dir="rtl"] .erp-app-v4 footer .pull-right {
    float: left !important;
}

/* Sidebar profile accent */
html[dir="rtl"] body.erp-app-v4 .sidebar-profile__card {
    direction: rtl;
    border-left: 1px solid var(--apple-gray-5) !important;
    border-right: 3px solid var(--brand-primary) !important;
}

/* Child menu tree lines */
html[dir="rtl"] .nav-md ul.nav.child_menu li:before {
    left: auto !important;
    right: 18px !important;
}

html[dir="rtl"] .nav-md ul.nav.child_menu li:after {
    left: auto !important;
    right: 21px !important;
    border-left: none !important;
    border-right: 1px solid rgba(255, 255, 255, 0.22);
}

html[dir="rtl"] body.erp-app-v4 .nav-md ul.nav.child_menu li:after {
    border-right-color: rgba(100, 116, 139, 0.35);
}

html[dir="rtl"] .nav.child_menu li.active > a,
html[dir="rtl"] .nav.child_menu li.current-page > a {
    box-shadow: inset -2px 0 0 var(--brand-primary-bright) !important;
}

/* Top navigation dropdowns */
html[dir="rtl"] .top-nav__notify-dropdown {
    left: 0 !important;
    right: auto !important;
}

html[dir="rtl"] .top-nav__notify-btn .badge,
html[dir="rtl"] .top-nav__notify-badge {
    right: auto !important;
    left: -4px !important;
    inset-inline-end: -4px !important;
    inset-inline-start: auto !important;
}

html[dir="rtl"] .top-nav__notify-dropdown-footer .fa-angle-right {
    transform: scaleX(-1);
}

html[dir="rtl"] .dropdown-usermenu.pull-right {
    left: 0 !important;
    right: auto !important;
}

html[dir="rtl"] .top_nav .navbar-right.top-nav__actions {
    padding-left: 12px;
    padding-right: 4px;
}

html[dir="rtl"] .top-nav__user-chevron {
    margin-left: 0;
    margin-right: 4px;
}

/* Employee profile page — RTL spacing */
html[dir="rtl"] .erp-app-v4 .erp-employee-banner__aside {
    align-items: flex-start;
}

html[dir="rtl"] .erp-app-v4 .erp-employee-banner__join {
    text-align: right;
}

html[dir="rtl"] .erp-app-v4 .erp-employee-banner__name,
html[dir="rtl"] .erp-app-v4 .erp-employee-banner__id,
html[dir="rtl"] .erp-app-v4 .erp-employee-banner__line {
    text-align: right;
}

html[dir="rtl"] .erp-app-v4 .erp-employee-banner__line {
    direction: ltr;
    unicode-bidi: plaintext;
}

html[dir="rtl"] .erp-app-v4 .erp-employee-profile__nav .tabs-left {
    border-left: none;
    border-right: none;
}

html[dir="rtl"] .erp-app-v4 .erp-employee-profile__nav .tabs-left > li > a {
    text-align: right;
    justify-content: flex-start;
}

html[dir="rtl"] .erp-app-v4 .erp-employee-profile__table th {
    text-align: right;
}

html[dir="rtl"] .erp-app-v4 .erp-employee-profile__table td {
    text-align: right;
    direction: ltr;
    unicode-bidi: plaintext;
}

/* Profile body — pin section nav to physical RIGHT in Dari/RTL (same pattern as dash-tasks) */
html[dir="rtl"] .erp-app-v4 .erp-employee-profile__body {
    display: flex !important;
    direction: ltr !important;
    flex-direction: row !important;
    flex-wrap: wrap;
}

html[dir="rtl"] .erp-app-v4 .erp-employee-profile__nav {
    order: 2 !important;
    direction: rtl !important;
    text-align: right !important;
}

html[dir="rtl"] .erp-app-v4 .erp-employee-profile__content {
    order: 1 !important;
    direction: rtl !important;
    text-align: right !important;
}

html[dir="rtl"] .erp-app-v4 .erp-employee-profile__content .x_title h2 {
    float: right;
    text-align: right;
}

@media (max-width: 991px) {
    html[dir="rtl"] .erp-app-v4 .erp-employee-banner__aside {
        align-items: stretch;
    }

    html[dir="rtl"] .erp-app-v4 .erp-employee-profile__body {
        direction: rtl !important;
        flex-direction: column !important;
    }

    html[dir="rtl"] .erp-app-v4 .erp-employee-profile__nav,
    html[dir="rtl"] .erp-app-v4 .erp-employee-profile__content {
        order: 0 !important;
        width: 100% !important;
    }
}

/* Self-portal card CTA arrow */
html[dir="rtl"] .portal-card-v2__cta .fa-arrow-right {
    transform: scaleX(-1);
}

/* Preserve intentional RTL islands (Jalali datetime) */
html[dir="rtl"] .top-nav__datetime-hejri {
    direction: rtl;
}

/* ── RTL Persian type scale (Bahij reads smaller at Latin sizes) ── */
html[dir="rtl"] body.erp-app-v4 {
    font-size: 15px;
    line-height: 1.65;
}

html[dir="rtl"] body.erp-app-v4 .menu_section h3 {
    font-size: 14px !important;
    letter-spacing: 0 !important;
    font-weight: 700 !important;
    text-transform: none !important;
    color: var(--apple-label-secondary) !important;
    line-height: 1.6 !important;
}

html[dir="rtl"] body.erp-app-v4 .nav.side-menu > li > a,
html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu > li > a,
html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu > li > a .parent_menue {
    font-size: 15px !important;
    line-height: 1.45 !important;
}

html[dir="rtl"] body.erp-app-v4 .nav.side-menu > li > a > i.fa {
    font-size: 15px !important;
}

html[dir="rtl"] body.erp-app-v4 .nav.child_menu li a,
html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.child_menu li a {
    font-size: 14px !important;
    line-height: 1.45 !important;
}

html[dir="rtl"] body.erp-app-v4 .sidebar-profile__card {
    text-align: right;
}

html[dir="rtl"] body.erp-app-v4 .sidebar-profile__body {
    text-align: right;
    align-items: flex-start;
}

html[dir="rtl"] body.erp-app-v4 .sidebar-profile__label {
    font-size: 14px !important;
}

html[dir="rtl"] body.erp-app-v4 .sidebar-profile__name {
    font-size: 17px !important;
}

html[dir="rtl"] .erp-app-v4 .top-nav__app-name {
    font-size: 16px;
}

html[dir="rtl"] .erp-app-v4 .top-nav__app-tagline {
    font-size: 12px;
    letter-spacing: 0.04em;
}

html[dir="rtl"] .erp-app-v4 .erp-page-welcome__title {
    font-size: clamp(1.85rem, 2.6vw, 2.35rem);
    line-height: 1.25;
}

html[dir="rtl"] .erp-app-v4 .erp-page-welcome__subtitle {
    font-size: 16px;
    line-height: 1.55;
}

html[dir="rtl"] .erp-app-v4 .top-nav__user-name {
    font-size: 14px !important;
}

html[dir="rtl"] .erp-app-v4 .top-nav__user-role {
    font-size: 12px !important;
}

html[dir="rtl"] .erp-app-v4 .top-nav__datetime-time {
    font-size: 13px !important;
}

html[dir="rtl"] .erp-app-v4 .top-nav__datetime-gregorian,
html[dir="rtl"] .erp-app-v4 .top-nav__datetime-hejri {
    font-size: 12px !important;
}

html[dir="rtl"] body.erp-app-v4 .right_col .x_title h2 {
    font-size: 20px;
    line-height: 1.35;
}

html[dir="rtl"] body.erp-app-v4 .x_panel .form-group label,
html[dir="rtl"] body.erp-app-v4 .x_panel .control-label {
    font-size: 14px;
}

html[dir="rtl"] body.erp-app-v4 .form-control,
html[dir="rtl"] body.erp-app-v4 .btn {
    font-size: 14px;
}

html[dir="rtl"] body.erp-app-v4 .TabbedPanelsTab {
    font-size: 14px;
    font-weight: 500;
}

html[dir="rtl"] body.erp-app-v4 .table th,
html[dir="rtl"] body.erp-app-v4 .table td {
    font-size: 14px;
    line-height: 1.5;
}

/* Self Portal quick-action cards */
html[dir="rtl"] .self-portal-cards__eyebrow {
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: none;
}

html[dir="rtl"] .self-portal-cards__heading {
    font-size: 28px;
    line-height: 1.25;
}

html[dir="rtl"] .self-portal-cards__subheading {
    font-size: 15px;
    line-height: 1.6;
}

html[dir="rtl"] .self-portal-cards__intro-badge {
    font-size: 13px;
}

html[dir="rtl"] .portal-grid-section__eyebrow {
    font-size: 13px;
    letter-spacing: 0.02em;
    text-transform: none;
    color: #86868b;
}

html[dir="rtl"] .portal-grid-section__title {
    font-size: 17px;
    color: #1d1d1f;
}

html[dir="rtl"] .portal-grid-section__toggle {
    font-size: 13px;
}

html[dir="rtl"] .portal-card-v2__badge {
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: none;
    padding: 5px 11px;
}

html[dir="rtl"] .portal-card-v2__title {
    font-size: 18px;
    line-height: 1.4;
}

html[dir="rtl"] .portal-card-v2__cta {
    font-size: 14px;
}

html[dir="rtl"] .portal-card-v2__cta .fa {
    font-size: 12px;
}

html[dir="rtl"] body.login-page-v3 {
    font-size: 15px;
    line-height: 1.65;
}

html[dir="rtl"] body.login-page-v3 .login-showcase__title {
    font-size: 32px;
    line-height: 1.3;
}

html[dir="rtl"] body.login-page-v3 .login-showcase__lead,
html[dir="rtl"] body.login-page-v3 .lc-input,
html[dir="rtl"] body.login-page-v3 .lc-btn {
    font-size: 15px;
}

@media (max-width: 991px) {
    html[dir="rtl"] .erp-app-v4 .top_nav.erp-topbar,
    html[dir="rtl"] body.erp-app-v4.nav-md .container.body .right_col,
    html[dir="rtl"] body.erp-app-v4.nav-sm .container.body .right_col,
    html[dir="rtl"] .erp-app-v4 footer {
        margin-right: 0 !important;
    }

    html[dir="rtl"] body.erp-app-v4.nav-md .container.body .right_col,
    html[dir="rtl"] body.erp-app-v4.nav-sm .container.body .right_col {
        padding: 0 max(12px, env(safe-area-inset-left)) calc(var(--erp-mobile-tabbar-height) + 20px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right)) !important;
    }

    html[dir="rtl"] .erp-app-v4 .erp-topbar__inner {
        padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-left)) 8px max(16px, env(safe-area-inset-right)) !important;
    }

    /* Closed drawer must stay hidden — global RTL nav-md rule uses display:flex */
    html[dir="rtl"] body.erp-app-v4.nav-md .container.body .col-md-3.left_col {
        display: none !important;
        pointer-events: none !important;
        visibility: hidden !important;
        left: auto !important;
        right: 0 !important;
    }

    /* Mobile full-page menu sheet — open from the right */
    html[dir="rtl"] body.erp-app-v4.nav-sm .container.body .col-md-3.left_col {
        display: flex !important;
        flex-direction: column !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        pointer-events: auto !important;
        visibility: visible !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    html[dir="rtl"] body.erp-app-v4.nav-sm .left_col.scroll-view,
    html[dir="rtl"] body.erp-app-v4.nav-sm .erp-subnav.scroll-view {
        border-radius: 0 !important;
    }

    html[dir="rtl"] body.erp-app-v4.nav-sm .nav.side-menu li a {
        text-align: right !important;
    }

    html[dir="rtl"] body.erp-app-v4.nav-sm .nav.child_menu li a {
        padding: 12px 48px 12px 14px !important;
    }

    html[dir="rtl"] body.erp-app-v4.nav-sm .nav.side-menu > li > a > span.fa {
        margin-left: 0 !important;
        margin-right: auto !important;
    }

    html[dir="rtl"] body.erp-app-v4.nav-sm #sidebar-menu.main_menu_side {
        padding: 8px 14px 40px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    html[dir="rtl"] body.erp-app-v4.nav-sm .erp-mobile-modules {
        direction: rtl;
        width: 100%;
    }

    html[dir="rtl"] body.erp-app-v4.nav-sm .erp-mobile-section-title {
        text-align: right;
    }

    html[dir="rtl"] .self-portal-cards__heading {
        font-size: 24px;
    }

    html[dir="rtl"] .portal-card-v2__title {
        font-size: 16px;
    }

    html[dir="rtl"] body.erp-app-v4 .nav.side-menu > li > a,
    html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu > li > a,
    html[dir="rtl"] body.erp-app-v4 #sidebar-menu .nav.side-menu > li > a .parent_menue {
        font-size: 15px !important;
    }
}

/* Dashboard task filter rail — physical RIGHT in RTL (Persian) */
html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks {
    direction: rtl !important;
    text-align: right !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__body {
    display: flex !important;
    /* LTR flex axis so `order` can pin the nav to the physical right */
    direction: ltr !important;
    flex-direction: row !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__nav {
    order: 2 !important;
    align-self: flex-start !important;
    direction: rtl !important;
    text-align: right !important;
    border-inline-end: 0 !important;
    border-right: 0 !important;
    border-left: 1px solid var(--apple-separator, #e5e5ea) !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__content {
    order: 1 !important;
    direction: rtl !important;
    text-align: right !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__tabs > li > a {
    justify-content: flex-start !important;
    text-align: right !important;
    flex-direction: row-reverse !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__header {
    direction: rtl !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__heading,
html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__panel-title,
html[dir="rtl"] body.erp-app-v4 .erp-dash-panel__title {
    flex-direction: row-reverse !important;
    justify-content: flex-start !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__add .fa {
    margin-left: 6px;
    margin-right: 0;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__table,
html[dir="rtl"] body.erp-app-v4 .erp-dash-panel__table {
    direction: rtl !important;
    text-align: right !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__empty,
html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__empty span {
    text-align: center !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__empty .fa {
    margin-left: auto !important;
    margin-right: auto !important;
}

html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__date,
html[dir="rtl"] body.erp-app-v4 .erp-dash-panel__table td[dir="ltr"] {
    direction: ltr !important;
    unicode-bidi: plaintext;
    text-align: right !important;
}

/* Legacy Bootstrap tabs-left inside box-body — float filter column to the right */
html[dir="rtl"] body.erp-app-v4 .box-body > .col-md-3:has(.tabs-left),
html[dir="rtl"] body.erp-app-v4 .box-body > .col-sm-3:has(.tabs-left) {
    float: right !important;
}

html[dir="rtl"] body.erp-app-v4 .box-body > .col-md-9:has(.tab-content),
html[dir="rtl"] body.erp-app-v4 .box-body > .col-sm-9:has(.tab-content) {
    float: left !important;
}

html[dir="rtl"] body.erp-app-v4 .nav.nav-tabs.tabs-left {
    border-right: 0 !important;
    border-left: 1px solid var(--erp-section-border, #e5e5ea) !important;
}

html[dir="rtl"] body.erp-app-v4 .nav.nav-tabs.tabs-left > li > a {
    border-radius: 0 6px 6px 0 !important;
    text-align: right !important;
}

@media (max-width: 991px) {
    html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__body {
        flex-direction: column !important;
        direction: rtl !important;
    }

    html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__nav,
    html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__content {
        order: 0 !important;
        width: 100% !important;
    }

    html[dir="rtl"] body.erp-app-v4 .erp-dash-tasks__nav {
        border-left: 0 !important;
        border-bottom: 1px solid var(--apple-separator, #e5e5ea) !important;
    }

    html[dir="rtl"] body.erp-app-v4 .box-body > .col-md-3:has(.tabs-left),
    html[dir="rtl"] body.erp-app-v4 .box-body > .col-md-9:has(.tab-content) {
        float: none !important;
        width: 100% !important;
    }
}

/* ── MdPersianDateTimePicker — Dari/RTL week starts on the right (شنبه) ──
   Plugin CSS forces LTR on the day grid (شنبه on the left). In RTL that
   reads wrong for the Jalali calendar; flip the Persian grid only.
   Gregorian mode keeps LTR. Header / time controls stay LTR so << / >>
   month-year buttons keep their intended order. */
html[dir="rtl"] [data-name="md-persiandatetimepicker"]:not([data-isgregorian="true"]) table.table-striped,
html[dir="rtl"] .popover.zIndexCorrected [data-name="md-persiandatetimepicker"]:not([data-isgregorian="true"]) table.table-striped {
    direction: rtl !important;
}

html[dir="rtl"] [data-name="md-persiandatetimepicker"] table[data-name="md-persiandatetimepicker-headertable"],
html[dir="rtl"] [data-name="md-persiandatetimepicker"] table[data-name="md-persiandatetimepicker-timepicker"],
html[dir="rtl"] .popover.zIndexCorrected [data-name="md-persiandatetimepicker"] table[data-name="md-persiandatetimepicker-headertable"],
html[dir="rtl"] .popover.zIndexCorrected [data-name="md-persiandatetimepicker"] table[data-name="md-persiandatetimepicker-timepicker"] {
    direction: ltr !important;
}

/* Date values: LTR digits, glued to the RTL field edge */
html[dir="rtl"] input.form-control[data-mddatetimepicker="true"],
html[dir="rtl"] input[data-mddatetimepicker="true"].form-control {
    direction: ltr;
    text-align: right;
    unicode-bidi: isolate;
}
