/**
 * Estanar Theme - RTL Styles
 * Right-to-Left language support (Arabic)
 * Version: 1.0.0
 */

/* ==========================================================================
   General RTL Overrides
   ========================================================================== */

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

html[dir="rtl"] body,
html[dir="rtl"],
body.rtl {
    font-family: 'Handicrafts-Med', 'Tajawal', sans-serif;
}

/* ==========================================================================
   Header RTL
   Note: direction:rtl already reverses flex row order automatically.
   Do NOT use flex-direction: row-reverse (causes double-reversal).
   ========================================================================== */

/* Dropdown - position override needed (absolute positioning ignores direction) */
html[dir="rtl"] .sub-menu,
html[dir="rtl"] .dropdown-menu,
body.rtl .sub-menu,
body.rtl .dropdown-menu,
.rtl .sub-menu,
.rtl .dropdown-menu {
    left: auto !important;
    right: 0 !important;
}

/* Mobile Menu */
html[dir="rtl"] .mobile-menu {
    transform: translateX(100%);
}

html[dir="rtl"] .mobile-menu.active {
    transform: translateX(0);
}

/* Search Close */
html[dir="rtl"] .search-close {
    right: auto;
    left: var(--spacing-xl);
}

/* ==========================================================================
   Footer RTL
   Note: direction:rtl reverses flex row order and grid column order.
   In RTL: flex-start = RIGHT, flex-end = LEFT.
   ========================================================================== */

html[dir="rtl"] .footer-brand,
html[dir="rtl"] .footer-nav-column,
html[dir="rtl"] .footer-menu,
html[dir="rtl"] .footer-contact-column,
html[dir="rtl"] .footer-heading,
html[dir="rtl"] .contact-item {
    text-align: right;
}

/* flex-start in RTL = RIGHT side (correct alignment) */
html[dir="rtl"] .social-links {
    justify-content: flex-start;
}

html[dir="rtl"] .contact-info {
    align-items: flex-start;
}

html[dir="rtl"] .footer-menu {
    align-items: flex-start;
}

/* Newsletter input text alignment only */
html[dir="rtl"] .newsletter-input-wrapper input {
    text-align: right;
}

/* ==========================================================================
   Buttons RTL
   Note: direction:rtl already reverses flex row order for buttons.
   ========================================================================== */

/* ==========================================================================
   Icons RTL
   ========================================================================== */

html[dir="rtl"] .dropdown-icon {
    margin-left: 0;
    margin-right: var(--spacing-xs);
}

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

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

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

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

/* ==========================================================================
   Form Elements RTL
   ========================================================================== */

html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select {
    text-align: right;
}

html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[type="tel"] {
    direction: ltr;
    text-align: left;
}

/* ==========================================================================
   Spacing RTL Utilities
   ========================================================================== */

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

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

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

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

/* ==========================================================================
   Animations RTL
   ========================================================================== */

html[dir="rtl"] .slide-left {
    animation-name: slideRight;
}

html[dir="rtl"] .slide-right {
    animation-name: slideLeft;
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==========================================================================
   Tutor LMS Cart & Checkout RTL
   ========================================================================== */

/* Cart Layout */
html[dir="rtl"] .estanar-tutor-cart .cart-layout,
html[dir="rtl"] .estanar-tutor-checkout .checkout-layout {
    direction: rtl;
}

/* Cart Table */
html[dir="rtl"] .estanar-tutor-cart .cart-items-table th,
html[dir="rtl"] .estanar-tutor-cart .cart-items-table td {
    text-align: right;
}

html[dir="rtl"] .estanar-tutor-cart .product-price {
    text-align: left;
}

html[dir="rtl"] .estanar-tutor-cart .price-wrapper {
    align-items: flex-start;
}

/* Continue Shopping Arrow */
html[dir="rtl"] .estanar-tutor-cart .continue-shopping i {
    transform: scaleX(-1);
}

/* Checkout Button Arrow */
html[dir="rtl"] .estanar-tutor-cart .checkout-button i {
    transform: scaleX(-1);
}

/* Form Fields */
html[dir="rtl"] .estanar-tutor-checkout .tutor-form-group label {
    text-align: right;
}

html[dir="rtl"] .estanar-tutor-checkout .tutor-form-group select {
    background-position: left 1rem center;
    padding-right: var(--spacing-md);
    padding-left: 2.5rem;
}

/* Payment Methods */
html[dir="rtl"] .estanar-tutor-checkout .tutor-checkout-payment-item {
    flex-direction: row-reverse;
}

html[dir="rtl"] .estanar-tutor-checkout .tutor-checkout-payment-item input[type="radio"] {
    margin-right: 0;
    margin-left: var(--spacing-sm);
}

/* Terms Checkbox */
html[dir="rtl"] .estanar-tutor-checkout .woocommerce-terms-and-conditions-wrapper label {
    flex-direction: row-reverse;
}

html[dir="rtl"] .estanar-tutor-checkout .woocommerce-terms-and-conditions-wrapper input[type="checkbox"] {
    margin-left: var(--spacing-sm);
    margin-right: 0;
}

/* Order Section */
html[dir="rtl"] .estanar-tutor-checkout .tutor-checkout-course-content {
    text-align: right;
}

html[dir="rtl"] .estanar-tutor-checkout .tutor-checkout-summary-row {
    flex-direction: row-reverse;
}

/* Trust Badges */
html[dir="rtl"] .estanar-tutor-cart .trust-badge,
html[dir="rtl"] .estanar-tutor-checkout .checkout-trust-badge {
    flex-direction: row-reverse;
}

html[dir="rtl"] .estanar-tutor-cart .trust-badge i,
html[dir="rtl"] .estanar-tutor-checkout .checkout-trust-badge i {
    margin-left: var(--spacing-sm);
    margin-right: 0;
}

/* Progress Steps */
html[dir="rtl"] .estanar-tutor-cart .checkout-progress,
html[dir="rtl"] .estanar-tutor-checkout .checkout-progress {
    flex-direction: row-reverse;
}

/* Product Meta */
html[dir="rtl"] .estanar-tutor-cart .product-meta {
    flex-direction: row-reverse;
}

html[dir="rtl"] .estanar-tutor-cart .product-meta .meta-item {
    flex-direction: row-reverse;
}

html[dir="rtl"] .estanar-tutor-cart .product-meta .meta-item i {
    margin-left: var(--spacing-xs);
    margin-right: 0;
}

/* ==========================================================================
   Authentication Pages RTL (Login, Register, Forgot Password, Reset Password)
   ========================================================================== */

/* Split Layout - Flip image and form sides */
html[dir="rtl"] .auth-split-layout,
body.rtl .auth-split-layout {
    flex-direction: row-reverse;
}

/* Form Groups - Align text to right */
html[dir="rtl"] .auth-form-side .form-group,
body.rtl .auth-form-side .form-group,
html[dir="rtl"] .auth-card .form-group,
body.rtl .auth-card .form-group {
    text-align: right;
}

/* Form Actions - Flip layout */
html[dir="rtl"] .form-actions,
body.rtl .form-actions {
    flex-direction: row-reverse;
}

/* Remember Me - Flip icon and text */
html[dir="rtl"] .remember-me,
body.rtl .remember-me {
    flex-direction: row-reverse;
}

/* Error/Success Messages - Align text to right */
html[dir="rtl"] .submit-success,
html[dir="rtl"] .submit-error,
body.rtl .submit-success,
body.rtl .submit-error {
    text-align: right;
}

html[dir="rtl"] .submit-success i,
html[dir="rtl"] .submit-error i,
body.rtl .submit-success i,
body.rtl .submit-error i {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Divider - Flip margins */
html[dir="rtl"] .divider::before,
body.rtl .divider::before {
    margin-right: 0;
    margin-left: 1rem;
}

html[dir="rtl"] .divider::after,
body.rtl .divider::after {
    margin-left: 0;
    margin-right: 1rem;
}

/* Back to Home Link - Flip icon direction */
html[dir="rtl"] .back-to-home,
body.rtl .back-to-home {
    flex-direction: row-reverse;
}

html[dir="rtl"] .back-to-home i,
body.rtl .back-to-home i {
    transform: scaleX(-1);
}

/* Auth Footer Link */
html[dir="rtl"] .auth-footer-link,
body.rtl .auth-footer-link {
    text-align: center;
}

/* Form Inputs - RTL Text Direction */
html[dir="rtl"] .auth-form-side input[type="text"],
html[dir="rtl"] .auth-form-side input[type="email"],
html[dir="rtl"] .auth-form-side input[type="password"],
html[dir="rtl"] .auth-card input[type="text"],
html[dir="rtl"] .auth-card input[type="email"],
html[dir="rtl"] .auth-card input[type="password"],
body.rtl .auth-form-side input[type="text"],
body.rtl .auth-form-side input[type="email"],
body.rtl .auth-form-side input[type="password"],
body.rtl .auth-card input[type="text"],
body.rtl .auth-card input[type="email"],
body.rtl .auth-card input[type="password"] {
    text-align: right;
    direction: rtl;
}

/* Centered Layout Card */
html[dir="rtl"] .auth-centered-layout,
body.rtl .auth-centered-layout {
    text-align: right;
}

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

html[dir="rtl"] .auth-card h2,
html[dir="rtl"] .auth-card p,
body.rtl .auth-card h2,
body.rtl .auth-card p {
    text-align: center;
}

/* ==========================================================================
   WooCommerce Cart & Checkout RTL
   ========================================================================== */

/* Cart Layout */
html[dir="rtl"] .cart-layout {
    direction: rtl;
}

html[dir="rtl"] .cart-page-header {
    text-align: right;
}

/* Cart Table */
html[dir="rtl"] .woocommerce-cart-form .shop_table th,
html[dir="rtl"] .woocommerce-cart-form .shop_table td {
    text-align: right;
}

html[dir="rtl"] .woocommerce-cart-form .product-subtotal,
html[dir="rtl"] .woocommerce-cart-form .product-price {
    text-align: left;
}

/* Cart Actions */
html[dir="rtl"] .woocommerce-cart-form .actions {
    text-align: right;
}

html[dir="rtl"] .woocommerce-cart-form .coupon {
    float: right;
}

/* Cart Totals */
html[dir="rtl"] .cart_totals {
    text-align: right;
}

html[dir="rtl"] .cart_totals .shop_table th {
    text-align: right;
}

html[dir="rtl"] .cart_totals .shop_table td {
    text-align: left;
}

/* Cart Trust Badges */
html[dir="rtl"] .cart-trust-badge {
    flex-direction: row-reverse;
}

html[dir="rtl"] .cart-trust-badge i {
    margin-left: var(--spacing-sm);
    margin-right: 0;
}

/* Checkout Layout */
html[dir="rtl"] .checkout-layout {
    direction: rtl;
}

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

/* Checkout Progress Steps */
html[dir="rtl"] .checkout-progress {
    flex-direction: row-reverse;
}

/* Checkout Form */
html[dir="rtl"] .woocommerce-billing-fields {
    text-align: right;
}

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

html[dir="rtl"] .woocommerce-billing-fields__field-wrapper .form-row {
    text-align: right;
}

/* Checkout Coupon */
html[dir="rtl"] .checkout-coupon-form .coupon-form-inner {
    flex-direction: row-reverse;
}

/* Checkout Order Review */
html[dir="rtl"] .woocommerce-checkout-review-order-table th {
    text-align: right;
}

html[dir="rtl"] .woocommerce-checkout-review-order-table td {
    text-align: left;
}

/* Checkout Trust Badges */
html[dir="rtl"] .checkout-trust-badge {
    flex-direction: row-reverse;
}

html[dir="rtl"] .checkout-trust-badge i {
    margin-left: var(--spacing-sm);
    margin-right: 0;
}

/* Place Order Section */
html[dir="rtl"] .place-order-section {
    text-align: right;
}

/* Payment Methods */
html[dir="rtl"] .wc_payment_methods .wc_payment_method label {
    text-align: right;
}

/* Cart Empty */
html[dir="rtl"] .cart-empty-wrapper .return-to-shop .button {
    flex-direction: row-reverse;
}

/* Thank You Page */
html[dir="rtl"] .order-received-page {
    text-align: center;
}

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

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

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

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

html[dir="rtl"] .calendar-option {
    flex-direction: row-reverse;
}
