/* RTL (Right-to-Left) Styles for Arabic */

/* Only apply when lang is Arabic */
[lang="ar"],
body.rtl {
    direction: rtl;
    text-align: right;
}

/* Header and Navigation */
[lang="ar"] .header-content,
body.rtl .header-content {
    flex-direction: row-reverse;
}

[lang="ar"] .nav-list,
body.rtl .nav-list {
    flex-direction: row-reverse;
}

[lang="ar"] .header-actions,
body.rtl .header-actions {
    flex-direction: row-reverse;
}

/* Language Toggle Button */
.language-toggle {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-base);
    margin-right: var(--spacing-md);
}

.language-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.lang-text {
    font-size: var(--font-size-sm);
}

[lang="ar"] .language-toggle,
body.rtl .language-toggle {
    margin-right: 0;
    margin-left: var(--spacing-md);
}

/* Hero Section */
[lang="ar"] .hero-content .container,
body.rtl .hero-content .container {
    direction: rtl;
}

[lang="ar"] .hero-buttons,
body.rtl .hero-buttons {
    justify-content: flex-start;
}

/* About Section */
[lang="ar"] .about-text,
body.rtl .about-text {
    text-align: right;
}

/* Skills Section */
[lang="ar"] .skill-item,
body.rtl .skill-item {
    text-align: right;
}

/* Projects Section */
[lang="ar"] .project-card,
body.rtl .project-card {
    text-align: right;
}

[lang="ar"] .project-header,
body.rtl .project-header {
    flex-direction: row-reverse;
}

[lang="ar"] .project-tags,
body.rtl .project-tags {
    justify-content: flex-end;
}

/* Analyzer Section */
[lang="ar"] .analyzer-container,
body.rtl .analyzer-container {
    direction: rtl;
}

[lang="ar"] .upload-area,
body.rtl .upload-area {
    text-align: right;
}

[lang="ar"] .file-info,
body.rtl .file-info {
    flex-direction: row-reverse;
}

[lang="ar"] .stat-box,
body.rtl .stat-box {
    text-align: center;
}

[lang="ar"] .data-table,
body.rtl .data-table {
    direction: rtl;
}

[lang="ar"] .data-table th,
[lang="ar"] .data-table td,
body.rtl .data-table th,
body.rtl .data-table td {
    text-align: right;
}

/* Contact Section */
[lang="ar"] .contact-content,
body.rtl .contact-content {
    direction: rtl;
}

[lang="ar"] .contact-item,
body.rtl .contact-item {
    flex-direction: row-reverse;
    text-align: right;
}

[lang="ar"] .contact-form,
body.rtl .contact-form {
    text-align: right;
}

[lang="ar"] .form-input,
body.rtl .form-input {
    text-align: right;
}

/* Footer */
[lang="ar"] .footer-content,
body.rtl .footer-content {
    flex-direction: row-reverse;
}

[lang="ar"] .footer-social,
body.rtl .footer-social {
    flex-direction: row-reverse;
}

/* Icons - flip direction for RTL */
[lang="ar"] .fas.fa-arrow-right,
body.rtl .fas.fa-arrow-right {
    transform: scaleX(-1);
}

[lang="ar"] .fas.fa-chevron-right,
body.rtl .fas.fa-chevron-right {
    transform: scaleX(-1);
}

/* Category Icons */
[lang="ar"] .category-title,
body.rtl .category-title {
    flex-direction: row-reverse;
}

/* Quality Metrics */
[lang="ar"] .quality-metric,
body.rtl .quality-metric {
    flex-direction: row-reverse;
    text-align: right;
}

/* Outlier Cards */
[lang="ar"] .outlier-method h5,
body.rtl .outlier-method h5 {
    flex-direction: row-reverse;
}

/* Card Titles with Icons */
[lang="ar"] .card-title,
body.rtl .card-title {
    flex-direction: row-reverse;
}

[lang="ar"] .project-header i,
body.rtl .project-header i {
    margin-right: 0;
    margin-left: var(--spacing-md);
}

/* Scroll Animations */
[lang="ar"] .scroll-header,
body.rtl .scroll-header {
    text-align: center;
}

/* Mobile Menu */
[lang="ar"] .nav-mobile,
body.rtl .nav-mobile {
    text-align: right;
}

/* Buttons */
[lang="ar"] .btn,
body.rtl .btn {
    text-align: center;
}

/* Charts - keep LTR for better readability */
[lang="ar"] canvas,
body.rtl canvas {
    direction: ltr;
}

/* Back to Top Button */
[lang="ar"] .back-to-top,
body.rtl .back-to-top {
    right: auto;
    left: var(--spacing-xl);
}

/* Mobile Responsive RTL */
@media (max-width: 768px) {
    [lang="ar"] .hero-content .container,
    body.rtl .hero-content .container {
        grid-template-columns: 1fr;
    }

    [lang="ar"] .hero-text,
    body.rtl .hero-text {
        text-align: center;
    }

    [lang="ar"] .hero-buttons,
    body.rtl .hero-buttons {
        justify-content: center;
    }

    [lang="ar"] .contact-content,
    body.rtl .contact-content {
        grid-template-columns: 1fr;
    }

    [lang="ar"] .back-to-top,
    body.rtl .back-to-top {
        left: var(--spacing-lg);
    }
}

/* Arabic Font Optimization */
[lang="ar"] body,
[lang="ar"] h1,
[lang="ar"] h2,
[lang="ar"] h3,
[lang="ar"] h4,
[lang="ar"] h5,
[lang="ar"] h6,
body.rtl,
body.rtl h1,
body.rtl h2,
body.rtl h3,
body.rtl h4,
body.rtl h5,
body.rtl h6 {
    font-family: 'Cairo', 'Tajawal', 'Amiri', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Smooth transitions for language switching */
* {
    transition: text-align 0.3s ease, direction 0.3s ease;
}
