/* ===================================
   Arabic (RTL) Styles Override
   =================================== */

/* RTL Typography */
html[dir="rtl"] body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-primary: 'Cairo', sans-serif;
    --font-secondary: 'Amiri', serif;
}

/* RTL Layout Adjustments */
html[dir="rtl"] .header-top-content {
    flex-direction: row-reverse;
}

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

html[dir="rtl"] .header-actions {
    order: 1;
}

html[dir="rtl"] .date-time {
    flex-direction: row-reverse;
}

/* RTL Navigation */
html[dir="rtl"] .nav-menu {
    direction: rtl;
}

html[dir="rtl"] .nav-menu li a {
    flex-direction: row-reverse;
}

/* RTL Search Bar */
html[dir="rtl"] .search-bar-content {
    flex-direction: row-reverse;
}

html[dir="rtl"] .search-filters {
    flex-direction: row-reverse;
}

/* RTL Featured Content */
html[dir="rtl"] .featured-meta {
    direction: rtl;
}

/* RTL Article Cards */
html[dir="rtl"] .article-meta {
    direction: rtl;
}

html[dir="rtl"] .article-author,
html[dir="rtl"] .article-date {
    flex-direction: row-reverse;
}

/* RTL Section Headers */
html[dir="rtl"] .section-header {
    flex-direction: row-reverse;
}

/* RTL Newsletter Form */
html[dir="rtl"] .newsletter-form {
    flex-direction: row-reverse;
}

/* RTL Footer */
html[dir="rtl"] .footer-content {
    direction: rtl;
    text-align: right;
}

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

/* RTL Mobile Menu Toggle */
html[dir="rtl"] .mobile-menu-toggle {
    order: 2;
}

/* RTL Category Icons */
html[dir="rtl"] .category-card i {
    margin-bottom: var(--spacing-md);
}

/* RTL Pagination */
html[dir="rtl"] .pagination {
    direction: rtl;
}

/* Language Switch Button */
.lang-switch {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
}

.lang-switch:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* RTL Article Category Badge */
html[dir="rtl"] .article-category {
    right: auto;
    left: var(--spacing-md);
}

html[dir="rtl"] .featured-category {
    display: inline-block;
}

/* RTL Stats and Metrics */
html[dir="rtl"] .article-meta-item {
    flex-direction: row-reverse;
}

/* RTL Buttons with Icons */
html[dir="rtl"] .btn-primary i,
html[dir="rtl"] .btn-secondary i {
    margin-left: 0;
    margin-right: var(--spacing-sm);
}

/* RTL List Items */
html[dir="rtl"] ul,
html[dir="rtl"] ol {
    padding-right: var(--spacing-2xl);
    padding-left: 0;
}

/* RTL Blockquotes */
html[dir="rtl"] blockquote {
    border-left: none;
    border-right: 4px solid var(--primary-color);
    padding-left: 0;
    padding-right: var(--spacing-xl);
}

/* RTL Form Elements */
html[dir="rtl"] input[type="text"],
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="search"],
html[dir="rtl"] textarea,
html[dir="rtl"] select {
    text-align: right;
    direction: rtl;
}

/* RTL Placeholder */
html[dir="rtl"] input::placeholder,
html[dir="rtl"] textarea::placeholder {
    text-align: right;
}

/* RTL Share Buttons */
html[dir="rtl"] .share-btn {
    flex-direction: row-reverse;
}

/* RTL Comment Items */
html[dir="rtl"] .comment-header {
    flex-direction: row-reverse;
}

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

/* RTL Admin Sidebar */
html[dir="rtl"] .admin-sidebar {
    right: 0;
    left: auto;
}

html[dir="rtl"] .admin-main {
    margin-right: 260px;
    margin-left: 0;
}

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

html[dir="rtl"] .admin-nav-link i {
    margin-left: var(--spacing-md);
    margin-right: 0;
}

/* RTL Table */
html[dir="rtl"] .admin-table {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .admin-table th,
html[dir="rtl"] .admin-table td {
    text-align: right;
}

/* RTL Form Groups */
html[dir="rtl"] .form-group label {
    text-align: right;
}

/* RTL Article Item */
html[dir="rtl"] .article-item {
    flex-direction: row-reverse;
}

html[dir="rtl"] .article-item-actions {
    justify-content: flex-start;
}

/* RTL Stat Card */
html[dir="rtl"] .stat-card {
    flex-direction: row-reverse;
}

/* RTL Table Actions */
html[dir="rtl"] .table-actions {
    justify-content: flex-start;
}

/* RTL Sources List */
html[dir="rtl"] .article-sources li:before {
    content: "← ";
    margin-right: 0;
    margin-left: var(--spacing-sm);
}

/* Arabic Number Formatting */
html[dir="rtl"] .article-meta-item,
html[dir="rtl"] .stat-content h3 {
    font-variant-numeric: lining-nums;
}

/* Responsive RTL Adjustments */
@media (max-width: 768px) {
    html[dir="rtl"] .admin-main {
        margin-right: 0;
    }
    
    html[dir="rtl"] .header-top-content {
        flex-direction: row-reverse;
    }
    
    html[dir="rtl"] .newsletter-form {
        flex-direction: column;
    }
}

/* Better Arabic Font Rendering */
html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] h5,
html[dir="rtl"] h6 {
    font-weight: 700;
    letter-spacing: 0;
}

html[dir="rtl"] p {
    line-height: 2;
    text-align: justify;
}

/* Arabic Specific Typography */
html[dir="rtl"] .logo h1 {
    font-family: 'Cairo', sans-serif;
    font-weight: 800;
}

html[dir="rtl"] .article-content {
    font-family: 'Amiri', serif;
    font-size: 1.25rem;
    line-height: 2;
    text-align: justify;
}

html[dir="rtl"] .tagline {
    font-family: 'Cairo', sans-serif;
}

/* RTL Icon Spacing */
html[dir="rtl"] i + span,
html[dir="rtl"] span + i {
    margin-left: 0;
    margin-right: var(--spacing-sm);
}

html[dir="rtl"] i {
    margin-left: var(--spacing-sm);
    margin-right: 0;
}

/* Fix for specific elements */
html[dir="rtl"] .nav-menu li a i {
    margin-left: var(--spacing-sm);
    margin-right: 0;
}

html[dir="rtl"] .header-actions {
    gap: var(--spacing-md);
}

html[dir="rtl"] .date-time i {
    margin-left: var(--spacing-sm);
    margin-right: 0;
}

/* Newsletter button order */
html[dir="rtl"] .newsletter-form button {
    order: -1;
}

/* Featured metadata proper alignment */
html[dir="rtl"] .featured-meta span {
    flex-direction: row-reverse;
}

html[dir="rtl"] .featured-meta span i {
    margin-left: var(--spacing-sm);
    margin-right: 0;
}

/* Better number display for Arabic */
html[dir="rtl"] {
    font-feature-settings: "ss02";
}

/* Search bar RTL fixes */
html[dir="rtl"] #searchButton {
    order: -1;
}

html[dir="rtl"] #searchClose {
    order: 1;
}

html[dir="rtl"] #searchInput {
    order: 0;
}