/**
 * RTL (Right-to-Left) Support for Arabic
 * Flips layout for RTL languages
 */

/* Base RTL Direction */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="ltr"] {
    direction: ltr;
    text-align: left;
}


/* Sidebar Position Flip */
/* Sidebar Position Flip - ENSURE this overrides Tailwind */
[dir="rtl"] .glass-sidebar {
    left: auto !important;
    right: 0 !important;
}

/* Force hidden on mobile for RTL */
@media (max-width: 767px) {
    [dir="rtl"] #sidebar.-translate-x-full {
        transform: translateX(100%) !important;
    }
}

/* RTL Sidebar Toggle Logic Overrides 
   In LTR, -translate-x-full hides to left.
   In RTL, we want it to hide to right (positive 100%).
*/
[dir="rtl"] .-translate-x-full {
    transform: translateX(100%) !important;
}

/* Moved inside media query below */

/* Main Content Margin Swapping for Sidebar Toggle 
   Map ml-64 (LTR) to mr-64 (RTL)
*/
@media (min-width: 768px) {
    [dir="rtl"] .md\:ml-64 {
        margin-left: 0 !important;
        margin-right: 16rem !important;
    }

    /* Fix for sidebar visibility on Desktop RTL */
    [dir="rtl"] .md\:translate-x-0 {
        transform: translateX(0) !important;
    }

    [dir="rtl"] .md\:ml-0 {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* Text Alignment */
[dir="rtl"] .text-left {
    text-align: right !important;
}

[dir="rtl"] .text-right {
    text-align: left !important;
}

/* Margins and Padding Flip */
[dir="rtl"] .ml-auto {
    margin-right: auto;
    margin-left: 0;
}

[dir="rtl"] .mr-auto {
    margin-left: auto;
    margin-right: 0;
}

[dir="rtl"] .ml-2 {
    margin-left: 0;
    margin-right: 0.5rem;
}

[dir="rtl"] .ml-3 {
    margin-left: 0;
    margin-right: 0.75rem;
}

[dir="rtl"] .ml-4 {
    margin-left: 0;
    margin-right: 1rem;
}

[dir="rtl"] .mr-2 {
    margin-right: 0;
    margin-left: 0.5rem;
}

[dir="rtl"] .mr-3 {
    margin-right: 0;
    margin-left: 0.75rem;
}

[dir="rtl"] .mr-4 {
    margin-right: 0;
    margin-left: 1rem;
}

[dir="rtl"] .pl-2 {
    padding-left: 0;
    padding-right: 0.5rem;
}

[dir="rtl"] .pl-4 {
    padding-left: 0;
    padding-right: 1rem;
}

[dir="rtl"] .pl-8 {
    padding-left: 0;
    padding-right: 2rem;
}

[dir="rtl"] .pr-2 {
    padding-right: 0;
    padding-left: 0.5rem;
}

[dir="rtl"] .pr-4 {
    padding-right: 0;
    padding-left: 1rem;
}

[dir="rtl"] .pr-8 {
    padding-right: 0;
    padding-left: 2rem;
}

/* Border Flip */
[dir="rtl"] .border-l {
    border-left: none;
    border-right: 1px solid;
}

[dir="rtl"] .border-r {
    border-right: none;
    border-left: 1px solid;
}

[dir="rtl"] .border-l-4 {
    border-left: none;
    border-right: 4px solid;
}

/* Rounded Corners Flip */
[dir="rtl"] .rounded-l {
    border-radius: 0 0.5rem 0.5rem 0;
}

[dir="rtl"] .rounded-r {
    border-radius: 0.5rem 0 0 0.5rem;
}

[dir="rtl"] .rounded-tl {
    border-radius: 0 0.5rem 0 0;
}

[dir="rtl"] .rounded-tr {
    border-radius: 0.5rem 0 0 0;
}

[dir="rtl"] .rounded-bl {
    border-radius: 0 0 0 0.5rem;
}

[dir="rtl"] .rounded-br {
    border-radius: 0 0 0.5rem 0;
}

/* Icon Flip - Arrows */
[dir="rtl"] .fa-chevron-right:before {
    content: "\f053";
    /* fa-chevron-left */
}

[dir="rtl"] .fa-chevron-left:before {
    content: "\f054";
    /* fa-chevron-right */
}

[dir="rtl"] .fa-arrow-right:before {
    content: "\f060";
    /* fa-arrow-left */
}

[dir="rtl"] .fa-arrow-left:before {
    content: "\f061";
    /* fa-arrow-right */
}

[dir="rtl"] .fa-long-arrow-right:before {
    content: "\f177";
    /* fa-long-arrow-left */
}

[dir="rtl"] .fa-angle-right:before {
    content: "\f104";
    /* fa-angle-left */
}

[dir="rtl"] .fa-angle-left:before {
    content: "\f105";
    /* fa-angle-right */
}

/* Flex Direction Flip */
[dir="rtl"] .flex-row-reverse {
    flex-direction: row;
}

/* Position Flip */
[dir="rtl"] .left-0 {
    left: auto;
    right: 0;
}

[dir="rtl"] .right-0 {
    right: auto;
    left: 0;
}

/* Transform Flip */
[dir="rtl"] .translate-x-full {
    transform: translateX(-100%);
}

[dir="rtl"] .-translate-x-full {
    transform: translateX(100%);
}

/* Float Flip */
[dir="rtl"] .float-left {
    float: right;
}

[dir="rtl"] .float-right {
    float: left;
}

/* Input and Forms */
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="number"],
[dir="rtl"] textarea,
[dir="rtl"] select {
    text-align: right;
}

/* Dropdowns */
[dir="rtl"] select {
    background-position: left 0.5rem center;
    padding-left: 2.5rem;
    padding-right: 1rem;
}

/* Modal Alignment */
[dir="rtl"] .modal-content {
    text-align: right;
}

/* Tables */
[dir="rtl"] table {
    direction: rtl;
}

[dir="rtl"] th,
[dir="rtl"] td {
    text-align: right;
}

/* Lists */
[dir="rtl"] ul,
[dir="rtl"] ol {
    padding-right: 1.5rem;
    padding-left: 0;
}

/* Navigation Items */
[dir="rtl"] .nav-item {
    text-align: right;
}

[dir="rtl"] .nav-item i {
    margin-right: 0;
    margin-left: 0.75rem;
}

/* Cards and Containers */
[dir="rtl"] .card {
    text-align: right;
}

/* Specific Component Fixes */
[dir="rtl"] .language-switcher {
    left: auto;
    right: 1rem;
}

/* Badge Positions */
[dir="rtl"] .badge {
    left: auto;
    right: 0;
}

/* Tooltips - flip position */
[dir="rtl"] .tooltip-left {
    right: 100%;
    left: auto;
}

[dir="rtl"] .tooltip-right {
    left: 100%;
    right: auto;
}

/* Calendar Navigation RTL Fix */
[dir="rtl"] .calendar-nav-container,
[dir="rtl"] .view-toggle-group {
    flex-direction: row-reverse;
}