/* RTL Support for Persian and Arabic Languages */

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

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

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

/* Font family overrides for RTL languages */
[dir="rtl"] body {
    font-family: 'Vazirmatn', 'Cairo', sans-serif;
}

/* Margin and padding adjustments */
[dir="rtl"] .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

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

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

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

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

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

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

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

/* Text alignment */
[dir="rtl"] .text-lg-start {
    text-align: right !important;
}

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

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

/* Bootstrap utilities */
[dir="rtl"] .start-50 {
    left: auto !important;
    right: 50% !important;
}

[dir="rtl"] .translate-middle-x {
    transform: translateX(50%) !important;
}

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

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

/* RTL Submenu support - با specificity بالاتر */
[dir="rtl"] .navbar .dropdown-submenu .dropdown-menu {
    left: auto !important;
    right: 100% !important;
    top: -1px !important; /* دقیقاً از روبروی parent با کمی تنظیم */
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    z-index: 1001 !important; /* بالاتر از dropdown اصلی */
}

[dir="rtl"] .navbar .dropdown-submenu .dropdown-toggle::after {
    content: "\f104" !important;
    margin-left: 0 !important;
    margin-right: 8px !important;
    float: left !important;
}

/* Button groups and form elements */
[dir="rtl"] .input-group > .form-control:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

[dir="rtl"] .input-group > .form-control:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

/* Icons and badges */
[dir="rtl"] .fa-check {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Service items */
[dir="rtl"] .service-item .service-icon {
    margin-left: 0;
    margin-right: 0;
}

/* Feature section */
[dir="rtl"] .feature .btn-sm-square {
    margin-left: 0;
    margin-right: 1rem;
}

/* Case studies */
[dir="rtl"] .case-overlay {
    text-align: right;
}

/* FAQ accordion */
[dir="rtl"] .accordion-button::after {
    margin-left: 0;
    margin-right: auto;
}

/* Footer */
[dir="rtl"] .footer .footer-item h4 {
    text-align: right;
}

[dir="rtl"] .footer .footer-item p {
    text-align: right;
}

[dir="rtl"] .footer .btn-link {
    text-align: right;
    display: block;
    margin-bottom: 0.5rem;
}

[dir="rtl"] .footer .copyright {
    text-align: right;
}

[dir="rtl"] .footer .footer-menu {
    text-align: left;
}

[dir="rtl"] .footer .footer-menu a {
    margin-left: 1rem;
    margin-right: 0;
}

[dir="rtl"] .footer .footer-menu a:last-child {
    margin-left: 0;
}

[dir="rtl"] .footer .btn-social {
    margin-left: 0.75rem;
    margin-right: 0;
}

[dir="rtl"] .footer .btn-social:first-child {
    margin-left: 0;
}

[dir="rtl"] .footer p i {
    margin-left: 0.75rem;
    margin-right: 0;
}

/* Newsletter form */
[dir="rtl"] .newsletter .form-control {
    border-radius: 0 50px 50px 0;
}

[dir="rtl"] .newsletter .btn {
    border-radius: 50px 0 0 50px;
}

/* Social media icons */
[dir="rtl"] .btn-square {
    margin-left: 0.75rem;
    margin-right: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    [dir="rtl"] .text-center {
        text-align: center !important;
    }
    
    [dir="rtl"] .navbar-nav {
        text-align: right;
    }
}

/* Animation adjustments for RTL */
[dir="rtl"] .animated.slideInRight {
    animation-name: slideInLeft;
}

[dir="rtl"] .animated.slideInLeft {
    animation-name: slideInRight;
}

/* Custom RTL animations */
@keyframes slideInRight {
    from {
        transform: translate3d(-100%, 0, 0);
        visibility: visible;
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translate3d(100%, 0, 0);
        visibility: visible;
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

/* Form elements RTL support */
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"],
[dir="rtl"] textarea,
[dir="rtl"] select {
    text-align: right;
}

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

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

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

/* Tooltip and popover */
[dir="rtl"] .tooltip {
    text-align: right;
}

[dir="rtl"] .popover {
    text-align: right;
}

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

/* Blockquote */
[dir="rtl"] blockquote {
    border-right: 4px solid #007bff;
    border-left: none;
    padding-right: 1rem;
    padding-left: 0;
}

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

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

/* Pagination */
[dir="rtl"] .pagination .page-link {
    margin-left: 0;
    margin-right: -1px;
}

/* Progress bars */
[dir="rtl"] .progress-bar {
    float: right;
}

/* Alert dismissible */
[dir="rtl"] .alert-dismissible .btn-close {
    right: auto;
    left: 0;
}

/* Input groups */
[dir="rtl"] .input-group-text {
    border-radius: 0 0.375rem 0.375rem 0;
}

[dir="rtl"] .input-group > .form-control {
    border-radius: 0.375rem 0 0 0.375rem;
}

/* Custom scrollbar for RTL */
[dir="rtl"] ::-webkit-scrollbar {
    width: 8px;
}

[dir="rtl"] ::-webkit-scrollbar-track {
    background: #f1f1f1;
}

[dir="rtl"] ::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

[dir="rtl"] ::-webkit-scrollbar-thumb:hover {
    background: #555;
} 