/* Persian RTL Enhancements */

/* RTL Direction for Persian */
body[dir="rtl"] {
    direction: rtl;
    text-align: right;
    font-family: 'Vazirmatn', 'Tahoma', 'Arial', sans-serif !important;
}

/* RTL Navigation */
body[dir="rtl"] .navbar-nav {
    padding-right: 0;
}

body[dir="rtl"] .navbar-nav .nav-link {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

/* RTL Dropdown */
body[dir="rtl"] .dropdown-menu {
    right: 0;
    left: auto;
    text-align: right;
}

body[dir="rtl"] .dropdown-item {
    text-align: right;
}

/* RTL Forms */
body[dir="rtl"] .form-check {
    padding-right: 1.25rem;
    padding-left: 0;
}

body[dir="rtl"] .form-check-input {
    margin-right: -1.25rem;
    margin-left: 0;
}

body[dir="rtl"] .form-check-label {
    margin-right: 0.5rem;
    margin-left: 0;
}

/* RTL Buttons */
body[dir="rtl"] .btn-group > .btn:not(:last-child):not(.dropdown-toggle) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

body[dir="rtl"] .btn-group > .btn:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

/* RTL Tables */
body[dir="rtl"] .table th,
body[dir="rtl"] .table td {
    text-align: right;
}

/* RTL Modals */
body[dir="rtl"] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

/* RTL Alerts */
body[dir="rtl"] .alert-dismissible .btn-close {
    right: auto;
    left: 0;
}

/* RTL Breadcrumbs */
body[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    float: right;
    padding-right: 0;
    padding-left: 0.5rem;
}

/* RTL Pagination */
body[dir="rtl"] .pagination {
    padding-right: 0;
}

body[dir="rtl"] .page-link {
    margin-right: -1px;
    margin-left: 0;
}

/* RTL Input Groups */
body[dir="rtl"] .input-group > .form-control:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

body[dir="rtl"] .input-group > .form-control:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

/* RTL List Groups */
body[dir="rtl"] .list-group-item {
    text-align: right;
}

/* RTL Cards */
body[dir="rtl"] .card-header {
    text-align: right;
}

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

/* RTL Sidebar */
body[dir="rtl"] .dash-sidebar {
    right: 0;
    left: auto;
}

/* Ensure main content not under sidebar (desktop) */
@media (min-width: 1025px) {
    body[dir="rtl"] .dash-container {
        margin-right: 260px !important; /* match sidebar width */
        margin-left: 0 !important;
    }
    /* Fix sidebar as a column and prevent independent scroll glitches */
    body[dir="rtl"] .dash-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        height: 100vh;
        overflow: visible;
    }
}

/* On tablets/mobiles let content be full width */
@media (max-width: 1024px) {
    body[dir="rtl"] .dash-container {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }
}

body[dir="rtl"] .dash-sidebar .dash-navbar {
    padding-right: 0;
    /* Prevent inner scrolling; let whole page scroll instead */
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
}

body[dir="rtl"] .dash-sidebar .dash-navbar li {
    text-align: right;
}

/* RTL Header */
body[dir="rtl"] .dash-header {
    text-align: right;
}

/* RTL Header toolbar alignment (move header icons group to the left side) */
body[dir="rtl"] .pcm-toolbar {
    margin-right: auto !important;
    margin-left: 0 !important;
    display: flex;
    justify-content: flex-start;
}
body[dir="rtl"] .pcm-toolbar .dash-head-link {
    margin-left: 8px;
    margin-right: 0;
}

/* Persian Typography Improvements */
body[dir="rtl"] {
    line-height: 1.8;
    letter-spacing: 0.01em;
}

body[dir="rtl"] h1,
body[dir="rtl"] h2,
body[dir="rtl"] h3,
body[dir="rtl"] h4,
body[dir="rtl"] h5,
body[dir="rtl"] h6 {
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

/* Persian Button Improvements */
body[dir="rtl"] .btn {
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* Persian Input Improvements */
body[dir="rtl"] input,
body[dir="rtl"] textarea,
body[dir="rtl"] select {
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* Persian Link Improvements */
body[dir="rtl"] a {
    text-decoration: none;
}

body[dir="rtl"] a:hover {
    text-decoration: none;
}

/* Persian Focus States */
body[dir="rtl"] .form-control:focus,
body[dir="rtl"] .form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Persian Loading States */
body[dir="rtl"] .spinner-border {
    margin-right: 0.5rem;
    margin-left: 0;
}

/* Persian Icon Alignments */
body[dir="rtl"] .icon-left {
    margin-right: 0;
    margin-left: 0.5rem;
}

body[dir="rtl"] .icon-right {
    margin-left: 0;
    margin-right: 0.5rem;
}

/* Persian Text Utilities */
body[dir="rtl"] .text-start {
    text-align: right !important;
}

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

body[dir="rtl"] .float-start {
    float: right !important;
}

body[dir="rtl"] .float-end {
    float: left !important;
}

/* Persian Margin and Padding Utilities */
body[dir="rtl"] .ms-auto {
    margin-right: auto !important;
    margin-left: 0 !important;
}

body[dir="rtl"] .me-auto {
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Persian Border Utilities */
body[dir="rtl"] .border-start {
    border-right: 1px solid #dee2e6 !important;
    border-left: 0 !important;
}

body[dir="rtl"] .border-end {
    border-left: 1px solid #dee2e6 !important;
    border-right: 0 !important;
} 