/* RTL Styles for Persian and Arabic */

[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

/* Reverse margins - در RTL، ml باید به سمت چپ بماند اما با مقدار جدید */
[dir="rtl"] .ml-1 { margin-right: 0 !important; margin-left: 0.25rem !important; }
[dir="rtl"] .ml-2 { margin-right: 0 !important; margin-left: 0.5rem !important; }
[dir="rtl"] .ml-3 { margin-right: 0 !important; margin-left: 0.75rem !important; }
[dir="rtl"] .ml-4 { margin-right: 0 !important; margin-left: 1rem !important; }
[dir="rtl"] .ml-5 { margin-right: 0 !important; margin-left: 1.25rem !important; }
[dir="rtl"] .ml-6 { margin-right: 0 !important; margin-left: 1.5rem !important; }
[dir="rtl"] .ml-8 { margin-right: 0 !important; margin-left: 2rem !important; }
[dir="rtl"] .ml-10 { margin-right: 0 !important; margin-left: 2.5rem !important; }
[dir="rtl"] .ml-12 { margin-right: 0 !important; margin-left: 3rem !important; }
[dir="rtl"] .ml-auto { margin-right: 0 !important; margin-left: auto !important; }

[dir="rtl"] .mr-1 { margin-left: 0 !important; margin-right: 0.25rem !important; }
[dir="rtl"] .mr-2 { margin-left: 0 !important; margin-right: 0.5rem !important; }
[dir="rtl"] .mr-3 { margin-left: 0 !important; margin-right: 0.75rem !important; }
[dir="rtl"] .mr-4 { margin-left: 0 !important; margin-right: 1rem !important; }
[dir="rtl"] .mr-5 { margin-left: 0 !important; margin-right: 1.25rem !important; }
[dir="rtl"] .mr-6 { margin-left: 0 !important; margin-right: 1.5rem !important; }
[dir="rtl"] .mr-8 { margin-left: 0 !important; margin-right: 2rem !important; }
[dir="rtl"] .mr-10 { margin-left: 0 !important; margin-right: 2.5rem !important; }
[dir="rtl"] .mr-12 { margin-left: 0 !important; margin-right: 3rem !important; }
[dir="rtl"] .mr-auto { margin-left: 0 !important; margin-right: auto !important; }

/* Reverse paddings */
[dir="rtl"] .pl-1 { padding-right: 0 !important; padding-left: 0.25rem !important; }
[dir="rtl"] .pl-2 { padding-right: 0 !important; padding-left: 0.5rem !important; }
[dir="rtl"] .pl-3 { padding-right: 0 !important; padding-left: 0.75rem !important; }
[dir="rtl"] .pl-4 { padding-right: 0 !important; padding-left: 1rem !important; }
[dir="rtl"] .pl-5 { padding-right: 0 !important; padding-left: 1.25rem !important; }
[dir="rtl"] .pl-6 { padding-right: 0 !important; padding-left: 1.5rem !important; }
[dir="rtl"] .pl-8 { padding-right: 0 !important; padding-left: 2rem !important; }
[dir="rtl"] .pl-10 { padding-right: 0 !important; padding-left: 2.5rem !important; }
[dir="rtl"] .pl-12 { padding-right: 0 !important; padding-left: 3rem !important; }

[dir="rtl"] .pr-1 { padding-left: 0 !important; padding-right: 0.25rem !important; }
[dir="rtl"] .pr-2 { padding-left: 0 !important; padding-right: 0.5rem !important; }
[dir="rtl"] .pr-3 { padding-left: 0 !important; padding-right: 0.75rem !important; }
[dir="rtl"] .pr-4 { padding-left: 0 !important; padding-right: 1rem !important; }
[dir="rtl"] .pr-5 { padding-left: 0 !important; padding-right: 1.25rem !important; }
[dir="rtl"] .pr-6 { padding-left: 0 !important; padding-right: 1.5rem !important; }
[dir="rtl"] .pr-8 { padding-left: 0 !important; padding-right: 2rem !important; }
[dir="rtl"] .pr-10 { padding-left: 0 !important; padding-right: 2.5rem !important; }
[dir="rtl"] .pr-12 { padding-left: 0 !important; padding-right: 3rem !important; }

/* Reverse left and right positioning */
[dir="rtl"] .left-0 { left: auto !important; right: 0 !important; }
[dir="rtl"] .left-4 { left: auto !important; right: 1rem !important; }
[dir="rtl"] .left-8 { left: auto !important; right: 2rem !important; }
[dir="rtl"] .right-0 { right: auto !important; left: 0 !important; }
[dir="rtl"] .right-4 { right: auto !important; left: 1rem !important; }
[dir="rtl"] .right-8 { right: auto !important; left: 2rem !important; }

/* Reverse inset */
[dir="rtl"] .inset-x-0 { left: auto !important; right: 0 !important; }

/* Reverse border radius */
[dir="rtl"] .rounded-l { 
    border-top-left-radius: 0 !important; 
    border-bottom-left-radius: 0 !important; 
    border-top-right-radius: 0.25rem !important; 
    border-bottom-right-radius: 0.25rem !important; 
}
[dir="rtl"] .rounded-r { 
    border-top-right-radius: 0 !important; 
    border-bottom-right-radius: 0 !important; 
    border-top-left-radius: 0.25rem !important; 
    border-bottom-left-radius: 0.25rem !important; 
}
[dir="rtl"] .rounded-l-lg { 
    border-top-left-radius: 0 !important; 
    border-bottom-left-radius: 0 !important; 
    border-top-right-radius: 0.5rem !important; 
    border-bottom-right-radius: 0.5rem !important; 
}
[dir="rtl"] .rounded-r-lg { 
    border-top-right-radius: 0 !important; 
    border-bottom-right-radius: 0 !important; 
    border-top-left-radius: 0.5rem !important; 
    border-bottom-left-radius: 0.5rem !important; 
}

/* Reverse borders */
[dir="rtl"] .border-l { border-left: 0 !important; border-right: 1px solid !important; }
[dir="rtl"] .border-r { border-right: 0 !important; border-left: 1px solid !important; }
[dir="rtl"] .border-l-2 { border-left: 0 !important; border-right: 2px solid !important; }
[dir="rtl"] .border-r-2 { border-right: 0 !important; border-left: 2px solid !important; }

/* Reverse text alignment */
[dir="rtl"] .text-left { text-align: right !important; }
[dir="rtl"] .text-right { text-align: left !important; }

/* Reverse float */
[dir="rtl"] .float-left { float: right !important; }
[dir="rtl"] .float-right { float: left !important; }

/* Reverse transforms for animations */
[dir="rtl"] .translate-x-full { transform: translateX(-100%) !important; }
[dir="rtl"] .-translate-x-full { transform: translateX(100%) !important; }
[dir="rtl"] .-translate-x-1\/2 { transform: translateX(50%) !important; }
[dir="rtl"] .translate-x-1\/2 { transform: translateX(-50%) !important; }

/* Icons in RTL - معکوس کردن جهت فلش‌ها */
[dir="rtl"] .fa-chevron-left:before { content: "\f054" !important; }
[dir="rtl"] .fa-chevron-right:before { content: "\f053" !important; }
[dir="rtl"] .fa-arrow-left:before { content: "\f061" !important; }
[dir="rtl"] .fa-arrow-right:before { content: "\f060" !important; }
[dir="rtl"] .fa-long-arrow-left:before { content: "\f178" !important; }
[dir="rtl"] .fa-long-arrow-right:before { content: "\f177" !important; }

/* Flexbox reverse */
[dir="rtl"] .flex-row-reverse { flex-direction: row !important; }
[dir="rtl"] .flex-row { flex-direction: row-reverse !important; }

/* Space reverse for RTL */
[dir="rtl"] .space-x-1 > :not([hidden]) ~ :not([hidden]) {
    margin-left: 0 !important;
    margin-right: 0.25rem !important;
}
[dir="rtl"] .space-x-2 > :not([hidden]) ~ :not([hidden]) {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}
[dir="rtl"] .space-x-3 > :not([hidden]) ~ :not([hidden]) {
    margin-left: 0 !important;
    margin-right: 0.75rem !important;
}
[dir="rtl"] .space-x-4 > :not([hidden]) ~ :not([hidden]) {
    margin-left: 0 !important;
    margin-right: 1rem !important;
}
[dir="rtl"] .space-x-6 > :not([hidden]) ~ :not([hidden]) {
    margin-left: 0 !important;
    margin-right: 1.5rem !important;
}
[dir="rtl"] .space-x-8 > :not([hidden]) ~ :not([hidden]) {
    margin-left: 0 !important;
    margin-right: 2rem !important;
}

/* Reverse space-x-reverse */
[dir="rtl"] .space-x-reverse > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 0 !important;
}

/* Custom RTL fixes */
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="number"] {
    direction: ltr;
    text-align: left;
}

/* Gradient direction for RTL */
[dir="rtl"] .gradient-primary,
[dir="rtl"] .gradient-success,
[dir="rtl"] .gradient-danger,
[dir="rtl"] .gradient-warning {
    background: linear-gradient(225deg, var(--tw-gradient-stops)) !important;
}

/* Divide reverse */
[dir="rtl"] .divide-x > :not([hidden]) ~ :not([hidden]) {
    border-left-width: 0 !important;
    border-right-width: 1px !important;
}

/* Origin reverse */
[dir="rtl"] .origin-top-left { transform-origin: top right !important; }
[dir="rtl"] .origin-top-right { transform-origin: top left !important; }
[dir="rtl"] .origin-bottom-left { transform-origin: bottom right !important; }
[dir="rtl"] .origin-bottom-right { transform-origin: bottom left !important; }
