/**
 * Language Switcher Styles - Enhanced Design
 * تصميم مبدل اللغات المحسن
 */

/* Language Switcher Container */
.language-switcher {
    position: relative;
    margin: 0 12px;
    z-index: 100;
}

.language-dropdown {
    position: relative;
    display: inline-block;
}

/* Language Toggle Button - Enhanced Design */
.language-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #8B5CF6 0%, #A855F7 50%, #C084FC 100%);
    color: white;
    border: 2px solid rgba(255, 215, 0, 0.2);
    border-radius: 30px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 4px 15px rgba(139, 92, 246, 0.3),
        0 2px 8px rgba(255, 215, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    min-width: 140px;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.language-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.3), transparent);
    transition: left 0.6s ease;
}

.language-toggle:hover::before {
    left: 100%;
}

.language-toggle:hover {
    background: linear-gradient(135deg, #7C3AED 0%, #9333EA 50%, #A855F7 100%);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 8px 25px rgba(139, 92, 246, 0.4),
        0 4px 12px rgba(255, 215, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 215, 0, 0.4);
}

.language-toggle:active {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 
        0 4px 15px rgba(139, 92, 246, 0.3),
        0 2px 8px rgba(255, 215, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Language Flag - Enhanced */
.language-flag {
    font-size: 20px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: all 0.3s ease;
}

.language-toggle:hover .language-flag {
    transform: scale(1.1);
    filter: drop-shadow(0 3px 6px rgba(255, 215, 0, 0.3));
}

/* Language Name - Enhanced */
.language-name {
    font-size: 15px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.5px;
}

/* Dropdown Arrow - Enhanced */
.dropdown-arrow {
    font-size: 12px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-left: 6px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.language-dropdown.active .dropdown-arrow {
    transform: rotate(180deg) scale(1.1);
}

.language-toggle:hover .dropdown-arrow {
    transform: scale(1.1);
}

.language-dropdown.active .language-toggle:hover .dropdown-arrow {
    transform: rotate(180deg) scale(1.2);
}

/* Language Menu - Enhanced Design */
.language-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 16px;
    box-shadow: 
        0 20px 40px rgba(139, 92, 246, 0.15),
        0 8px 16px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(139, 92, 246, 0.1);
    list-style: none;
    padding: 12px 8px;
    margin: 12px 0 0 0;
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-15px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
}

.language-menu::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid rgba(139, 92, 246, 0.1);
    border-bottom: none;
    border-right: none;
    transform: translateX(-50%) rotate(45deg);
}

.language-dropdown.active .language-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
    display: block;
}

/* Language Option - Enhanced */
.language-option {
    margin: 4px 0;
}

.language-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    color: #4B5563;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 12px;
    margin: 0 6px;
    position: relative;
    overflow: hidden;
}

.language-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #8B5CF6 0%, #A855F7 100%);
    transition: left 0.4s ease;
    z-index: -1;
}

.language-link:hover::before {
    left: 0;
}

.language-link:hover {
    background: transparent;
    color: white;
    transform: translateX(4px) scale(1.02);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.language-link .language-flag {
    font-size: 18px;
    transition: all 0.3s ease;
}

.language-link:hover .language-flag {
    transform: scale(1.15) rotate(5deg);
    filter: drop-shadow(0 2px 4px rgba(255, 215, 0, 0.3));
}

.language-link .language-name {
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* Mobile Responsive - Enhanced */
@media (max-width: 768px) {
    .language-switcher {
        margin: 0 8px;
    }
    
    .language-toggle {
        padding: 10px 16px;
        font-size: 14px;
        min-width: 120px;
        gap: 8px;
    }
    
    .language-name {
        font-size: 14px;
    }
    
    .language-flag {
        font-size: 18px;
    }
    
    .language-menu {
        min-width: 140px;
        left: 50%;
        transform: translateX(-50%) translateY(-15px) scale(0.95);
        margin-top: 10px;
    }
    
    .language-dropdown.active .language-menu {
        transform: translateX(-50%) translateY(0) scale(1);
    }
    
    .language-link {
        padding: 12px 16px;
        font-size: 14px;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .language-switcher {
        margin: 0 6px;
    }
    
    .language-toggle {
        padding: 8px 14px;
        font-size: 13px;
        min-width: 110px;
        gap: 7px;
        border-radius: 25px;
    }
    
    .language-name {
        font-size: 13px;
    }
    
    .language-flag {
        font-size: 17px;
    }
    
    .dropdown-arrow {
        font-size: 11px;
        margin-left: 5px;
    }
    
    .language-menu {
        min-width: 130px;
        margin-top: 8px;
        padding: 10px 6px;
    }
    
    .language-link {
        padding: 10px 14px;
        font-size: 13px;
        gap: 9px;
        margin: 0 4px;
    }
    
    .language-link .language-flag {
        font-size: 16px;
    }
}

/* تحسينات للشاشات 360px */
@media (max-width: 360px) {
    .language-switcher {
        margin: 0 5px;
    }
    
    .language-toggle {
        padding: 7px 12px;
        font-size: 12px;
        min-width: 100px;
        gap: 6px;
        border-radius: 22px;
    }
    
    .language-name {
        font-size: 12px;
        display: none; /* إخفاء النص في الشاشات 360px */
    }
    
    .language-flag {
        font-size: 15px;
    }
    
    .dropdown-arrow {
        font-size: 10px;
        margin-left: 4px;
    }
    
    .language-menu {
        min-width: 125px;
        margin-top: 7px;
        padding: 9px 5px;
    }
    
    .language-link {
        padding: 9px 13px;
        font-size: 12px;
        gap: 7px;
        margin: 0 3px;
    }
    
    .language-link .language-flag {
        font-size: 15px;
    }
}

/* تحسينات للشاشات الصغيرة جداً (300px وأقل) */
@media (max-width: 300px) {
    .language-switcher {
        margin: 0 4px;
    }
    
    .language-toggle {
        padding: 6px 10px;
        font-size: 11px;
        min-width: 90px;
        gap: 5px;
        border-radius: 20px;
    }
    
    .language-name {
        font-size: 11px;
        display: none; /* إخفاء النص في الشاشات الصغيرة جداً */
    }
    
    .language-flag {
        font-size: 14px;
    }
    
    .dropdown-arrow {
        font-size: 9px;
        margin-left: 3px;
    }
    
    .language-menu {
        min-width: 120px;
        margin-top: 6px;
        padding: 8px 4px;
    }
    
    .language-link {
        padding: 8px 12px;
        font-size: 11px;
        gap: 6px;
        margin: 0 2px;
    }
    
    .language-link .language-flag {
        font-size: 14px;
    }
}

/* RTL Support - Enhanced */
[dir="rtl"] .language-toggle {
    flex-direction: row-reverse;
}

[dir="rtl"] .dropdown-arrow {
    margin-left: 0;
    margin-right: 6px;
}

[dir="rtl"] .language-link {
    flex-direction: row-reverse;
}

[dir="rtl"] .language-link:hover {
    transform: translateX(-4px) scale(1.02);
}

[dir="rtl"] .language-menu {
    left: 50%;
    right: auto;
}

[dir="rtl"] .language-menu::before {
    left: 50%;
    right: auto;
}

/* Dark Mode Support - Enhanced */
@media (prefers-color-scheme: dark) {
    .language-menu {
        background: linear-gradient(145deg, #1F2937 0%, #111827 100%);
        border-color: rgba(139, 92, 246, 0.3);
        box-shadow: 
            0 20px 40px rgba(139, 92, 246, 0.2),
            0 8px 16px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    
    .language-menu::before {
        background: linear-gradient(145deg, #1F2937 0%, #111827 100%);
        border-color: rgba(139, 92, 246, 0.3);
    }
    
    .language-link {
        color: #D1D5DB;
    }
    
    .language-link:hover {
        background: transparent;
        color: white;
        box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
    }
}

/* Enhanced Animations */
.language-change-animation {
    animation: languageChange 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes languageChange {
    0% {
        opacity: 0.8;
        transform: scale(0.9) rotate(-2deg);
        filter: blur(1px);
    }
    50% {
        opacity: 1;
        transform: scale(1.05) rotate(1deg);
        filter: blur(0px);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        filter: blur(0px);
    }
}

/* Enhanced Loading state */
.language-toggle.loading {
    opacity: 0.8;
    pointer-events: none;
    animation: loadingPulse 1.5s ease-in-out infinite;
}

.language-toggle.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 215, 0, 0.3);
    border-top: 3px solid #FFD700;
    border-radius: 50%;
    animation: enhancedSpin 1s linear infinite;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

@keyframes enhancedSpin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

@keyframes loadingPulse {
    0%, 100% { 
        box-shadow: 
            0 4px 15px rgba(139, 92, 246, 0.3),
            0 2px 8px rgba(255, 215, 0, 0.1),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
    50% { 
        box-shadow: 
            0 6px 20px rgba(139, 92, 246, 0.5),
            0 3px 12px rgba(255, 215, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
}

/* Enhanced Success feedback */
.language-toggle.success {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    animation: enhancedSuccess 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes enhancedSuccess {
    0% { 
        transform: scale(1);
        box-shadow: 
            0 4px 15px rgba(139, 92, 246, 0.3),
            0 2px 8px rgba(255, 215, 0, 0.1);
    }
    25% { 
        transform: scale(1.1) rotate(2deg);
        box-shadow: 
            0 8px 25px rgba(16, 185, 129, 0.4),
            0 4px 12px rgba(255, 215, 0, 0.3);
    }
    50% { 
        transform: scale(1.05) rotate(-1deg);
        box-shadow: 
            0 12px 30px rgba(16, 185, 129, 0.5),
            0 6px 15px rgba(255, 215, 0, 0.4);
    }
    100% { 
        transform: scale(1) rotate(0deg);
        box-shadow: 
            0 4px 15px rgba(16, 185, 129, 0.3),
            0 2px 8px rgba(255, 215, 0, 0.2);
    }
}

/* Enhanced Error state */
.language-toggle.error {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    animation: enhancedError 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes enhancedError {
    0%, 100% { 
        transform: translateX(0) scale(1);
        box-shadow: 
            0 4px 15px rgba(239, 68, 68, 0.3),
            0 2px 8px rgba(255, 215, 0, 0.1);
    }
    10%, 30%, 50%, 70%, 90% { 
        transform: translateX(-3px) scale(1.02);
        box-shadow: 
            0 6px 20px rgba(239, 68, 68, 0.4),
            0 3px 12px rgba(255, 215, 0, 0.2);
    }
    20%, 40%, 60%, 80% { 
        transform: translateX(3px) scale(1.02);
        box-shadow: 
            0 6px 20px rgba(239, 68, 68, 0.4),
            0 3px 12px rgba(255, 215, 0, 0.2);
    }
}

/* Additional hover effects */
.language-toggle:hover .language-name {
    animation: textGlow 0.3s ease-in-out;
}

@keyframes textGlow {
    0%, 100% { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
    50% { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 0 8px rgba(255, 215, 0, 0.5); }
}

/* Additional helper classes for JavaScript interactions */
.language-menu.menu-open {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(-50%) translateY(0) scale(1) !important;
}

/* Ensure dropdown works even if JavaScript fails */
.language-dropdown:hover .language-menu {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
}

.language-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg) scale(1.1);
}

/* Fix for mobile touch devices */
@media (hover: none) and (pointer: coarse) {
    .language-dropdown:hover .language-menu {
        display: none;
    }
}

/* Ensure z-index is high enough */
.language-menu {
    z-index: 99999 !important;
}