/* ============================================
   RTL Support Styles
   ============================================ */

body.rtl {
    direction: rtl;
    text-align: right;
}

body.rtl .container {
    direction: rtl;
}

/* Header RTL */
body.rtl .header-content {
    flex-direction: row-reverse;
}

body.rtl .main-nav {
    padding-left: 7rem;
    padding-right: 0;
}

body.rtl .nav-list {
    flex-direction: row-reverse;
}

body.rtl .dropdown-menu {
    left: auto;
    right: 0;
    text-align: right;
}

body.rtl .dropdown-menu a:hover {
    padding-left: 1.5rem;
    padding-right: 2rem;
}

/* Language Switcher RTL */
body.rtl .language-switcher {
    margin-left: 0.75rem;
    margin-right: 0;
}

body.rtl .cta-button {
    margin-left: 1rem;
    margin-right: 0;
}

/* Content RTL */
body.rtl .section-header {
    text-align: right;
}

body.rtl .about-content {
    flex-direction: row-reverse;
}

body.rtl .content-grid {
    flex-direction: row-reverse;
}

body.rtl .content-sidebar {
    margin-right: 0;
    margin-left: 2rem;
}

body.rtl .footer-content {
    flex-direction: row-reverse;
}

body.rtl .footer-col {
    text-align: right;
}

body.rtl .social-links {
    justify-content: flex-start;
}

body.rtl .contact-info li {
    text-align: right;
}

body.rtl .contact-info li i {
    margin-left: 0.75rem;
    margin-right: 0;
}

/* Forms RTL */
body.rtl .form-row {
    flex-direction: row-reverse;
}

body.rtl .form-group {
    text-align: right;
}

body.rtl .form-group label {
    text-align: right;
}

body.rtl .form-group input,
body.rtl .form-group select,
body.rtl .form-group textarea {
    text-align: right;
}

/* Buttons RTL */
body.rtl .btn {
    direction: rtl;
}

body.rtl .btn i {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Mobile RTL - السايدبار والقائمة الجانبية بالعربية */
@media (max-width: 768px) {
    /* منع قص الهيدر وإظهار زر القائمة (الثلاث شرط) دائماً */
    body.rtl .main-header,
    body.rtl .main-header .container,
    body.rtl .header-content {
        overflow: visible !important;
    }
    
    body.rtl .header-content {
        flex-wrap: nowrap;
        gap: 0.5rem !important;
    }
    
    /* زر الهامبرغر لا يتقلص ويبقى ظاهراً على اليمين في الوضع العربي */
    body.rtl .mobile-menu-toggle {
        flex-shrink: 0 !important;
        min-width: 48px !important;
        min-height: 48px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        order: -1; /* أول عنصر بصرياً = أقصى اليمين في RTL */
    }
    
    /* منع اقتصاص زر اللغة وإظهاره بالكامل */
    body.rtl .language-switcher {
        flex-shrink: 0 !important;
        min-width: 52px !important;
        min-height: 40px !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
        visibility: visible !important;
        opacity: 1 !important;
        overflow: visible !important;
        order: 0;
    }
    
    /* السماح بتقلص الشعار فقط حتى لا يدفع زر اللغة خارج الشاشة */
    body.rtl .header-content .logo {
        flex-shrink: 1;
        min-width: 0;
    }
    
    body.rtl .header-content .logo span {
        max-width: 120px !important;
    }
    
    body.rtl .main-nav {
        left: auto !important;
        right: -100% !important;
        text-align: right;
        padding-left: 0;
        padding-right: 0;
        overflow-x: visible !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }
    
    body.rtl .main-nav.active {
        right: 0 !important;
        left: auto !important;
    }
    
    /* السايدبار: كل النصوص على الجانب الأيسر */
    body.rtl .main-nav .nav-list {
        flex-direction: column !important;
        align-items: stretch !important;
        padding-left: var(--spacing-md, 1rem) !important;
        padding-right: var(--spacing-sm, 0.5rem) !important;
        overflow: visible !important;
        box-sizing: border-box !important;
        direction: ltr !important;
        text-align: left !important;
    }
    
    body.rtl .main-nav .nav-list > li {
        text-align: left !important;
        width: 100% !important;
        max-width: 100% !important;
        direction: ltr !important;
        overflow: visible !important;
        box-sizing: border-box !important;
    }
    
    /* جميع روابط القائمة - محاذاة لليسار وعدم قطع النص */
    body.rtl .main-nav .nav-list > li > a {
        flex-direction: row !important;
        justify-content: flex-start !important;
        text-align: left !important;
        padding: 1rem 0 1rem 0.75rem !important;
        padding-left: 0.75rem !important;
        padding-right: 0 !important;
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        direction: ltr !important;
        align-items: center !important;
        overflow: visible !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        box-sizing: border-box !important;
    }
    
    /* عناصر الـ dropdown - السهم على اليمين والنص على اليسار */
    body.rtl .main-nav .nav-list > li.has-dropdown > a {
        justify-content: space-between !important;
    }
    
    body.rtl .main-nav .nav-list > li.has-dropdown > a::after {
        order: 1;
        margin-left: 0;
        margin-right: auto;
        flex-shrink: 0;
    }
    
    body.rtl .main-nav .nav-list > li > a i.fa-chevron-down {
        margin-left: 0.5rem;
        margin-right: 0;
    }
    
    body.rtl .main-nav .dropdown-menu {
        text-align: left !important;
        padding: 0.5rem 0 0.5rem 1.5rem !important;
        left: 0 !important;
        right: auto !important;
        direction: ltr !important;
    }
    
    body.rtl .main-nav .dropdown-menu li {
        text-align: left !important;
    }
    
    body.rtl .main-nav .dropdown-menu li a {
        text-align: left !important;
        padding: 0.75rem 0 0.75rem 0.75rem !important;
        direction: ltr !important;
        white-space: normal !important;
        overflow: visible !important;
    }
    
    body.rtl .content-sidebar {
        margin-left: 0;
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    body.rtl .header-content .logo span {
        max-width: 90px !important;
    }
    
    body.rtl .language-switcher {
        min-width: 48px !important;
        padding: 0.4rem 0.5rem !important;
        font-size: 0.7rem !important;
    }
    
    body.rtl .main-nav .nav-list {
        padding-left: 0.75rem !important;
        padding-right: 0.5rem !important;
    }
    
    body.rtl .main-nav .nav-list > li > a {
        text-align: left !important;
        padding-left: 0.75rem !important;
    }
    
    body.rtl .main-nav .dropdown-menu {
        padding: 0.5rem 0 0.5rem 1rem !important;
    }
}
