/* ===================================================================
   INTERNATIONALIZATION (i18n) & RTL SUPPORT
   Handles RTL layout and language switcher styling
   ================================================================= */

/* Language Switcher Styles */
.language-switcher {
    position: relative;
    display: inline-block;
    margin-left: 8px;
    margin-right: 8px;
}

.language-toggle {
    background: var(--bg-tertiary, #f0f2f5);
    border: 2px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    min-width: 48px;
    min-height: 40px;
}

.language-toggle:hover {
    background: var(--primary-color, #a7f300);
    border-color: var(--primary-color, #a7f300);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(167, 243, 0, 0.3);
}

.language-flag,
.language-flag-current {
    font-size: 1.3em;
    line-height: 1;
}

.language-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    max-height: 420px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10000;
    overflow: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Scrollbar Styling for Language Dropdown */
.language-dropdown::-webkit-scrollbar {
    width: 8px;
}

.language-dropdown::-webkit-scrollbar-track {
    background: var(--bg-secondary, #f9fafb);
    border-radius: 0 12px 12px 0;
}

.language-dropdown::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-color, #a7f300) 0%, #8bc900 100%);
    border-radius: 10px;
    border: 2px solid var(--bg-secondary, #f9fafb);
}

.language-dropdown::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #8bc900 0%, #6fa000 100%);
}

/* Firefox Scrollbar */
.language-dropdown {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color, #a7f300) var(--bg-secondary, #f9fafb);
}

.language-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Arrow pointer for dropdown */
.language-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--card-bg);
}

.language-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    position: relative;
}

.language-option:hover {
    background: var(--bg-tertiary, #f0f2f5);
    padding-left: 24px;
}

.language-option.active {
    background: linear-gradient(135deg, rgba(167, 243, 0, 0.15) 0%, rgba(167, 243, 0, 0.05) 100%);
    color: var(--primary-color, #a7f300);
    font-weight: 700;
    border-left: 4px solid var(--primary-color, #a7f300);
}

.language-option.active::after {
    content: '✓';
    position: absolute;
    right: 16px;
    color: var(--primary-color, #a7f300);
    font-weight: bold;
}

.language-option .language-flag {
    font-size: 1.5em;
    line-height: 1;
}

.language-option .language-name {
    flex: 1;
    font-family: 'IBM Plex Sans Arabic', sans-serif;
}

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

[dir="rtl"] body {
    font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}

/* RTL Header Adjustments */
[dir="rtl"] .main-header .container {
    direction: rtl;
}

[dir="rtl"] .logo {
    order: 3;
}

[dir="rtl"] .main-nav {
    order: 2;
}

[dir="rtl"] .header-actions {
    order: 1;
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .right-controls {
    margin-left: 0;
    margin-right: auto;
    flex-direction: row-reverse;
}

[dir="rtl"] .language-switcher {
    margin-left: 8px;
    margin-right: 8px;
}

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

[dir="rtl"] .language-dropdown::before {
    right: auto;
    left: 20px;
}

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

[dir="rtl"] .language-option:hover {
    padding-left: 20px;
    padding-right: 24px;
}

[dir="rtl"] .language-option.active {
    border-left: none;
    border-right: 4px solid var(--primary-color, #a7f300);
}

[dir="rtl"] .language-option.active::after {
    right: auto;
    left: 16px;
}

/* RTL Navigation Menu */
/* Keep navbar layout LTR but allow text to be RTL for proper Arabic display */
[dir="rtl"] .main-header {
    text-align: left; /* Keep text alignment LTR */
}

[dir="rtl"] .main-header .container {
    flex-direction: row; /* Keep original order */
    display: flex; /* Ensure flexbox */
    justify-content: space-between; /* Prevent overlapping */
    align-items: center;
}

[dir="rtl"] .main-header .nav-menu {
    flex-direction: row; /* Keep original order */
}

[dir="rtl"] .main-header .header-actions {
    flex-direction: row; /* Keep original order */
}

[dir="rtl"] .main-header .right-controls {
    flex-direction: row; /* Keep original order */
    display: flex; /* Ensure flexbox */
    align-items: center;
    gap: 10px; /* Add spacing between controls */
}

/* Allow Arabic text to display properly in nav links */
[dir="rtl"] .main-header .nav-menu a {
    unicode-bidi: plaintext; /* Allow proper RTL text rendering */
}

/* Ensure proper text display in user menu */
[dir="rtl"] .main-header .user-name {
    unicode-bidi: plaintext;
}

/* Fix header login button text */
[dir="rtl"] .main-header .header-login {
    unicode-bidi: plaintext;
}

[dir="rtl"] .main-nav a::after {
    left: 0; /* Keep original position */
    right: auto;
}

[dir="rtl"] .main-header .language-switcher {
    direction: ltr; /* Keep LTR */
}

/* Define explicit order to prevent overlapping */
[dir="rtl"] .main-header .logo {
    order: 1; /* Logo first */
}

[dir="rtl"] .main-header .main-nav {
    order: 2; /* Navigation second */
}

[dir="rtl"] .main-header .header-actions {
    order: 4; /* Actions last (user-menu) */
    margin-left: 0;
    margin-right: 0;
}

[dir="rtl"] .main-header .right-controls {
    order: 3; /* Controls before user menu */
    margin-left: 0;
}

/* RTL Hero Section */
[dir="rtl"] .hero-section .container {
    /* flex-direction: row-reverse; */
}

[dir="rtl"] .cta-buttons {
    /* flex-direction: row-reverse;
    justify-content: flex-start; */
}

[dir="rtl"] .btn-primary-hero,
[dir="rtl"] .btn-secondary-hero {
    flex-direction: row-reverse;
}

[dir="rtl"] .hero-stats {
    /* flex-direction: row-reverse; */
}

/* RTL Feature Cards */
[dir="rtl"] .feature-cards {
    flex-direction: row-reverse;
}

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

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

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

/* RTL User Menu */
/* Keep user menu in navbar with proper layout */
[dir="rtl"] .main-header .user-menu-toggle {
    flex-direction: row; /* Keep original order */
    direction: ltr; /* Force LTR for user menu button */
}

[dir="rtl"] .main-header .user-dropdown {
    right: 0; /* Keep original position */
    left: auto;
    direction: ltr; /* Keep LTR for dropdown */
}

[dir="rtl"] .main-header .dropdown-item {
    flex-direction: row; /* Keep original order */
    text-align: left;
    direction: ltr; /* Force LTR */
}

/* For user menu outside navbar (if any) */
[dir="rtl"] .user-menu-toggle {
    flex-direction: row-reverse;
}

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

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

/* RTL Dashboard & Forms */
[dir="rtl"] .dashboard-controls,
[dir="rtl"] .form-group,
[dir="rtl"] .input-group {
    flex-direction: row-reverse;
}

[dir="rtl"] .form-label {
    text-align: right;
}

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

/* RTL Buttons with Icons */
[dir="rtl"] .btn-primary-hero i,
[dir="rtl"] .btn-secondary-hero i {
    order: -1;
}

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

/* RTL Mobile Navigation */
/* Keep mobile navbar layout consistent */
@media (max-width: 768px) {
    [dir="rtl"] .main-header .container {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
    }
    
    [dir="rtl"] .main-header .main-nav {
        right: 0; /* Keep original position */
        left: auto;
    }

    [dir="rtl"] .main-header .nav-menu {
        flex-direction: column; /* Keep column layout */
    }
    
    [dir="rtl"] .main-header .nav-menu a {
        text-align: left; /* Keep text left aligned */
    }

    [dir="rtl"] .main-header .language-dropdown {
        left: auto;
        right: -10px; /* Keep original position */
    }
    
    /* Keep proper order on mobile */
    [dir="rtl"] .main-header .logo {
        order: 1;
    }
    
    [dir="rtl"] .main-header .header-actions {
        order: 2;
        display: none; /* Hide on mobile if shown */
    }
    
    [dir="rtl"] .main-header .right-controls {
        order: 3;
        display: flex;
        gap: 8px;
    }
    
    [dir="rtl"] .main-header .nav-toggle {
        order: 4;
    }
}

/* RTL Pricing Cards */
[dir="rtl"] .pricing-cards {
    flex-direction: row-reverse;
}

[dir="rtl"] .pricing-card ul {
    text-align: right;
    padding-right: 0;
    padding-left: 0;
}

[dir="rtl"] .pricing-card li::before {
    margin-right: 0;
    margin-left: 10px;
}

/* RTL Gallery Grid */
[dir="rtl"] .gallery-grid {
    direction: rtl;
}

/* Smooth transitions for direction changes */
* {
    transition-property: margin, padding, left, right;
    transition-duration: 0s;
}

/* Ensure language switcher is always separate from user menu */
.right-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Desktop: Show language switcher separately */
@media (min-width: 769px) {
    .language-switcher {
        display: inline-block !important;
    }
}

/* Mobile: Keep language switcher visible */
@media (max-width: 768px) {
    .language-switcher {
        display: inline-block !important;
    }
    
    .right-controls {
        gap: 4px;
    }
    
    .language-toggle {
        min-width: 40px;
        min-height: 36px;
        padding: 6px 10px;
        font-size: 1.1rem;
    }
    
    .language-dropdown {
        max-height: 320px;
    }
    
    .language-dropdown::-webkit-scrollbar {
        width: 6px;
    }
}

