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

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

/* Prevent horizontal scroll in RTL mode */
[dir="rtl"] html,
[dir="rtl"] body {
    overflow-x: hidden !important;
}

/* RTL: Fix all sidebars with negative left positioning */
/* These sidebars use transform to hide off-screen, which works better in RTL */
@media (max-width: 768px) {
    /* Fix sidebars in RTL to slide from right */
    [dir="rtl"] .mobile-menu-sidebar,
    [dir="rtl"] .filter-sidebar {
        left: auto !important;
        right: 0 !important;
        transform: translateX(100%) !important;
    }
    
    [dir="rtl"] .mobile-menu-sidebar.open,
    [dir="rtl"] .filter-sidebar.open {
        transform: translateX(0) !important;
        visibility: visible !important;
    }
}

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

[dir="rtl"] .header-left {
    order: 2;
}

[dir="rtl"] .header-right {
    order: 1;
}

/* Header buttons - keep normal order (text first, icon after) */
/* In RTL, this means: text on right, icon on left - which is correct */
[dir="rtl"] .header-btn {
    /* Don't reverse - keep text before icon in DOM */
}

[dir="rtl"] .cart {
    /* Don't reverse - keep text before icon in DOM */
}

[dir="rtl"] .language-selector {
    margin-right: 0;
    margin-left: 8px; /* Gap to the left (currency) */
}

[dir="rtl"] .currency-selector {
    margin-right: 0;
    margin-left: 20px; /* Gap to the left (login button) */
}

[dir="rtl"] .language-selector select,
[dir="rtl"] .currency-selector select {
    /* In RTL, text should be on right, arrow on left */
    direction: rtl;
    text-align: right;
    padding: 2px 2px 2px 5px;
    /* Width will be set dynamically by JavaScript based on selected option */
}

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

[dir="rtl"] .nav-item {
    margin-left: 0;
    margin-right: 30px;
}

/* Product Grid RTL */
[dir="rtl"] .product-card {
    text-align: right;
}

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

[dir="rtl"] .product-article {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 5px;
}

[dir="rtl"] .product-article .article-label {
    order: 2;
}

[dir="rtl"] .product-article #product-sku {
    order: 1;
}

/* Fix product name direction for proper quote display */
[dir="rtl"] .product-name {
    direction: ltr;
    text-align: right;
    unicode-bidi: plaintext;
}

[dir="rtl"] .product-price {
    text-align: right;
    margin-left: auto;
    margin-right: 0;
}

[dir="rtl"] .product-price-display {
    text-align: right;
    margin-left: auto;
    margin-right: 0;
}

/* RTL: Product info - align all items to right */
[dir="rtl"] .product-info {
    align-items: flex-end !important;
    text-align: right;
}

/* RTL: Add to Cart button - align to right edge */
[dir="rtl"] .product-info .add-to-cart-btn {
    margin-left: auto;
    margin-right: 0;
}

[dir="rtl"] .product-info .product-name {
    width: 100%;
    text-align: right;
}

[dir="rtl"] .product-info .product-article {
    width: 100%;
    text-align: right;
}

[dir="rtl"] .product-info .product-price {
    width: auto;
    margin-left: auto;
    margin-right: 0;
}

[dir="rtl"] .product-info .product-variations {
    width: 100%;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
}

[dir="rtl"] .product-info .product-navigation-buttons {
    width: 100%;
    display: flex !important;
    justify-content: flex-end !important;
}

[dir="rtl"] .product-info .product-attributes-info {
    width: 100%;
}

/* RTL: Marketplace buttons - full width so they don't collapse */
[dir="rtl"] .product-info #marketplace-buttons-container {
    width: 100% !important;
}

[dir="rtl"] .product-info .marketplace-buttons {
    width: 100% !important;
}

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

/* RTL: Variation buttons - align right */
[dir="rtl"] .variation-buttons {
    justify-content: flex-end !important;
}

[dir="rtl"] .variations-options {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    gap: 10px;
}

[dir="rtl"] .variations-label {
    text-align: right !important;
    width: 100%;
}

/* RTL: Navigation buttons - align right */
[dir="rtl"] .product-navigation-buttons {
    display: flex !important;
    justify-content: flex-end !important;
}

[dir="rtl"] .product-navigation-buttons .nav-btn {
    flex: none !important;
    width: auto !important;
    max-width: none !important;
}

/* RTL: Attributes info - align right */
[dir="rtl"] .product-attributes-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

[dir="rtl"] .product-attributes-info .attribute-item {
    width: auto;
    margin-left: auto;
    margin-right: 0;
}

[dir="rtl"] .product-code {
    left: 10px;
    right: auto;
}

/* Forms RTL */
[dir="rtl"] .form-group {
    text-align: right;
}

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

[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea {
    text-align: right;
    padding-left: 12px;
    padding-right: 12px;
    direction: rtl;
}

/* Fix select dropdown arrow position in RTL */
[dir="rtl"] select {
    background-position: left 12px center;
    padding-left: 35px;
    padding-right: 12px;
}

/* Checkout RTL */
[dir="rtl"] .checkout-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .checkout-form {
    padding-left: 0;
    padding-right: 40px;
}

[dir="rtl"] .order-summary {
    padding-right: 0;
    padding-left: 40px;
}

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

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

/* Order Summary RTL - swap text and price */
[dir="rtl"] .summary-row {
    flex-direction: row-reverse !important;
    justify-content: space-between;
}

[dir="rtl"] .summary-row span:first-child {
    text-align: right;
    order: 2;
}

[dir="rtl"] .summary-row span:last-child {
    text-align: left;
    order: 1;
}

[dir="rtl"] .order-total {
    flex-direction: row-reverse !important;
    justify-content: space-between;
}

[dir="rtl"] .order-total span:first-child {
    text-align: right;
    order: 2;
}

[dir="rtl"] .order-total span:last-child {
    text-align: left;
    order: 1;
}

[dir="rtl"] .item-image {
    margin-left: 15px;
    margin-right: 0;
}

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

[dir="rtl"] .item-total {
    text-align: left;
}

/* Product info in checkout table RTL */
/* Image on right edge, text on left of image */
[dir="rtl"] .product-cell {
    text-align: right !important;
}

[dir="rtl"] .checkout-table .product-info {
    display: block !important;
    text-align: right !important;
}

[dir="rtl"] .checkout-table .product-thumbnail {
    float: right !important;
    margin-left: 15px !important;
    margin-right: 0 !important;
}

[dir="rtl"] .checkout-table .product-details {
    text-align: right !important;
    margin: 0 !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

[dir="rtl"] .checkout-table .product-name {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

[dir="rtl"] .checkout-table .preorder-badge {
    margin-left: 0;
    margin-right: 0;
}

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

[dir="rtl"] .product-name {
    /* Don't reverse */
}

/* Quantity cell - center align */
[dir="rtl"] .checkout-table .quantity-cell {
    text-align: center;
}

[dir="rtl"] .checkout-table .quantity-cell input {
    text-align: center;
    direction: ltr;
}

/* Price cells - keep numbers LTR */
[dir="rtl"] .checkout-table .price-cell,
[dir="rtl"] .checkout-table .total-cell {
    direction: ltr;
    text-align: right;
}

/* Account Page RTL */
[dir="rtl"] .account-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .account-sidebar {
    padding-left: 0;
    padding-right: 30px;
    border-left: none;
    border-right: 1px solid #e0e0e0;
}

[dir="rtl"] .account-content {
    padding-right: 0;
    padding-left: 30px;
}

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

[dir="rtl"] .order-header-content {
    text-align: right;
}

[dir="rtl"] .order-header-right {
    flex-direction: row-reverse;
}

[dir="rtl"] .order-info-row {
    direction: rtl;
}

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

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

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

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

[dir="rtl"] .footer-payment-icons {
    justify-content: flex-end;
}

/* Cookie Consent RTL */
[dir="rtl"] .cookie-consent-content {
    flex-direction: row-reverse;
    text-align: right;
}

[dir="rtl"] .cookie-consent-buttons {
    flex-direction: row-reverse;
}

/* Modal RTL */
[dir="rtl"] .modal-content {
    text-align: right;
}

[dir="rtl"] .modal-close,
[dir="rtl"] .close {
    left: 20px;
    right: auto;
}

/* Buttons RTL */
[dir="rtl"] .btn-primary,
[dir="rtl"] .btn-secondary,
[dir="rtl"] button {
    text-align: center;
}

/* Checkbox and Radio RTL - text then checkbox */
html[dir="rtl"] .checkbox-group,
html[dir="rtl"] div.checkbox-group,
[dir="rtl"] .checkbox-group {
    flex-direction: row-reverse !important;
    justify-content: flex-end !important;
}

html[dir="rtl"] .checkbox-group input[type="checkbox"],
[dir="rtl"] .checkbox-group input[type="checkbox"] {
    order: 2 !important;
}

html[dir="rtl"] .checkbox-group label,
[dir="rtl"] .checkbox-group label {
    order: 1 !important;
}

/* Payment options RTL - text, icon, radio button */
[dir="rtl"] label.payment-option {
    flex-direction: row-reverse !important;
    justify-content: flex-end !important;
}

[dir="rtl"] .payment-option .payment-label {
    flex-direction: row-reverse !important;
    margin-left: 0 !important;
    margin-right: 12px !important;
    order: 1;
    flex: 0 0 auto !important;
}

[dir="rtl"] .payment-option input[type="radio"] {
    margin: 0 !important;
    order: 2;
}

[dir="rtl"] .payment-label .payment-icon {
    order: 2;
}

[dir="rtl"] .payment-label span:not(.payment-icon) {
    order: 1;
}

/* Account Page RTL - reverse label and value order */
[dir="rtl"] .order-section p {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 5px;
}

[dir="rtl"] .order-section p strong {
    order: 2;
}

[dir="rtl"] .order-header-info {
    flex-direction: row-reverse;
}

[dir="rtl"] .order-info-row {
    direction: rtl;
}

[dir="rtl"] .order-item {
    flex-direction: row-reverse;
    justify-content: flex-end;
}

[dir="rtl"] .item-image-link {
    order: 3;
}

[dir="rtl"] .item-info {
    order: 2;
    text-align: right;
}

[dir="rtl"] .item-total {
    order: 1;
    text-align: left;
}

[dir="rtl"] .status-history-item {
    flex-direction: row-reverse;
    border-left: none;
    border-right: 3px solid #8B7355;
}

[dir="rtl"] .tracking-section,
[dir="rtl"] .notes-section {
    border-left: none;
    border-right: 4px solid #4a90e2;
}

[dir="rtl"] .notes-section {
    border-right-color: #f0ad4e;
}

/* Responsive RTL */
@media (max-width: 768px) {
    [dir="rtl"] .header-top {
        flex-direction: column;
    }
    
    [dir="rtl"] .header-left,
    [dir="rtl"] .header-right {
        order: initial;
        justify-content: center;
    }
    
    [dir="rtl"] .checkout-container {
        flex-direction: column;
    }
    
    [dir="rtl"] .checkout-form,
    [dir="rtl"] .order-summary {
        padding: 20px;
    }
    
    [dir="rtl"] .account-container {
        flex-direction: column;
    }
    
    [dir="rtl"] .account-sidebar {
        padding: 20px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
}

/* Quantity controls RTL - reverse to get + - */
html[dir="rtl"] .quantity-controls,
[dir="rtl"] .quantity-controls {
    display: flex !important;
    flex-direction: row !important;
}

/* Первая кнопка (минус с текстом −) - в конец */
html[dir="rtl"] .quantity-controls button:first-of-type,
[dir="rtl"] .quantity-controls button:first-of-type {
    order: 3 !important;
}

/* Input - в центр */
html[dir="rtl"] .quantity-controls input[type="number"],
[dir="rtl"] .quantity-controls input[type="number"] {
    order: 2 !important;
}

/* Последняя кнопка (плюс с текстом +) - в начало */
html[dir="rtl"] .quantity-controls button:last-of-type,
[dir="rtl"] .quantity-controls button:last-of-type {
    order: 1 !important;
}

/* Remove button RTL */
[dir="rtl"] .remove-item-btn {
    margin-right: 0;
    margin-left: 10px;
}

/* Shipping row in table - reverse cell order */
[dir="rtl"] .shipping-row-table td:first-child {
    order: 2;
}

[dir="rtl"] .shipping-row-table td:nth-child(2) {
    order: 1;
    text-align: left !important;
}

/* Discount row in table - reverse cell order */
[dir="rtl"] .discount-row-table td:first-child {
    order: 2;
}

[dir="rtl"] .discount-row-table td:nth-child(2) {
    order: 1;
    text-align: left !important;
}

/* Total row in table - reverse cell order */
[dir="rtl"] .total-row-table td:first-child {
    order: 2;
}

[dir="rtl"] .total-row-table td:nth-child(2) {
    order: 1;
    text-align: left !important;
}

/* Make sure the row uses flexbox for order to work */
[dir="rtl"] .shipping-row-table,
[dir="rtl"] .discount-row-table,
[dir="rtl"] .total-row-table {
    display: flex;
}

[dir="rtl"] .shipping-row-table td,
[dir="rtl"] .discount-row-table td,
[dir="rtl"] .total-row-table td {
    display: flex;
    align-items: center;
}


/* Terms agreement section RTL */
[dir="rtl"] .terms-agreement-section .checkbox-group {
    flex-direction: row-reverse !important;
    justify-content: flex-end !important;
}

[dir="rtl"] .terms-agreement-section .checkbox-group input[type="checkbox"] {
    order: 2 !important;
}

[dir="rtl"] .terms-agreement-section .checkbox-group label {
    order: 1 !important;
    text-align: right;
}


/* Production time notice RTL */
[dir="rtl"] .production-time-notice {
    text-align: right;
    direction: rtl;
    margin-left: auto;
    margin-right: 0;
}


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


/* Checkout preorder notice RTL */
[dir="rtl"] .checkout-preorder-notice {
    text-align: center;
    direction: rtl;
}


/* Product availability RTL - прижать к правому краю */
[dir="rtl"] .product-availability {
    flex-direction: row-reverse;
    justify-content: flex-end;
}

/* Product quantity RTL - прижать к правому краю */
[dir="rtl"] .product-quantity {
    flex-direction: row-reverse;
    justify-content: flex-end;
}


/* Mixed Order Shipping Choice RTL */
[dir="rtl"] .mixed-order-section {
    text-align: right;
}

[dir="rtl"] .mixed-order-notice h3,
[dir="rtl"] .mixed-order-notice > p {
    text-align: right;
}

[dir="rtl"] .shipping-option-card input[type="radio"] {
    right: auto;
    left: 15px;
}

[dir="rtl"] .option-content {
    padding-right: 0;
    padding-left: 35px;
}

[dir="rtl"] .option-content strong,
[dir="rtl"] .option-note,
[dir="rtl"] .option-note-info {
    text-align: right;
}

/* Payment Notice RTL */
[dir="rtl"] .payment-notice {
    text-align: right;
}


/* RTL для мобильных карточек товаров */
@media (max-width: 768px) {
    /* Вертикальные карточки в RTL - просто выравнивание текста */
    [dir="rtl"] .product-card {
        flex-direction: column !important;
    }
    
    [dir="rtl"] .product-card .product-image {
        border-radius: 0 !important;
    }
    
    [dir="rtl"] .product-card .product-image img {
        border-radius: 0 !important;
    }
    
    [dir="rtl"] .product-card-content {
        text-align: right !important;
        padding: 15px !important;
    }
    
    [dir="rtl"] .product-card .product-title {
        text-align: right !important;
    }
    
    [dir="rtl"] .product-card .product-price {
        align-items: flex-start !important;
    }
    
    [dir="rtl"] .product-card .price-container {
        text-align: right !important;
    }
    
    [dir="rtl"] .product-card .price,
    [dir="rtl"] .product-card .price-discount,
    [dir="rtl"] .product-card .price-original {
        direction: ltr !important;
        unicode-bidi: embed !important;
    }
}


/* RTL Mobile checkout - product price display */
@media (max-width: 768px) {
    /* Price cell - align to right and reverse text order */
    [dir="rtl"] .checkout-table .total-cell {
        text-align: right !important;
    }
    
    /* Remove "Price" label from before */
    [dir="rtl"] .checkout-table .total-cell::before {
        content: '' !important;
    }
    
    /* Add ":Price" label after the price */
    [dir="rtl"] .checkout-table .total-cell::after {
        content: ' :Price' !important;
        font-weight: 600;
        color: #666;
        font-size: 14px;
        margin-left: 5px;
    }
    
    /* Shipping row mobile - centered like in LTR */
    [dir="rtl"] .shipping-row-mobile {
        text-align: center !important;
    }
    
    /* Discount row in table - centered on mobile RTL */
    [dir="rtl"] .discount-row-table {
        display: block !important;
        text-align: center !important;
    }
    
    [dir="rtl"] .discount-row-table td {
        display: block !important;
        text-align: center !important;
    }
    
    [dir="rtl"] .discount-row-table td:empty {
        display: none !important;
    }
}

/* RTL: Filter sidebar - slide from right */
[dir="rtl"] .filter-sidebar {
    left: auto !important;
    right: 0 !important;
    transform: translateX(100%) !important;
    transition: transform 0.3s ease, visibility 0.3s ease !important;
}

[dir="rtl"] .filter-sidebar.open {
    transform: translateX(0) !important;
}

[dir="rtl"] .filter-sidebar-header {
    flex-direction: row-reverse !important;
}

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

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

/* RTL: Breadcrumbs on main/category pages - align right */
[dir="rtl"] .breadcrumb {
    direction: rtl !important;
}

[dir="rtl"] .breadcrumb-content {
    flex-direction: row-reverse !important;
}

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

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

/* RTL: Filter breadcrumbs - align right */
[dir="rtl"] #filter-breadcrumbs {
    text-align: right !important;
    direction: rtl !important;
}

/* RTL: Section titles on mobile - align right */
@media (max-width: 768px) {
    [dir="rtl"] .section-title {
        text-align: right !important;
        padding-left: 0 !important;
        padding-right: 15px !important;
    }
    
    /* RTL: Product name on mobile - align right */
    [dir="rtl"] .product-name {
        text-align: right !important;
        width: 100% !important;
    }
    
    /* RTL: Product price on mobile - align right */
    [dir="rtl"] .product-price,
    [dir="rtl"] .product-price-display,
    [dir="rtl"] #product-price {
        text-align: right !important;
        width: 100% !important;
    }
    
    /* RTL: Product info on mobile - align right */
    [dir="rtl"] .product-info {
        align-items: flex-end !important;
        text-align: right !important;
    }
    
    /* RTL: Add to Cart button - align right */
    [dir="rtl"] .add-to-cart-btn {
        margin-left: auto !important;
        margin-right: 0 !important;
    }
    
    /* RTL: Marketplace buttons on mobile - full width */
    [dir="rtl"] .marketplace-buttons {
        width: 100% !important;
    }
    
    [dir="rtl"] #marketplace-buttons-container {
        width: 100% !important;
    }
    
    /* RTL: Product card button - align right */
    [dir="rtl"] .product-card .add-to-cart {
        margin-left: auto !important;
        margin-right: 0 !important;
    }
    
    /* RTL: Product card content - flex for button alignment */
    [dir="rtl"] .product-card-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-end !important;
    }
    
    [dir="rtl"] .product-card .product-title,
    [dir="rtl"] .product-card .product-price {
        width: 100% !important;
        text-align: right !important;
    }
}
