/**
 * 翻译系统UI样式
 * 语言切换器、翻译内容样式和响应式设计
 */

/* 语言切换器容器 */
.language-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.language-switcher:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* 语言切换按钮 */
.lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    min-width: 60px;
    justify-content: center;
}

.lang-btn:hover {
    background: rgba(0, 123, 255, 0.1);
    color: #007bff;
    transform: translateY(-1px);
}

.lang-btn.active {
    background: #007bff;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.lang-btn.active:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

/* 国旗图标 */
.lang-btn .flag-icon {
    width: 18px;
    height: 13px;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 语言文本 */
.lang-btn .lang-text {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .language-switcher {
        top: 15px;
        right: 15px;
        padding: 3px;
    }
    
    .lang-btn {
        padding: 6px 8px;
        font-size: 12px;
        min-width: 50px;
    }
    
    .lang-btn .flag-icon {
        width: 16px;
        height: 11px;
    }
    
    .lang-btn .lang-text {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .language-switcher {
        top: 10px;
        right: 10px;
    }
    
    .lang-btn {
        padding: 5px 6px;
        gap: 4px;
    }
    
    .lang-btn .lang-text {
        display: none; /* 小屏幕只显示图标 */
    }
}

/* 翻译内容样式 */
.translatable {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.translatable.translating {
    opacity: 0.7;
    transform: scale(0.98);
}

/* 语言特定显示控制 */
body[data-lang="en"] .cn-only {
    display: none !important;
}

body[data-lang="cn"] .en-only {
    display: none !important;
}

/* 翻译提示样式 */
.translation-tooltip {
    position: relative;
    cursor: help;
}

.translation-tooltip::after {
    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: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.translation-tooltip:hover::after {
    opacity: 1;
}

/* 翻译加载状态 */
.translation-loading {
    position: relative;
    overflow: hidden;
}

.translation-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: translateLoading 1.5s infinite;
}

@keyframes translateLoading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* 语言切换动画 */
.language-switch-animation {
    animation: languageSwitch 0.5s ease-in-out;
}

@keyframes languageSwitch {
    0% { opacity: 1; transform: translateY(0); }
    50% { opacity: 0.5; transform: translateY(-5px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .language-switcher {
        background: white;
        border: 2px solid #000;
    }
    
    .lang-btn {
        border: 1px solid #666;
    }
    
    .lang-btn.active {
        background: #000;
        color: white;
        border-color: #000;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .language-switcher,
    .lang-btn,
    .translatable,
    .translation-tooltip::after {
        transition: none;
    }
    
    .translation-loading::before {
        animation: none;
    }
    
    .language-switch-animation {
        animation: none;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .language-switcher {
        background: rgba(30, 30, 30, 0.95);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    .lang-btn {
        color: #ccc;
    }
    
    .lang-btn:hover {
        background: rgba(0, 123, 255, 0.2);
        color: #4dabf7;
    }
    
    .lang-btn.active {
        background: #0056b3;
        color: white;
    }
}

/* 打印样式 */
@media print {
    .language-switcher {
        display: none;
    }
    
    .cn-only,
    .en-only {
        display: block !important;
    }
}

/* 辅助功能增强 */
.lang-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.lang-btn:focus:not(:focus-visible) {
    outline: none;
}

/* 语言切换器位置变体 */
.language-switcher.top-left {
    top: 20px;
    left: 20px;
    right: auto;
}

.language-switcher.bottom-right {
    top: auto;
    bottom: 20px;
    right: 20px;
}

.language-switcher.bottom-left {
    top: auto;
    bottom: 20px;
    left: 20px;
    right: auto;
}

/* 内联语言切换器 */
.language-switcher.inline {
    position: static;
    display: inline-flex;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.language-switcher.inline .lang-btn {
    border: 1px solid #ddd;
    background: white;
}

.language-switcher.inline .lang-btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.language-switcher.inline .lang-btn:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* 翻译状态指示器 */
.translation-status {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 9998;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.translation-status.show {
    opacity: 1;
    transform: translateY(0);
}

.translation-status.success {
    background: rgba(40, 167, 69, 0.9);
}

.translation-status.error {
    background: rgba(220, 53, 69, 0.9);
}

/* 翻译进度条 */
.translation-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(0, 123, 255, 0.2);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.translation-progress.show {
    opacity: 1;
}

.translation-progress::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #007bff;
    width: 0;
    transition: width 0.3s ease;
}

.translation-progress.complete::before {
    width: 100%;
}