/* ═══════════════════════════════════════════════════════════════
   RTL/LTR Dynamic Styles
   ═══════════════════════════════════════════════════════════════
   Purpose: Handle text direction changes for Arabic/English
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   1. Body & HTML Direction
   ═══════════════════════════════════════════════════════════════ */

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

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

/* ═══════════════════════════════════════════════════════════════
   2. Sidebar Position (Desktop Only)
   ═══════════════════════════════════════════════════════════════ */

@media (min-width: 769px) {
    html[dir="rtl"] .sidebar {
        right: 0;
        left: auto;
    }

    html[dir="ltr"] .sidebar {
        left: 0;
        right: auto;
    }

    html[dir="rtl"] .sidebar.collapsed {
        right: -280px;
    }

    html[dir="ltr"] .sidebar.collapsed {
        left: -280px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   3. Main Content Margin (Desktop Only) - Neutralized for overlay
   ═══════════════════════════════════════════════════════════════ */

@media (min-width: 769px) {
    html[dir="rtl"] .main-content,
    html[dir="ltr"] .main-content,
    html[dir="rtl"] .main-content.expanded,
    html[dir="ltr"] .main-content.expanded {
        margin: 0 !important; /* overlay sidebar: لا حجز مساحة */
    }
}

/* Mobile: No margin for main-content */
@media (max-width: 768px) {
    html[dir="rtl"] .main-content,
    html[dir="ltr"] .main-content {
        margin: 0 !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   4. Text Alignment
   ═══════════════════════════════════════════════════════════════ */

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

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

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

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

/* ═══════════════════════════════════════════════════════════════
   5. Padding & Margin Utilities
   ═══════════════════════════════════════════════════════════════ */

html[dir="rtl"] .ps-1 { padding-right: 0.25rem !important; padding-left: 0 !important; }
html[dir="rtl"] .ps-2 { padding-right: 0.5rem !important; padding-left: 0 !important; }
html[dir="rtl"] .ps-3 { padding-right: 1rem !important; padding-left: 0 !important; }
html[dir="rtl"] .ps-4 { padding-right: 1.5rem !important; padding-left: 0 !important; }
html[dir="rtl"] .ps-5 { padding-right: 3rem !important; padding-left: 0 !important; }

html[dir="rtl"] .pe-1 { padding-left: 0.25rem !important; padding-right: 0 !important; }
html[dir="rtl"] .pe-2 { padding-left: 0.5rem !important; padding-right: 0 !important; }
html[dir="rtl"] .pe-3 { padding-left: 1rem !important; padding-right: 0 !important; }
html[dir="rtl"] .pe-4 { padding-left: 1.5rem !important; padding-right: 0 !important; }
html[dir="rtl"] .pe-5 { padding-left: 3rem !important; padding-right: 0 !important; }

html[dir="rtl"] .ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ms-4 { margin-right: 1.5rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ms-5 { margin-right: 3rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ms-auto { margin-right: auto !important; margin-left: 0 !important; }

html[dir="rtl"] .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
html[dir="rtl"] .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
html[dir="rtl"] .me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
html[dir="rtl"] .me-4 { margin-left: 1.5rem !important; margin-right: 0 !important; }
html[dir="rtl"] .me-5 { margin-left: 3rem !important; margin-right: 0 !important; }
html[dir="rtl"] .me-auto { margin-left: auto !important; margin-right: 0 !important; }

/* ═══════════════════════════════════════════════════════════════
   6. Float Utilities
   ═══════════════════════════════════════════════════════════════ */

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

html[dir="ltr"] .float-start {
    float: left !important;
}

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

html[dir="ltr"] .float-end {
    float: right !important;
}

/* ═══════════════════════════════════════════════════════════════
   7. Border Radius
   ═══════════════════════════════════════════════════════════════ */

html[dir="rtl"] .rounded-start {
    border-top-right-radius: 0.25rem !important;
    border-bottom-right-radius: 0.25rem !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

html[dir="ltr"] .rounded-start {
    border-top-left-radius: 0.25rem !important;
    border-bottom-left-radius: 0.25rem !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

html[dir="rtl"] .rounded-end {
    border-top-left-radius: 0.25rem !important;
    border-bottom-left-radius: 0.25rem !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

html[dir="ltr"] .rounded-end {
    border-top-right-radius: 0.25rem !important;
    border-bottom-right-radius: 0.25rem !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

/* ═══════════════════════════════════════════════════════════════
   8. Dropdown & Modals
   ═══════════════════════════════════════════════════════════════ */

html[dir="rtl"] .dropdown-menu {
    text-align: right;
    right: 0;
    left: auto;
}

html[dir="ltr"] .dropdown-menu {
    text-align: left;
    left: 0;
    right: auto;
}

html[dir="rtl"] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

html[dir="ltr"] .modal-header .btn-close {
    margin: -0.5rem -0.5rem -0.5rem auto;
}

/* ═══════════════════════════════════════════════════════════════
   9. Forms & Inputs
   ═══════════════════════════════════════════════════════════════ */

html[dir="rtl"] .form-control,
html[dir="rtl"] .form-select,
html[dir="rtl"] input,
html[dir="rtl"] textarea {
    text-align: right;
}

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

/* ═══════════════════════════════════════════════════════════════
   10. Breadcrumb
   ═══════════════════════════════════════════════════════════════ */

html[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    float: right;
    padding-left: 0.5rem;
    padding-right: 0;
    content: "‹";
}

html[dir="ltr"] .breadcrumb-item + .breadcrumb-item::before {
    float: left;
    padding-right: 0.5rem;
    padding-left: 0;
    content: "›";
}

/* ═══════════════════════════════════════════════════════════════
   11. Icons & Arrows
   ═══════════════════════════════════════════════════════════════ */

html[dir="rtl"] .material-icons.arrow-forward::before {
    content: "arrow_back";
}

html[dir="rtl"] .material-icons.arrow-back::before {
    content: "arrow_forward";
}

/* ═══════════════════════════════════════════════════════════════
   12. List Items
   ═══════════════════════════════════════════════════════════════ */

html[dir="rtl"] ul,
html[dir="rtl"] ol {
    padding-right: 2rem;
    padding-left: 0;
}

html[dir="ltr"] ul,
html[dir="ltr"] ol {
    padding-left: 2rem;
    padding-right: 0;
}

/* ═══════════════════════════════════════════════════════════════
   13. Transitions for Smooth Direction Change
   ═══════════════════════════════════════════════════════════════ */

.sidebar,
.main-content {
    transition: margin 0.3s ease, left 0.3s ease, right 0.3s ease;
}

