/* RTL Support for Arabic */

/* General RTL adjustments */
[dir="rtl"] {
    text-align: right;
}

/* Bootstrap RTL overrides */
[dir="rtl"] .text-start {
    text-align: right !important;
}

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

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

[dir="rtl"] .me-auto {
    margin-left: auto !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"] .ms-5 { margin-right: 3rem !important; margin-left: 0 !important; }

[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"] .me-5 { margin-left: 3rem !important; margin-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; }
[dir="rtl"] .ps-5 { padding-right: 3rem !important; padding-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"] .pe-5 { padding-left: 3rem !important; padding-right: 0 !important; }

/* Float adjustments */
[dir="rtl"] .float-start {
    float: right !important;
}

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

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

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

/* Dropdown adjustments */
[dir="rtl"] .dropdown-menu-end {
    right: auto !important;
    left: 0 !important;
}

[dir="rtl"] .dropdown-menu-start {
    left: auto !important;
    right: 0 !important;
}

/* Form controls */
[dir="rtl"] .form-control,
[dir="rtl"] .form-select {
    text-align: right;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
}

[dir="rtl"] .form-check {
    padding-right: 1.5em;
    padding-left: 0;
}

[dir="rtl"] .form-check-input {
    float: right;
    margin-right: -1.5em;
    margin-left: 0;
}

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

[dir="rtl"] .list-unstyled {
    padding-right: 0;
}

/* Icon adjustments for Font Awesome */
[dir="rtl"] .fa-arrow-right:before {
    content: "\f060";  /* arrow-left */
}

[dir="rtl"] .fa-arrow-left:before {
    content: "\f061";  /* arrow-right */
}

[dir="rtl"] .fa-chevron-right:before {
    content: "\f053";  /* chevron-left */
}

[dir="rtl"] .fa-chevron-left:before {
    content: "\f054";  /* chevron-right */
}

[dir="rtl"] .fa-angle-right:before {
    content: "\f104";  /* angle-left */
}

[dir="rtl"] .fa-angle-left:before {
    content: "\f105";  /* angle-right */
}

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

/* Card adjustments */
[dir="rtl"] .card {
    text-align: right;
}

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

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

/* Progress bar adjustments */
[dir="rtl"] .progress-bar {
    background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
}

/* Custom Arabic typography improvements */
[dir="rtl"] {
    letter-spacing: 0;
    word-spacing: 0.05em;
    line-height: 1.8;
}

[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6 {
    font-weight: 600;
    line-height: 1.5;
}

[dir="rtl"] p {
    line-height: 1.8;
}

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

[dir="rtl"] .navbar-brand {
    margin-left: 1rem;
    margin-right: 0;
}

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

/* Button group adjustments */
[dir="rtl"] .btn-group > .btn:first-child:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
}

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

/* Alert adjustments */
[dir="rtl"] .alert-dismissible .btn-close {
    position: absolute;
    top: 0;
    left: 0;
    right: auto;
    z-index: 2;
    padding: 1.25rem 1rem;
}

/* Table adjustments */
[dir="rtl"] table {
    text-align: right;
}

[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right;
}

/* Offcanvas adjustments */
[dir="rtl"] .offcanvas-start {
    right: 0;
    left: auto;
}

[dir="rtl"] .offcanvas-end {
    left: 0;
    right: auto;
}

/* Carousel adjustments */
[dir="rtl"] .carousel-control-prev {
    right: 0;
    left: auto;
}

[dir="rtl"] .carousel-control-next {
    left: 0;
    right: auto;
}

[dir="rtl"] .carousel-control-prev-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

[dir="rtl"] .carousel-control-next-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z'/%3e%3c/svg%3e");
}