/* Seeyoo Magic Internationalization Styles */

/* Fast and smooth loading without flashing */
body:not(.i18n-loaded) {
    visibility: hidden;
}

body.i18n-loaded {
    visibility: visible;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Smooth transition for translatable content */
[data-i18n] {
    transition: opacity 0.15s ease;
}

/* Show content after translation */
[data-i18n].i18n-translated {
    opacity: 1;
}

/* Fallback: show content after i18n is ready */
html.i18n-ready [data-i18n] {
    opacity: 1;
}

/* Ensure language selector is always visible and functional */
.language-selector, .language-dropdown, .language-btn {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.language-selector {
    position: relative;
    display: inline-block;
    margin-left: 10px;
    z-index: 100;
    background: transparent !important;
}

.language-dropdown {
    position: relative;
    background: transparent !important;
}

.language-btn {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 12px !important;
    background: rgba(255, 255, 255, 0.3) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 20px !important;
    color: #2d3748 !important;
    cursor: pointer !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    backdrop-filter: blur(10px) !important;
    min-width: 80px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

.language-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-color: #667eea !important;
    color: white !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

/* Флаги стран через CSS */
.flag-circle {
    display: inline-block;
    width: 22px;
    height: 16px;
    min-width: 22px;
    min-height: 16px;
    border-radius: 3px;
    box-shadow: none !important;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    vertical-align: middle;
    border: none !important;
}

/* Флаг России - три горизонтальные полосы */
.flag-ru {
    background: 
        linear-gradient(to bottom, 
            #FFFFFF 0%, #FFFFFF 33.33%, 
            #0039A6 33.33%, #0039A6 66.67%, 
            #D52B1E 66.67%, #D52B1E 100%
        );
}

/* Флаг США - упрощенная версия */
.flag-us {
    background: repeating-linear-gradient(
        to bottom,
        #B22234 0,
        #B22234 7.69%,
        #FFFFFF 7.69%,
        #FFFFFF 15.38%
    );
}

.flag-us::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 54%;
    background: #3C3B6E;
    z-index: 1;
}

/* Флаг Германии - три горизонтальные полосы */
.flag-de {
    background: linear-gradient(to bottom,
        #000000 0%, #000000 33.33%,
        #DD0000 33.33%, #DD0000 66.67%,
        #FFCE00 66.67%, #FFCE00 100%
    );
}

/* Флаг Франции - три вертикальные полосы */
.flag-fr {
    background: linear-gradient(to right,
        #002395 0%, #002395 33.33%,
        #FFFFFF 33.33%, #FFFFFF 66.67%,
        #ED2939 66.67%, #ED2939 100%
    );
}

.language-btn:hover .flag-circle {
    transform: scale(1.2);
    box-shadow: none !important;
}

.language-btn .lang-code {
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.language-btn .arrow {
    font-size: 0.65em;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 2px;
    opacity: 0.7;
}

.language-dropdown.show .language-btn .arrow {
    transform: rotate(180deg);
}

.language-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
    border: 1.5px solid rgba(102, 126, 234, 0.15);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1), 0 3px 10px rgba(102, 126, 234, 0.06);
    backdrop-filter: blur(24px);
    min-width: 150px;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-12px) scale(0.92);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

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

.language-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
}

.language-option::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.language-option:hover::before {
    transform: scaleY(1);
}

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

.language-option:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.05) 100%);
    color: #667eea;
    padding-left: 18px;
}

.language-option.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

.language-option.active::before {
    display: none;
}

.language-option.active:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    padding-left: 14px;
}

.language-option .flag-circle {
    width: 26px;
    height: 19px;
}

.language-option:hover .flag-circle {
    transform: scale(1.1);
    box-shadow: none !important;
}

.language-option.active .flag-circle {
    box-shadow: none !important;
    transform: scale(1.05);
}

.language-option .name {
    font-weight: 500;
    flex: 1;
    letter-spacing: 0.3px;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .language-btn {
        color: #fff;
        background: rgba(0, 0, 0, 0.3);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .language-btn:hover {
        background: rgba(0, 0, 0, 0.4);
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    .language-menu {
        background: rgba(30, 30, 30, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
        color: #fff;
    }
    
    .language-option {
        border-color: rgba(255, 255, 255, 0.05);
    }
    
    .language-option:hover {
        background: rgba(102, 126, 234, 0.2);
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .language-selector {
        margin-left: 10px;
    }
    
    .language-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
        min-width: 70px;
    }
    
    .language-btn .lang-code {
        display: none; /* Hide text on mobile, show only flag */
    }
    
    .language-menu {
        right: -10px;
        min-width: 140px;
    }
    
    .language-option {
        padding: 10px 14px;
    }
}

/* Header integration */
.header .language-selector {
    display: flex;
    align-items: center;
}

.header .language-btn {
    color: inherit;
}

/* Animation for language change */
.i18n-fade-out {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.i18n-fade-in {
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* Loading state */
.language-selector.loading .language-btn {
    opacity: 0.6;
    cursor: not-allowed;
}

.language-selector.loading .language-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 8px;
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translateY(-50%);
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Tooltip for language names */
.language-btn[title] {
    position: relative;
}

.language-btn[title]:hover::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1001;
    margin-bottom: 5px;
}

.language-btn[title]:hover::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
    margin-bottom: 1px;
}
