/* ========================================
   RTL/LTR Handling for Bilingual Support
   ======================================== */

/* Root direction handling */
html[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

/* Font adjustments for Arabic */
html[lang="ar"],
html[lang="ar"] body,
html[lang="ar"] * {
    font-family: 'Tajawal', 'Cairo', 'Almarai', 'Outfit', sans-serif;
}

/* ========================================
   General Text Alignment
   ======================================== */

[dir="rtl"] {
    text-align: right;
}

[dir="ltr"] {
    text-align: left;
}

/* Center aligned elements should stay centered */
[dir="rtl"] .text-center,
[dir="rtl"] .mx-auto,
[dir="rtl"] .justify-content-center {
    text-align: center !important;
}

/* ========================================
   Margin and Padding Flipping
   ======================================== */

/* Margin Left to Right in RTL */
[dir="rtl"] .ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-4 { margin-right: 1.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-5 { margin-right: 3rem !important; margin-left: 0 !important; }

/* Margin Right to Left in RTL */
[dir="rtl"] .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-4 { margin-left: 1.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-5 { margin-left: 3rem !important; margin-right: 0 !important; }

/* Padding Left to Right in RTL */
[dir="rtl"] .ps-1 { padding-right: 0.25rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-2 { padding-right: 0.5rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-3 { padding-right: 1rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-4 { padding-right: 1.5rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-5 { padding-right: 3rem !important; padding-left: 0 !important; }

/* Padding Right to Left in RTL */
[dir="rtl"] .pe-1 { padding-left: 0.25rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-2 { padding-left: 0.5rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-3 { padding-left: 1rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-4 { padding-left: 1.5rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-5 { padding-left: 3rem !important; padding-right: 0 !important; }

/* ========================================
   Border Radius Flipping
   ======================================== */

[dir="rtl"] .rounded-start {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-top-right-radius: 0.375rem !important;
    border-bottom-right-radius: 0.375rem !important;
}

[dir="rtl"] .rounded-end {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 0.375rem !important;
    border-bottom-left-radius: 0.375rem !important;
}

/* ========================================
   Float Flipping
   ======================================== */

[dir="rtl"] .float-start {
    float: right !important;
}

[dir="rtl"] .float-end {
    float: left !important;
}

/* ========================================
   Text Alignment
   ======================================== */

[dir="rtl"] .text-start {
    text-align: right !important;
}

[dir="rtl"] .text-end {
    text-align: left !important;
}

/* ========================================
   Navigation & Menu Items
   ======================================== */

[dir="rtl"] .navbar-nav {
    flex-direction: row-reverse;
}

[dir="rtl"] .nav-item {
    margin-left: 0;
    margin-right: 1rem;
}

[dir="rtl"] .dropdown-menu {
    right: 0;
    left: auto;
}

/* ========================================
   Forms & Inputs
   ======================================== */

[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="number"],
[dir="rtl"] textarea,
[dir="rtl"] select {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] input::placeholder,
[dir="rtl"] textarea::placeholder {
    text-align: right;
}

/* ========================================
   Buttons & Icons
   ======================================== */

[dir="rtl"] .btn svg,
[dir="rtl"] .button svg {
    margin-left: 8px;
    margin-right: 0;
}

[dir="ltr"] .btn svg,
[dir="ltr"] .button svg {
    margin-right: 8px;
    margin-left: 0;
}

/* Arrow flipping for RTL */
[dir="rtl"] .arrow-right::before {
    content: "←";
}

[dir="ltr"] .arrow-right::before {
    content: "→";
}

[dir="rtl"] .arrow-left::before {
    content: "→";
}

[dir="ltr"] .arrow-left::before {
    content: "←";
}

/* ========================================
   Grid & Flexbox
   ======================================== */

[dir="rtl"] .d-flex {
    flex-direction: row-reverse;
}

[dir="rtl"] .flex-row {
    flex-direction: row-reverse !important;
}

/* Don't reverse column direction */
[dir="rtl"] .flex-column {
    flex-direction: column !important;
}

[dir="rtl"] .justify-content-start {
    justify-content: flex-end !important;
}

[dir="rtl"] .justify-content-end {
    justify-content: flex-start !important;
}

/* ========================================
   Specific Component Adjustments
   ======================================== */

/* Hero Section */
[dir="rtl"] .hero-section h1,
[dir="rtl"] .hero-section h2,
[dir="rtl"] .hero-section p {
    text-align: center;
}

/* Feature Cards */
[dir="rtl"] .feature-card {
    text-align: right;
}

[dir="rtl"] .feature-card img {
    margin-left: 0;
    margin-right: auto;
}

/* Testimonials */
[dir="rtl"] .testimonial-card {
    text-align: right;
}

[dir="rtl"] .testimonial-card .quote-icon {
    left: auto;
    right: 20px;
}

/* Pricing Cards */
[dir="rtl"] .pricing-card ul {
    text-align: right;
    padding-right: 0;
    padding-left: 1.5rem;
}

[dir="rtl"] .pricing-card ul li::before {
    right: -1.5rem;
    left: auto;
}

/* Footer */
[dir="rtl"] .footer {
    text-align: right;
}

[dir="rtl"] .footer-links {
    text-align: right;
}

/* ========================================
   FAQ Accordion
   ======================================== */

[dir="rtl"] .accordion-button {
    text-align: right;
    padding-right: 1.25rem;
    padding-left: 3rem;
}

[dir="rtl"] .accordion-button::after {
    margin-left: 0;
    margin-right: auto;
}

/* ========================================
   Modal & Dropdown Adjustments
   ======================================== */

[dir="rtl"] .modal-header {
    text-align: right;
}

[dir="rtl"] .modal-body {
    text-align: right;
}

[dir="rtl"] .modal-header .btn-close {
    margin-left: 0;
    margin-right: auto;
}

/* ========================================
   List Items
   ======================================== */

[dir="rtl"] ul,
[dir="rtl"] ol {
    padding-left: 0;
    padding-right: 2rem;
}

[dir="rtl"] ul li,
[dir="rtl"] ol li {
    text-align: right;
}

/* ========================================
   Badge & Labels
   ======================================== */

[dir="rtl"] .badge {
    margin-left: 0.5rem;
    margin-right: 0;
}

[dir="ltr"] .badge {
    margin-right: 0.5rem;
    margin-left: 0;
}

/* ========================================
   Transform Flipping for Icons
   ======================================== */

[dir="rtl"] .icon-flip {
    transform: scaleX(-1);
}

/* ========================================
   Ticker Tape Animation
   ======================================== */

[dir="rtl"] .ticker-tape {
    animation-direction: reverse;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 768px) {
    [dir="rtl"] .navbar-nav {
        flex-direction: column;
        align-items: flex-end;
    }

    [dir="rtl"] .nav-item {
        margin-right: 0;
        text-align: right;
        width: 100%;
    }
}

/* ========================================
   Utility Classes
   ======================================== */

/* Force RTL */
.force-rtl {
    direction: rtl !important;
    text-align: right !important;
}

/* Force LTR */
.force-ltr {
    direction: ltr !important;
    text-align: left !important;
}

/* Bidirectional elements (keep as-is) */
.bidi-override {
    unicode-bidi: bidi-override;
}

/* ========================================
   Arabic Font Loading (Google Fonts)
   ======================================== */

/* Add this to your HTML head:
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@200..1000&family=Tajawal:wght@200;300;400;500;700;800;900&display=swap" rel="stylesheet">
*/

/* ========================================
   Print Styles
   ======================================== */

@media print {
    [dir="rtl"] * {
        direction: rtl !important;
        text-align: right !important;
    }
}
