/* Language Switcher and RTL Support */

/* Language Switcher Dropdown */
.language-switcher {
    position: relative;
    margin-left: 20px;
    z-index: 1000;
}

/* Debug - ensure visibility */
.language-switcher * {
    box-sizing: border-box;
}

/* Debug styles removed - text should now be visible */

.lang-dropdown {
    position: relative;
    display: inline-block;
}

.lang-current {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #333 !important;
    padding: 8px 12px !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    min-width: 120px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    width: auto !important;
    height: auto !important;
}

.lang-current:hover {
    background: rgba(255, 255, 255, 1) !important;
    color: #000 !important;
}

.lang-current::after {
    content: "▼";
    font-size: 10px;
    transition: transform 0.3s ease;
    opacity: 0.8;
    margin-left: auto;
    color: #666 !important;
}

.lang-dropdown.active .lang-current::after {
    transform: rotate(180deg);
}

.lang-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1001;
    border: 1px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

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

.lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 13px;
}

.lang-option:last-child {
    border-bottom: none;
}

.lang-option:hover {
    background: var(--gray-50);
    color: var(--primary);
}

.lang-option.active {
    background: var(--primary);
    color: var(--white);
}

.flag-icon {
    width: 18px;
    height: 13px;
    border-radius: 2px;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.flag-fr {
    background: linear-gradient(to right, #002395 33%, #fff 33%, #fff 66%, #ed2939 66%);
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.flag-ma {
    background: #c1272d;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.flag-ma::after {
    content: "★";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #006233;
    font-size: 8px;
    font-weight: bold;
}

.lang-text {
    font-weight: 500;
    font-size: 13px;
    color: inherit;
    white-space: nowrap;
}

.lang-current .lang-text {
    color: #333 !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    white-space: nowrap !important;
}

/* Ensure the current language container has proper flex layout */
.lang-current {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
}

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

[dir="rtl"] .container {
    direction: rtl;
}

[dir="rtl"] .header-content {
    flex-direction: row-reverse;
    justify-content: space-between;
}

[dir="rtl"] .nav-menu {
    flex-direction: row;
    order: 1;
    width: auto;
    justify-content: flex-start;
    margin-right: 40px;
}

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

[dir="rtl"] .nav-link {
    margin-left: 30px;
    margin-right: 0;
}

[dir="rtl"] .nav-link:first-of-type {
    margin-right: 0;
    margin-left: 20px;
}

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

/* Additional RTL navbar improvements */
[dir="rtl"] .nav-menu {
    text-align: right;
}

/* Group button and language switcher on the left in RTL */
[dir="rtl"] .nav-menu .btn-header,
[dir="rtl"] .nav-menu .language-switcher {
    margin-left: 0;
    margin-right: 15px;
}

[dir="rtl"] .mobile-menu-toggle {
    order: -1;
}

/* Create a flex container for nav links vs buttons/switcher */
[dir="rtl"] .nav-menu {
    display: flex;
    align-items: center;
}

[dir="rtl"] .nav-menu > a.nav-link {
    flex: 0 0 auto;
}

[dir="rtl"] .nav-menu > .btn-header {
    margin-left: auto;
    margin-right: 15px;
    order: 10;
}

[dir="rtl"] .nav-menu > .language-switcher {
    margin-right: 0;
    order: 11;
}

[dir="rtl"] .hero-content {
    text-align: center;
}

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

[dir="rtl"] .section-header {
    text-align: center;
}

[dir="rtl"] .section-title {
    text-align: center;
}

[dir="rtl"] .section-subtitle {
    text-align: center;
}

[dir="rtl"] .hero-title {
    text-align: center;
}

[dir="rtl"] .hero-subtitle {
    text-align: center;
}

[dir="rtl"] .formations-grid {
    direction: rtl;
}

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

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

[dir="rtl"] .contact-content {
    direction: rtl;
}

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

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

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

[dir="rtl"] .contact-info {
    text-align: right;
}

[dir="rtl"] .contact-item {
    text-align: right;
}

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

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

[dir="rtl"] .footer-content {
    direction: rtl;
}

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

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

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

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

[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6 {
    font-family: 'Tajawal', 'Cairo', 'Amiri', Arial, sans-serif;
    font-weight: 600;
}

/* Success Popup RTL */
[dir="rtl"] .popup-content {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .popup-btn {
    margin: 0 auto;
}

/* Mobile RTL Support */
@media (max-width: 768px) {
    [dir="rtl"] .mobile-menu-toggle {
        order: -1;
    }
    
    [dir="rtl"] .nav-menu {
        text-align: right;
    }
    
    [dir="rtl"] .nav-menu.active {
        right: auto;
        left: 0;
    }
    
    [dir="rtl"] .hero-content {
        text-align: center;
    }
    
    [dir="rtl"] .hero-buttons {
        justify-content: center;
    }
}

/* Language Switcher Mobile */
@media (max-width: 768px) {
    .language-switcher {
        margin: 10px 0;
        text-align: center;
    }
    
    [dir="rtl"] .language-switcher {
        margin: 10px 0;
    }
}

/* Form Direction Fix */
[dir="rtl"] .form-row {
    direction: rtl;
}

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

/* Button RTL */
[dir="rtl"] .btn {
    direction: rtl;
}

[dir="rtl"] .btn i {
    margin-left: 8px;
    margin-right: 0;
}

/* Stats Section RTL */
[dir="rtl"] .stats-grid {
    direction: rtl;
}

[dir="rtl"] .stat-item {
    text-align: right;
}

/* Testimonials RTL */
[dir="rtl"] .testimonials-grid {
    direction: rtl;
}

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

[dir="rtl"] .testimonial-author {
    text-align: right;
}
