/* 🌐 全局悬浮语言切换器样式 */

/* 容器 - 固定在右侧中央 */
.language-switcher-container {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 99999;
    transition: right 0.3s ease-in-out;
}

/* 使用伪元素扩展hover区域到切换按钮区域，防止闪动 */
.language-switcher-container::before {
    content: '';
    position: absolute;
    left: -35px;  /* 覆盖切换按钮区域 */
    top: 0;
    width: 35px;
    height: 100%;
    background: transparent;
    pointer-events: auto;
}

/* 隐藏状态 - 只露出切换按钮 */
.language-switcher-container.hidden {
    right: -56px;  /* 主按钮宽度，让主按钮完全隐藏，但切换按钮可见 */
}

/* 主按钮 - 圆形地球图标 */
.language-switcher-main-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    cursor: grab;  /* 拖动光标 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    position: relative;
    user-select: none;  /* 防止拖动时选中文本 */
}

.language-switcher-main-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.language-switcher-main-btn:active {
    transform: scale(0.95);
}

/* 拖动状态 */
.language-switcher-container.dragging {
    transition: none !important;
}

.language-switcher-container.dragging .language-switcher-main-btn {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6);
    cursor: grabbing;
}

.language-switcher-container.dragging .language-switcher-panel {
    opacity: 0 !important;
    pointer-events: none !important;
}

.language-switcher-container.dragging .language-switcher-toggle-visibility {
    opacity: 0 !important;
}

/* 当前语言指示器 */
.language-switcher-main-btn .current-lang-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: white;
    color: #667eea;
    font-size: 10px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #667eea;
    text-transform: uppercase;
}

/* 语言面板 */
.language-switcher-panel {
    position: absolute;
    right: 70px;
    top: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 12px;
    min-width: 220px;
    max-height: 500px;
    overflow-y: auto;
    opacity: 0;
    transform: translateX(20px) scale(0.9);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.language-switcher-panel.show {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

/* 自定义滚动条 */
.language-switcher-panel::-webkit-scrollbar {
    width: 6px;
}

.language-switcher-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.language-switcher-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.language-switcher-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* 面板标题 */
.language-switcher-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
}

.language-switcher-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.language-switcher-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.language-switcher-close:hover {
    background: #f5f5f5;
    color: #333;
}

/* 语言列表 */
.language-switcher-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.language-switcher-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #555;
    position: relative;
}

.language-switcher-item:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: #667eea;
    transform: translateX(-3px);
}

.language-switcher-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

.language-switcher-item.active::after {
    content: '✓';
    position: absolute;
    right: 12px;
    font-size: 16px;
}

/* 语言旗帜图标 */
.language-switcher-flag {
    font-size: 20px;
    width: 28px;
    text-align: center;
}

/* 语言名称 */
.language-switcher-name {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.language-switcher-name-main {
    font-weight: 500;
}

.language-switcher-name-native {
    font-size: 11px;
    opacity: 0.7;
}

/* 隐藏/显示切换按钮 */
.language-switcher-toggle-visibility {
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 60px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    color: white;
    border: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
    opacity: 0;  /* 默认隐藏 */
}

/* 使用伪元素填充按钮和容器之间的间隙，防止hover闪动 */
.language-switcher-toggle-visibility::after {
    content: '';
    position: absolute;
    right: -5px;  /* 延伸到主按钮边缘 */
    top: 0;
    width: 5px;
    height: 100%;
    background: transparent;
}

/* 正常状态：hover时显示隐藏按钮 */
.language-switcher-container:hover .language-switcher-toggle-visibility,
.language-switcher-toggle-visibility:hover {
    opacity: 1;
}

/* 正常状态下的hover效果 */
.language-switcher-container:not(.hidden) .language-switcher-toggle-visibility:hover {
    background: linear-gradient(135deg, rgba(118, 75, 162, 0.95) 0%, rgba(102, 126, 234, 0.95) 100%);
    left: -35px;  /* hover时稍微伸出一点 */
}

/* 隐藏状态：一直显示展开按钮 */
.language-switcher-container.hidden .language-switcher-toggle-visibility {
    opacity: 1;
    left: -30px;  /* 切换按钮宽度，保持露出在屏幕边缘 */
    border-radius: 8px 0 0 8px;
}

/* 隐藏状态下的hover效果 */
.language-switcher-container.hidden .language-switcher-toggle-visibility:hover {
    background: linear-gradient(135deg, rgba(118, 75, 162, 0.95) 0%, rgba(102, 126, 234, 0.95) 100%);
    left: -35px;  /* hover时稍微伸出一点 */
}

/* 加载状态 */
.language-switcher-loading {
    display: none;
    text-align: center;
    padding: 20px;
    color: #999;
}

.language-switcher-loading.show {
    display: block;
}

/* 响应式设计 - 移动端适配 */
@media (max-width: 768px) {
    /* 主按钮尺寸调整 */
    .language-switcher-main-btn {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    /* 面板位置调整 */
    .language-switcher-panel {
        right: 60px;
        min-width: 200px;
        max-height: 400px;
    }

    /* 切换按钮尺寸调整 */
    .language-switcher-toggle-visibility {
        width: 24px;
        height: 50px;
        left: -24px;
    }

    /* 移动端：正常状态下一直显示切换按钮（因为没有hover） */
    .language-switcher-container:not(.hidden) .language-switcher-toggle-visibility {
        opacity: 0.5;  /* 半透明显示，不挡住内容 */
    }

    /* 移动端：正常状态下点击区域足够大 */
    .language-switcher-container:not(.hidden) .language-switcher-toggle-visibility:active {
        opacity: 1;
        background: linear-gradient(135deg, rgba(118, 75, 162, 0.95) 0%, rgba(102, 126, 234, 0.95) 100%);
    }

    /* 隐藏状态调整 */
    .language-switcher-container.hidden {
        right: -48px;  /* 响应式：主按钮在移动端宽度为48px */
    }

    /* 移动端：隐藏状态下切换按钮位置调整 */
    .language-switcher-container.hidden .language-switcher-toggle-visibility {
        opacity: 1;
        left: -24px;  /* 移动端切换按钮宽度24px，保持露出 */
    }

    /* 移动端：隐藏状态下的active效果（替代hover） */
    .language-switcher-container.hidden .language-switcher-toggle-visibility:active {
        background: linear-gradient(135deg, rgba(118, 75, 162, 0.95) 0%, rgba(102, 126, 234, 0.95) 100%);
        left: -28px;  /* active时稍微伸出一点 */
    }
}

/* 深色模式支持（可选） */
@media (prefers-color-scheme: dark) {
    .language-switcher-panel {
        background: #2d2d2d;
        color: #e0e0e0;
    }

    .language-switcher-title {
        color: #e0e0e0;
    }

    .language-switcher-item {
        color: #b0b0b0;
    }

    .language-switcher-item:hover {
        background: rgba(102, 126, 234, 0.2);
        color: #a0a5ea;
    }

    .language-switcher-close:hover {
        background: #3a3a3a;
        color: #e0e0e0;
    }

    .language-switcher-panel::-webkit-scrollbar-track {
        background: #3a3a3a;
    }
}

/* 动画关键帧 */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.language-switcher-main-btn.pulse {
    animation: pulse 0.5s ease-in-out;
}

