/**
 * RTL Support Styles for PTCO Theme
 *
 * This theme is built RTL-first (Persian/Farsi).
 * This file contains:
 * - RTL-specific utilities
 * - Mixed-direction content handling
 * - Form element RTL fixes
 * - Third-party plugin RTL overrides
 */

/* ============================================
   RTL Utilities
   ============================================ */

/* Force LTR for specific content (e.g., code, URLs, numbers) */
.ltr,
[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

/* Force RTL (useful inside LTR containers) */
.rtl,
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

/* Mixed content - numbers, dates, technical text */
.ltr-inline {
    direction: ltr;
    display: inline-block;
    unicode-bidi: embed;
}

/* Phone numbers, IP addresses, technical values */
.phone-number,
.ip-address,
.technical-value,
.email-address {
    direction: ltr;
    unicode-bidi: embed;
    display: inline-block;
}

/* Code blocks should be LTR */
code,
pre,
kbd,
samp,
.code-block {
    direction: ltr;
    text-align: left;
    unicode-bidi: embed;
}

/* URLs should be LTR */
.url,
.file-path {
    direction: ltr;
    unicode-bidi: embed;
    word-break: break-all;
}

/* ============================================
   Form Elements RTL Fixes
   ============================================ */

/* Input fields - ensure proper text alignment */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
textarea,
select {
    text-align: right;
}

/* Email and URL inputs should be LTR */
input[type="email"],
input[type="url"] {
    direction: ltr;
    text-align: left;
}

/* Phone number input - LTR for digits */
input[type="tel"] {
    direction: ltr;
    text-align: left;
}

/* Number input */
input[type="number"] {
    direction: ltr;
    text-align: left;
}

/* Search input - keep RTL for Persian search */
input[type="search"] {
    direction: rtl;
    text-align: right;
}

/* Select dropdown arrow positioning */
select {
    background-position: left 12px center;
    padding-left: 40px;
    padding-right: 16px;
}

/* Checkbox and radio labels */
input[type="checkbox"],
input[type="radio"] {
    margin-left: 8px;
    margin-right: 0;
}

/* ============================================
   Icon Positioning (RTL Flips)
   ============================================ */

/* Icons that should flip in RTL */
.icon-flip-rtl {
    transform: scaleX(-1);
}

/* Arrow icons */
.arrow-left,
.icon-arrow-left,
.nav-prev .icon {
    transform: scaleX(-1);
}

.arrow-right,
.icon-arrow-right,
.nav-next .icon {
    transform: scaleX(-1);
}

/* Chevron icons in RTL */
.chevron-left {
    transform: rotate(180deg);
}

.chevron-right {
    transform: rotate(0deg);
}

/* ============================================
   List RTL Fixes
   ============================================ */

/* Ordered lists */
ol {
    padding-right: 2rem;
    padding-left: 0;
}

/* Unordered lists */
ul.styled-list,
ul.bullet-list {
    padding-right: 1.5rem;
    padding-left: 0;
}

ul.styled-list li::before,
ul.bullet-list li::before {
    right: 0;
    left: auto;
}

/* ============================================
   Table RTL Fixes
   ============================================ */

table {
    direction: rtl;
}

th,
td {
    text-align: right;
}

/* Numeric columns should be LTR */
td.numeric,
th.numeric,
.price-column,
.number-column {
    direction: ltr;
    text-align: left;
}

/* ============================================
   Contact Form 7 RTL Fixes
   ============================================ */

.wpcf7-form {
    direction: rtl;
    text-align: right;
}

.wpcf7-form input,
.wpcf7-form textarea {
    text-align: right;
}

.wpcf7-form input[type="email"],
.wpcf7-form input[type="url"],
.wpcf7-form input[type="tel"] {
    direction: ltr;
    text-align: left;
}

.wpcf7-not-valid-tip {
    text-align: right;
}

.wpcf7-response-output {
    text-align: center;
}

/* ============================================
   Yoast SEO RTL Fixes
   ============================================ */

.yoast-schema-graph,
.yoast-breadcrumb a {
    direction: ltr;
}

/* ============================================
   WHMCS Bridge RTL Fixes
   ============================================ */

.whmcs-bridge-content {
    direction: rtl;
    text-align: right;
}

/* Price displays in WHMCS */
.whmcs-price,
.whmcs-amount {
    direction: ltr;
    unicode-bidi: embed;
}

/* ============================================
   Pagination RTL
   ============================================ */

.pagination .page-btn,
.pagination .page-numbers {
    order: 1;
}

.pagination .page-btn.prev,
.pagination .page-numbers.prev {
    order: 0;
}

.pagination .page-btn.next,
.pagination .page-numbers.next {
    order: 2;
}

/* ============================================
   Modal and Dropdown RTL
   ============================================ */

/* Dropdown menus open to the left in RTL */
.dropdown-menu {
    right: 0;
    left: auto;
}

/* Modal close button */
.modal-close {
    left: 1rem;
    right: auto;
}

/* ============================================
   Persian Number Display
   ============================================ */

/* Class to use Persian numerals */
.persian-numerals {
    font-feature-settings: "locl";
}

/* Keep Western numerals for prices and technical data */
.western-numerals {
    font-feature-settings: normal;
}

/* ============================================
   Print Styles RTL
   ============================================ */

@media print {
    body {
        direction: rtl;
        text-align: right;
    }

    /* Ensure proper page breaks */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
}

/* ============================================
   Responsive RTL Adjustments
   ============================================ */

@media (max-width: 768px) {
    /* Mobile menu slides from right in RTL */
    .mobile-menu {
        right: 0;
        left: auto;
        transform: translateX(100%);
    }

    .mobile-menu.active {
        transform: translateX(0);
    }

    /* Stack order adjustments */
    .reverse-on-mobile {
        flex-direction: column-reverse;
    }
}

/* ============================================
   Browser-Specific RTL Fixes
   ============================================ */

/* Firefox scrollbar position fix */
@-moz-document url-prefix() {
    html {
        scrollbar-gutter: stable;
    }
}

/* Safari RTL fixes */
@supports (-webkit-touch-callout: none) {
    input[type="search"]::-webkit-search-cancel-button {
        -webkit-appearance: none;
        appearance: none;
    }
}
