/* RTL (Right-to-Left) Language Support */

/* RTL Base Styles */
[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] * {
    box-sizing: border-box;
}

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

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

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

[dir="rtl"] .nav-action-btn {
    margin-left: 0.5rem;
    margin-right: 0;
}

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

[dir="rtl"] .user-dropdown {
    left: auto;
    right: 0;
}

/* Button and Form RTL Support */
[dir="rtl"] .btn {
    text-align: center;
}

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

[dir="rtl"] .search-input {
    text-align: right;
    padding-left: 1rem;
    padding-right: 2.5rem;
}

[dir="rtl"] .search-icon {
    left: auto;
    right: 0.75rem;
}

/* Content RTL Support */
[dir="rtl"] .hero-content {
    text-align: center; /* Keep hero centered for all languages */
}

[dir="rtl"] .hero-actions {
    justify-content: center;
}

[dir="rtl"] .feature-card,
[dir="rtl"] .dream-card {
    text-align: right;
}

[dir="rtl"] .feature-icon,
[dir="rtl"] .card-icon {
    margin-left: 0;
    margin-right: 0;
}

/* Footer RTL Support */
[dir="rtl"] .footer-content {
    flex-direction: row-reverse;
}

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

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

[dir="rtl"] .social-links {
    justify-content: flex-end;
}

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

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

[dir="rtl"] .close-btn {
    left: 1.5rem;
    right: auto;
}

/* Dropdown RTL Support */
[dir="rtl"] .dropdown-menu {
    left: auto;
    right: 0;
    text-align: right;
}

[dir="rtl"] .dropdown-item {
    flex-direction: row-reverse;
    text-align: right;
}

[dir="rtl"] .dropdown-item i {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Cards and Stats RTL Support */
[dir="rtl"] .stat-card {
    text-align: center; /* Keep stats centered */
}

[dir="rtl"] .cards-grid {
    text-align: right;
}

/* Mobile Menu RTL Support */
[dir="rtl"] .mobile-menu-content {
    text-align: right;
}

[dir="rtl"] .mobile-nav-link {
    flex-direction: row-reverse;
    text-align: right;
}

[dir="rtl"] .mobile-nav-link i {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Notification RTL Support */
[dir="rtl"] .notification {
    left: 1rem;
    right: auto;
}

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

/* Language Transition Effects */
.language-transition {
    transition: all 0.3s ease;
}

/* Arabic Font Support */
[dir="rtl"] body,
[dir="rtl"] * {
    font-family: 'Cairo', 'Amiri', 'Noto Sans Arabic', 'Inter', sans-serif;
}

/* Specific Arabic styling */
html[lang="ar"] body,
html[lang="ar"] * {
    font-family: 'Cairo', 'Amiri', 'Noto Sans Arabic', 'Inter', sans-serif;
}

/* Improve Arabic text rendering */
html[lang="ar"] {
    font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}

/* Specific German styling for better text rendering */
html[lang="de"] {
    hyphens: auto;
    word-break: break-word;
}

/* French typography improvements */
html[lang="fr"] {
    hanging-punctuation: first;
}

/* Spanish typography improvements */
html[lang="es"] {
    quotes: "«" "»" "'" "'";
}

/* Responsive RTL adjustments */
@media (max-width: 768px) {
    [dir="rtl"] .mobile-menu-btn {
        order: -1;
    }
    
    [dir="rtl"] .nav-brand {
        order: 1;
    }
    
    [dir="rtl"] .nav-actions {
        order: 2;
    }
}

/* High contrast mode for accessibility */
@media (prefers-contrast: high) {
    [dir="rtl"] .nav-link,
    [dir="rtl"] .footer-link {
        text-decoration: underline;
    }
}

/* Print styles for RTL */
@media print {
    [dir="rtl"] body {
        direction: rtl;
        text-align: right;
    }
}

/* Focus styles for RTL */
[dir="rtl"] :focus {
    outline-offset: -2px;
}

/* Selection styles for RTL */
[dir="rtl"] ::selection {
    direction: rtl;
}

/* Smooth transitions for direction changes */
* {
    transition: direction 0.3s ease;
}

/* Ensure images don't flip in RTL */
[dir="rtl"] img,
[dir="rtl"] .icon,
[dir="rtl"] .logo {
    transform: none !important;
}

/* Number and date formatting */
[dir="rtl"] .number,
[dir="rtl"] .date,
[dir="rtl"] .stat-number {
    direction: ltr;
    unicode-bidi: embed;
}

/* Code blocks should always be LTR */
[dir="rtl"] code,
[dir="rtl"] pre {
    direction: ltr;
    text-align: left;
}