/* RTL (Right-to-Left) Support for Arabic and Hebrew */

/* RTL Base Styles */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

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

/* Navigation RTL */
[dir="rtl"] .navbar-nav {
    margin-right: auto;
    margin-left: 0;
}

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

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

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

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

[dir="rtl"] .text-start {
    text-align: left !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"] .ms-2 {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}

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

/* Flexbox RTL */
[dir="rtl"] .d-flex {
    flex-direction: row-reverse;
}

[dir="rtl"] .justify-content-end {
    justify-content: flex-start !important;
}

[dir="rtl"] .justify-content-start {
    justify-content: flex-end !important;
}

/* Product Cards RTL */
[dir="rtl"] .product-card,
[dir="rtl"] .category-card {
    text-align: center; /* Keep product cards centered */
}

[dir="rtl"] .product-info,
[dir="rtl"] .product-content {
    text-align: center;
}

[dir="rtl"] .product-price {
    direction: ltr; /* Keep prices LTR */
    display: inline-block;
}

/* Cart RTL */
[dir="rtl"] .cart-item {
    text-align: right;
}

[dir="rtl"] .quantity-controls {
    flex-direction: row-reverse;
}

[dir="rtl"] .cart-total {
    direction: ltr; /* Keep currency LTR */
}

/* Forms RTL */
[dir="rtl"] .form-check {
    padding-right: 1.5em;
    padding-left: 0;
    text-align: right;
}

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

[dir="rtl"] .input-group {
    flex-direction: row-reverse;
}

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

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

/* Buttons RTL */
[dir="rtl"] .btn-group {
    flex-direction: row-reverse;
}

[dir="rtl"] .btn .fas,
[dir="rtl"] .btn .far {
    margin-right: 0;
    margin-left: 0.5rem;
}

/* Tables RTL */
[dir="rtl"] .table {
    text-align: right;
}

[dir="rtl"] .table th:first-child,
[dir="rtl"] .table td:first-child {
    left: auto;
    right: 0;
}

/* Admin RTL */
[dir="rtl"] .admin-sidebar {
    right: 0;
    left: auto;
}

[dir="rtl"] .admin-content {
    margin-right: 250px;
    margin-left: 0;
}

[dir="rtl"] .admin-nav-link {
    text-align: right;
}

[dir="rtl"] .admin-nav-link .fas {
    margin-right: 0;
    margin-left: 0.5rem;
    float: right;
}

/* Design Tool RTL */
[dir="rtl"] .designer-content {
    grid-template-columns: auto 1fr auto;
    /* Keep the same layout but content will be RTL */
}

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

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

[dir="rtl"] .tool-btn {
    text-align: center; /* Keep buttons centered */
}

/* Modals RTL */
[dir="rtl"] .modal-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .modal-header .btn-close {
    margin-right: auto;
    margin-left: 0;
}

[dir="rtl"] .modal-footer {
    flex-direction: row-reverse;
}

/* Breadcrumbs RTL */
[dir="rtl"] .breadcrumb {
    flex-direction: row-reverse;
}

[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    content: "\\";
    float: right;
    padding-right: var(--bs-breadcrumb-item-padding-x);
    padding-left: 0;
}

/* Pagination RTL */
[dir="rtl"] .pagination {
    flex-direction: row-reverse;
}

/* Alerts RTL */
[dir="rtl"] .alert {
    text-align: right;
}

[dir="rtl"] .alert .fas {
    margin-right: 0;
    margin-left: 0.5rem;
    float: right;
}

/* Cards RTL */
[dir="rtl"] .card-header {
    text-align: right;
}

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

/* Lists RTL */
[dir="rtl"] .list-group-item {
    text-align: right;
}

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

/* Badges and Labels RTL */
[dir="rtl"] .badge {
    direction: ltr; /* Keep badges LTR for consistency */
}

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

/* Progress Bars RTL */
[dir="rtl"] .progress-bar {
    right: 0;
    left: auto;
}

/* Tooltips RTL */
[dir="rtl"] .tooltip {
    text-align: center; /* Keep tooltips centered */
}

/* Special RTL Typography */
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6 {
    text-align: right;
}

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

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

/* Keep certain elements LTR even in RTL mode */
[dir="rtl"] .price,
[dir="rtl"] .currency,
[dir="rtl"] .phone,
[dir="rtl"] .email,
[dir="rtl"] .url,
[dir="rtl"] .sku {
    direction: ltr;
    display: inline-block;
}

/* Language selector always LTR */
[dir="rtl"] .language-selector {
    direction: ltr;
    text-align: left;
}

[dir="rtl"] .language-dropdown {
    right: auto;
    left: 0;
    text-align: left;
}

/* Mobile RTL adjustments */
@media (max-width: 768px) {
    [dir="rtl"] .navbar-collapse {
        text-align: center;
    }

    [dir="rtl"] .hero-buttons {
        align-items: center;
    }

    [dir="rtl"] .admin-sidebar {
        right: -100%;
        left: auto;
    }

    [dir="rtl"] .admin-sidebar.show {
        right: 0;
    }

    [dir="rtl"] .admin-content {
        margin-right: 0;
    }

    [dir="rtl"] .table-responsive {
        direction: rtl;
    }

    [dir="rtl"] .table th:first-child,
    [dir="rtl"] .table td:first-child {
        right: 0;
        left: auto;
    }
}

/* Arabic-specific adjustments */
[dir="rtl"][lang="ar"] {
    font-family: 'Segoe UI', 'Tahoma', 'Arial', 'Helvetica Neue', sans-serif;
}

[dir="rtl"][lang="ar"] .navbar-brand,
[dir="rtl"][lang="ar"] .btn,
[dir="rtl"][lang="ar"] .form-control {
    font-family: inherit;
}

/* Hebrew-specific adjustments */
[dir="rtl"][lang="he"] {
    font-family: 'Segoe UI', 'Tahoma', 'Arial', 'David', 'Times New Roman', serif;
}

[dir="rtl"][lang="he"] .navbar-brand,
[dir="rtl"][lang="he"] .btn,
[dir="rtl"][lang="he"] .form-control {
    font-family: inherit;
}

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

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

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

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

/* Animation adjustments for RTL */
[dir="rtl"] .slide-left {
    transform: translateX(20px);
}

[dir="rtl"] .slide-right {
    transform: translateX(-20px);
}

/* Ensure important elements maintain LTR */
.keep-ltr {
    direction: ltr !important;
    text-align: left !important;
}

/* Code blocks, emails, URLs always LTR */
code,
pre,
.email,
.url,
.phone,
.sku,
.tracking-number {
    direction: ltr !important;
    text-align: left !important;
    display: inline-block;
}

/* Product IDs and order numbers always LTR */
.order-number,
.product-id,
.variation-id {
    direction: ltr !important;
    font-family: monospace;
}