/* Enhanced Language Selector CSS */
/* File: assets/css/language-selector.css */

/* Language Selector Component */
.language-selector {
    position: relative;
    z-index: 1000;
    user-select: none;
}

.language-current {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-white);
    font-size: 14px;
    font-weight: 500;
    user-select: none;
    min-width: 80px;
    position: relative;
    overflow: hidden;
}

.language-current:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.language-current:focus {
    outline: 2px solid var(--accent-orange);
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.15);
}

.language-current:active {
    transform: translateY(0);
}

/* Loading State */
.language-selector.loading .language-current {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.language-selector.loading .language-current::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 8px;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid var(--accent-orange);
    border-radius: 50%;
    animation: languageLoading 1s linear infinite;
    transform: translateY(-50%);
}

@keyframes languageLoading {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Flag Image */
.flag-image {
    width: 16px;
    height: 12px;
    border-radius: 2px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.flag-fallback {
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
}

/* Language Code */
.lang-code {
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.lang-name {
    font-size: 13px;
    opacity: 0.9;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* Dropdown Arrow */
.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.2s ease;
    opacity: 0.7;
    margin-left: auto;
    flex-shrink: 0;
}

.language-selector.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Container */
.language-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(15, 15, 25, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 200px;
    max-width: 280px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 1001;
    padding: 8px;
}

.language-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Custom Scrollbar for Dropdown */
.language-dropdown::-webkit-scrollbar {
    width: 6px;
}

.language-dropdown::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.language-dropdown::-webkit-scrollbar-thumb {
    background: var(--accent-orange);
    border-radius: 3px;
}

.language-dropdown::-webkit-scrollbar-thumb:hover {
    background: #e55a2b;
}

/* Language Options */
.language-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-white);
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin-bottom: 4px;
    position: relative;
    cursor: pointer;
    border: 1px solid transparent;
}

.language-option:last-child {
    margin-bottom: 0;
}

.language-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
    transform: translateX(2px);
    border-color: rgba(255, 255, 255, 0.1);
}

.language-option:focus {
    background: rgba(255, 255, 255, 0.1);
    outline: 2px solid var(--accent-orange);
    outline-offset: 2px;
    border-color: var(--accent-orange);
}

.language-option.active {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.2), rgba(255, 107, 53, 0.1));
    border: 1px solid rgba(255, 107, 53, 0.3);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.2);
}

.language-option.active:hover {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.3), rgba(255, 107, 53, 0.15));
}

/* Language Info Container */
.lang-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0; /* Allow text truncation */
}

.lang-native {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    color: var(--text-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lang-english {
    font-size: 12px;
    opacity: 0.7;
    line-height: 1.2;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.language-option.active .lang-english {
    color: rgba(255, 107, 53, 0.8);
}

/* Current Indicator */
.current-indicator {
    color: var(--accent-orange);
    font-size: 12px;
    flex-shrink: 0;
    animation: currentPulse 2s ease-in-out infinite;
}

@keyframes currentPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .hidden-mobile {
        display: none;
    }

    .language-current {
        min-width: 60px;
        padding: 6px 10px;
        font-size: 13px;
    }

    .language-dropdown {
        right: 0;
        left: auto;
        min-width: 180px;
        max-width: calc(100vw - 20px);
    }

    .lang-info {
        gap: 1px;
    }

    .lang-native {
        font-size: 13px;
    }

    .lang-english {
        font-size: 11px;
    }

    .language-option {
        padding: 10px 14px;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .language-current {
        padding: 5px 8px;
        min-width: 50px;
    }

    .lang-code {
        font-size: 12px;
    }

    .language-dropdown {
        min-width: 160px;
        padding: 6px;
    }

    .language-option {
        padding: 8px 12px;
    }

    .flag-image {
        width: 14px;
        height: 10px;
    }
}

/* RTL Support */
[dir="rtl"] .language-dropdown {
    right: auto;
    left: 0;
}

[dir="rtl"] .language-current {
    flex-direction: row-reverse;
}

[dir="rtl"] .language-option {
    flex-direction: row-reverse;
}

[dir="rtl"] .language-option:hover {
    transform: translateX(-2px);
}

[dir="rtl"] .dropdown-arrow {
    margin-left: 0;
    margin-right: auto;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .language-current {
        border-width: 2px;
        background: rgba(255, 255, 255, 0.2);
    }

    .language-dropdown {
        border-width: 2px;
        background: rgba(15, 15, 25, 1);
    }

    .language-option {
        border: 1px solid transparent;
    }

    .language-option:hover,
    .language-option:focus {
        border-color: var(--accent-orange);
        background: rgba(255, 107, 53, 0.2);
    }

    .language-option.active {
        border: 2px solid var(--accent-orange);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .language-dropdown,
    .dropdown-arrow,
    .language-option,
    .language-current {
        transition: none;
    }

    .current-indicator {
        animation: none;
    }

    @keyframes languageLoading {
        0%, 100% { transform: translateY(-50%) rotate(0deg); }
    }
}

/* Dark Mode Enhancement */
@media (prefers-color-scheme: dark) {
    .language-dropdown {
        background: rgba(10, 10, 15, 0.98);
        border-color: rgba(255, 255, 255, 0.15);
    }
}

/* Print Styles */
@media print {
    .language-selector {
        display: none;
    }
}

/* Focus Visible for Better Accessibility */
.language-current:focus-visible,
.language-option:focus-visible {
    outline: 2px solid var(--accent-orange);
    outline-offset: 2px;
}

/* Keyboard Navigation Enhancements */
.language-dropdown[role="listbox"] {
    scroll-behavior: smooth;
}

.language-option[aria-selected="true"] {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.2), rgba(255, 107, 53, 0.1));
    border-color: rgba(255, 107, 53, 0.3);
}

/* Loading Animation for Language Switch */
.language-switch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.language-switch-overlay.active {
    opacity: 1;
    visibility: visible;
}

.language-switch-content {
    background: rgba(15, 15, 25, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.language-switch-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid var(--accent-orange);
    border-radius: 50%;
    animation: languageSwitchSpin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes languageSwitchSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.language-switch-text {
    color: var(--text-white);
    font-size: 14px;
    font-weight: 500;
}

/* Enhanced Hover Effects */
.language-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 107, 53, 0.1), transparent);
    transition: width 0.3s ease;
    border-radius: 8px;
}

.language-option:hover::before {
    width: 100%;
}

/* Smooth Transitions for All States */
* {
    transition-property: background-color, border-color, color, box-shadow, transform, opacity;
    transition-duration: 0.2s;
    transition-timing-function: ease-out;
}

/* Error States */
.language-selector.error .language-current {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    animation: languageError 0.5s ease-in-out;
}

@keyframes languageError {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* Success States */
.language-selector.success .language-current {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

/* Dropdown Enter/Exit Animations */
.language-dropdown-enter {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
}

.language-dropdown-enter-active {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.language-dropdown-exit {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.language-dropdown-exit-active {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.6, 1);
}

/* Notification Integration */
.language-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, rgba(15, 15, 25, 0.95), rgba(30, 30, 45, 0.95));
    border: 1px solid rgba(255, 107, 53, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-white);
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.language-notification.show {
    transform: translateX(0);
}

.language-notification.success {
    border-color: rgba(16, 185, 129, 0.3);
}

.language-notification.error {
    border-color: rgba(239, 68, 68, 0.3);
}

/* Additional Language-Specific Styles */
[lang="ar"] .language-current,
[lang="he"] .language-current {
    direction: rtl;
    text-align: right;
}

[lang="zh"] .lang-native,
[lang="ja"] .lang-native,
[lang="ko"] .lang-native {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

/* Performance Optimizations */
.language-selector {
    contain: layout style paint;
}

.language-dropdown {
    contain: layout style paint;
    will-change: opacity, transform;
}

.language-option {
    contain: layout paint;
    will-change: background-color, transform;
}

/* Final Polish */
.language-selector:hover .language-current {
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.15);
}

.language-dropdown.active {
    animation: dropdownFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}