/**
 * KeraCRM - RTL (Right-to-Left) Stylesheet
 * Arabic Language Support
 */

/* ============================================
   Base RTL Overrides
   ============================================ */
[dir="rtl"] body,
body.rtl {
    direction: rtl;
    text-align: right;
}

/* ============================================
   Sidebar RTL
   ============================================ */
[dir="rtl"] .sidebar {
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-right: none;
}

[dir="rtl"] .sidebar .nav-link i {
    margin-left: 0.5rem;
    margin-right: 0;
}

[dir="rtl"] .offcanvas-start {
    right: 0;
    left: auto;
    transform: translateX(100%);
}

[dir="rtl"] .offcanvas.show {
    transform: translateX(0);
}

/* ============================================
   Header RTL
   ============================================ */
[dir="rtl"] .navbar-nav {
    padding-right: 0;
}

[dir="rtl"] .me-auto {
    margin-left: auto !important;
    margin-right: 0 !important;
}

[dir="rtl"] .ms-auto {
    margin-right: auto !important;
    margin-left: 0 !important;
}

/* ============================================
   Margins & Paddings RTL
   ============================================ */
[dir="rtl"] .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-4 { margin-left: 1.5rem !important; margin-right: 0 !important; }

[dir="rtl"] .ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-4 { margin-right: 1.5rem !important; margin-left: 0 !important; }

[dir="rtl"] .pe-1 { padding-left: 0.25rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-2 { padding-left: 0.5rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-3 { padding-left: 1rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-4 { padding-left: 1.5rem !important; padding-right: 0 !important; }

[dir="rtl"] .ps-1 { padding-right: 0.25rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-2 { padding-right: 0.5rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-3 { padding-right: 1rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-4 { padding-right: 1.5rem !important; padding-left: 0 !important; }

/* ============================================
   Text Alignment RTL
   ============================================ */
[dir="rtl"] .text-start {
    text-align: right !important;
}

[dir="rtl"] .text-end {
    text-align: left !important;
}

/* ============================================
   Form Elements RTL
   ============================================ */
[dir="rtl"] .form-control,
[dir="rtl"] .form-select {
    text-align: right;
}

[dir="rtl"] .input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

[dir="rtl"] .input-group > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating) {
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

[dir="rtl"] .input-group-text {
    border-left: 1px solid var(--border-color);
    border-right: none;
}

/* ============================================
   Dropdown RTL
   ============================================ */
[dir="rtl"] .dropdown-menu {
    text-align: right;
}

[dir="rtl"] .dropdown-menu-end {
    right: auto !important;
    left: 0 !important;
}

[dir="rtl"] .dropdown-toggle::after {
    margin-left: 0;
    margin-right: 0.5rem;
}

/* ============================================
   Tables RTL
   ============================================ */
[dir="rtl"] .table {
    text-align: right;
}

[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right;
}

/* ============================================
   Cards RTL
   ============================================ */
[dir="rtl"] .stat-card .stat-icon {
    right: auto;
    left: 1rem;
}

/* ============================================
   Buttons RTL
   ============================================ */
[dir="rtl"] .btn-group > .btn:not(:last-child):not(.dropdown-toggle) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;
}

[dir="rtl"] .btn-group > .btn:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
}

[dir="rtl"] .btn i + span,
[dir="rtl"] .btn span + i {
    margin-right: 0.5rem;
    margin-left: 0;
}

/* ============================================
   Breadcrumb RTL
   ============================================ */
[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    float: right;
    padding-left: 0.5rem;
    padding-right: 0;
}

/* ============================================
   Pagination RTL
   ============================================ */
[dir="rtl"] .pagination {
    padding-right: 0;
}

[dir="rtl"] .page-item:first-child .page-link {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
}

[dir="rtl"] .page-item:last-child .page-link {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;
}

/* ============================================
   Modal RTL
   ============================================ */
[dir="rtl"] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

/* ============================================
   Alerts RTL
   ============================================ */
[dir="rtl"] .alert-dismissible {
    padding-left: 3rem;
    padding-right: 1rem;
}

[dir="rtl"] .alert-dismissible .btn-close {
    left: 0;
    right: auto;
}

/* ============================================
   List Group RTL
   ============================================ */
[dir="rtl"] .list-group {
    padding-right: 0;
}

/* ============================================
   Float RTL
   ============================================ */
[dir="rtl"] .float-start {
    float: right !important;
}

[dir="rtl"] .float-end {
    float: left !important;
}

/* ============================================
   Border RTL
   ============================================ */
[dir="rtl"] .border-start {
    border-right: 1px solid var(--border-color) !important;
    border-left: none !important;
}

[dir="rtl"] .border-end {
    border-left: 1px solid var(--border-color) !important;
    border-right: none !important;
}

/* ============================================
   Position RTL
   ============================================ */
[dir="rtl"] .start-0 {
    right: 0 !important;
    left: auto !important;
}

[dir="rtl"] .end-0 {
    left: 0 !important;
    right: auto !important;
}

[dir="rtl"] .start-100 {
    right: 100% !important;
    left: auto !important;
}

[dir="rtl"] .translate-middle-x {
    transform: translateX(50%) !important;
}

/* ============================================
   Flex RTL
   ============================================ */
[dir="rtl"] .flex-row {
    flex-direction: row-reverse !important;
}

[dir="rtl"] .flex-row-reverse {
    flex-direction: row !important;
}

/* ============================================
   Icons RTL - Flip directional icons
   ============================================ */
[dir="rtl"] .bi-arrow-left::before { content: "\F135"; } /* arrow-right */
[dir="rtl"] .bi-arrow-right::before { content: "\F12F"; } /* arrow-left */
[dir="rtl"] .bi-chevron-left::before { content: "\F285"; } /* chevron-right */
[dir="rtl"] .bi-chevron-right::before { content: "\F284"; } /* chevron-left */
[dir="rtl"] .bi-box-arrow-right::before { content: "\F1C4"; } /* box-arrow-left */
[dir="rtl"] .bi-box-arrow-left::before { content: "\F1C5"; } /* box-arrow-right */
