/**
 * RTL (Right-to-Left) Styles
 * أنماط اللغة العربية (من اليمين لليسار)
 */

/* ============================================
   RTL Base Styles
   ============================================ */
[dir="rtl"],
.rtl {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] body,
.rtl body {
    font-family: var(--font-family-ar, 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif);
}

/* ============================================
   Bootstrap RTL Overrides
   ============================================ */
[dir="rtl"] .me-1,
.rtl .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-2,
.rtl .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-3,
.rtl .me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-4,
.rtl .me-4 { margin-left: 1.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-5,
.rtl .me-5 { margin-left: 3rem !important; margin-right: 0 !important; }

[dir="rtl"] .ms-1,
.rtl .ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-2,
.rtl .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-3,
.rtl .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-4,
.rtl .ms-4 { margin-right: 1.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-5,
.rtl .ms-5 { margin-right: 3rem !important; margin-left: 0 !important; }

[dir="rtl"] .pe-1,
.rtl .pe-1 { padding-left: 0.25rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-2,
.rtl .pe-2 { padding-left: 0.5rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-3,
.rtl .pe-3 { padding-left: 1rem !important; padding-right: 0 !important; }

[dir="rtl"] .ps-1,
.rtl .ps-1 { padding-right: 0.25rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-2,
.rtl .ps-2 { padding-right: 0.5rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-3,
.rtl .ps-3 { padding-right: 1rem !important; padding-left: 0 !important; }

[dir="rtl"] .text-start,
.rtl .text-start { text-align: right !important; }
[dir="rtl"] .text-end,
.rtl .text-end { text-align: left !important; }

[dir="rtl"] .float-start,
.rtl .float-start { float: right !important; }
[dir="rtl"] .float-end,
.rtl .float-end { float: left !important; }

/* ============================================
   Navbar RTL
   ============================================ */
[dir="rtl"] .navbar-nav,
.rtl .navbar-nav {
    padding-right: 0;
}

[dir="rtl"] .navbar-brand,
.rtl .navbar-brand {
    margin-left: 1rem;
    margin-right: 0;
}

/* ============================================
   Dropdown Menu RTL
   ============================================ */
[dir="rtl"] .dropdown-menu,
.rtl .dropdown-menu {
    right: 0;
    left: auto;
    text-align: right;
}

[dir="rtl"] .dropdown-item,
.rtl .dropdown-item {
    text-align: right;
}

/* ============================================
   Breadcrumb RTL
   ============================================ */
[dir="rtl"] .breadcrumb,
.rtl .breadcrumb {
    padding-right: 0;
}

[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before,
.rtl .breadcrumb-item + .breadcrumb-item::before {
    content: "\2039"; /* Single left-pointing angle quotation mark */
    padding-left: 0.5rem;
    padding-right: 0;
}

/* ============================================
   List RTL
   ============================================ */
[dir="rtl"] ul,
[dir="rtl"] ol,
.rtl ul,
.rtl ol {
    padding-right: 1.5rem;
    padding-left: 0;
}

[dir="rtl"] .list-unstyled,
.rtl .list-unstyled {
    padding-right: 0;
}

/* ============================================
   Form RTL
   ============================================ */
[dir="rtl"] .form-control,
.rtl .form-control {
    text-align: right;
}

[dir="rtl"] .input-group > .form-control,
[dir="rtl"] .input-group > .form-select,
.rtl .input-group > .form-control,
.rtl .input-group > .form-select {
    border-radius: 0.375rem 0 0 0.375rem;
}

[dir="rtl"] .input-group > .btn,
.rtl .input-group > .btn {
    border-radius: 0 0.375rem 0.375rem 0;
}

[dir="rtl"] .input-group-append,
.rtl .input-group-append {
    margin-right: -1px;
    margin-left: 0;
}

/* ============================================
   Card RTL
   ============================================ */
[dir="rtl"] .card-header,
.rtl .card-header {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
}

/* ============================================
   Badge RTL
   ============================================ */
[dir="rtl"] .badge,
.rtl .badge {
    margin-right: 0.25rem;
    margin-left: 0;
}

/* ============================================
   Button Group RTL
   ============================================ */
[dir="rtl"] .btn-group > .btn:not(:first-child),
[dir="rtl"] .btn-group > .btn-group:not(:first-child) > .btn,
.rtl .btn-group > .btn:not(:first-child),
.rtl .btn-group > .btn-group:not(:first-child) > .btn {
    margin-right: -1px;
    margin-left: 0;
    border-radius: 0.375rem 0 0 0.375rem;
}

[dir="rtl"] .btn-group > .btn:not(:last-child):not(.dropdown-toggle),
[dir="rtl"] .btn-group > .btn-group:not(:last-child) > .btn,
.rtl .btn-group > .btn:not(:last-child):not(.dropdown-toggle),
.rtl .btn-group > .btn-group:not(:last-child) > .btn {
    border-radius: 0 0.375rem 0.375rem 0;
}

/* ============================================
   Pagination RTL
   ============================================ */
[dir="rtl"] .pagination,
.rtl .pagination {
    padding-right: 0;
}

[dir="rtl"] .page-item:first-child .page-link,
.rtl .page-item:first-child .page-link {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

[dir="rtl"] .page-item:last-child .page-link,
.rtl .page-item:last-child .page-link {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* ============================================
   Table RTL
   ============================================ */
[dir="rtl"] .table,
.rtl .table {
    text-align: right;
}

/* ============================================
   Modal RTL
   ============================================ */
[dir="rtl"] .modal-header .close,
.rtl .modal-header .close {
    margin: -1rem auto -1rem -1rem;
}

/* ============================================
   Carousel RTL
   ============================================ */
[dir="rtl"] .carousel-control-prev,
.rtl .carousel-control-prev {
    right: 0;
    left: auto;
}

[dir="rtl"] .carousel-control-next,
.rtl .carousel-control-next {
    left: 0;
    right: auto;
}

/* ============================================
   Section Title RTL
   ============================================ */
[dir="rtl"] .section-title::after,
.rtl .section-title::after {
    right: 50%;
    left: auto;
    transform: translateX(50%);
}

/* ============================================
   Icon Alignment
   ============================================ */
[dir="rtl"] .fas,
[dir="rtl"] .far,
[dir="rtl"] .fab,
.rtl .fas,
.rtl .far,
.rtl .fab {
    display: inline-block;
}

[dir="rtl"] i.fas,
[dir="rtl"] i.far,
[dir="rtl"] i.fab,
.rtl i.fas,
.rtl i.far,
.rtl i.fab {
    vertical-align: middle;
}

/* ============================================
   Animation Direction
   ============================================ */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}
