/**
 * 前台语言切换按钮样式
 */

/* 隐藏 translate.js 内置语言选择器，防止页面加载时闪现蓝色文字 */
#translate,
.translateSelectLanguage,
[id$="SelectLanguage"] {
    display: none !important;
}

.lang-switch-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-right: 12px;
}

.lang-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
    color: #fff;
    opacity: 0.9;
    user-select: none;
}

.lang-switch-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* top-bar 区域（登录/注册按钮所在区域） */
.top-bar .lang-switch-btn {
    color: #fff;
    opacity: 0.9;
}

.top-bar .lang-switch-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* 滚动后的导航栏 */
.main-header.scrolled .lang-switch-btn {
    color: #000;
    opacity: 0.9;
}

.main-header.scrolled .lang-switch-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

.lang-switch-icon {
    display: inline-flex;
    align-items: center;
    opacity: 0.7;
}

.lang-switch-text {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

/* 上传的自定义图标：自动跟随导航文字颜色（白色/深色） */
.lang-switch-custom-icon {
    filter: brightness(0) invert(1);
    transition: filter 0.2s ease;
}

/* 滚动后：导航文字变深色 → 图标同步变深色 */
.main-header.scrolled .lang-switch-custom-icon {
    filter: brightness(0) invert(0);
}

.lang-code-item {
    padding: 1px 4px;
    border-radius: 2px;
    transition: all 0.2s;
    cursor: pointer;
}

.lang-switch-arrow {
    display: inline-flex;
    align-items: center;
    opacity: 0.5;
    transition: transform 0.2s;
}

.lang-switch-wrapper .lang-switch-btn:hover .lang-switch-arrow {
    opacity: 0.8;
}

.lang-switch-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 140px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 6px 0;
    display: none;
    z-index: 9999;
}

.lang-switch-dropdown.show {
    display: block;
}

.lang-switch-dropdown .lang-option {
    display: block;
    padding: 8px 16px;
    color: #333;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s;
    white-space: nowrap;
}

.lang-switch-dropdown .lang-option:hover {
    background: #f5f5f5;
}

.lang-switch-dropdown .lang-option.active {
    background: #f0f7ff;
    font-weight: 500;
}

/* 深色导航适配 */
.main-header .lang-switch-dropdown .lang-option {
    color: #333;
}

/* 移动端容器默认隐藏，仅移动端显示 */
.mobile-header-actions {
    display: none;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .header-user-actions .lang-switch-wrapper {
        display: none !important;
    }
    .mobile-header-actions {
        display: flex;
        align-items: center;
        margin-left: auto;
        margin-right: 8px;
        flex-shrink: 0;
    }
    /* 移动端：汉堡按钮紧贴语言按钮，不再单独 auto */
    .main-header .mobile-menu-btn {
        margin-left: 0;
    }
    .mobile-header-actions .lang-switch-wrapper {
        display: inline-flex !important;
        margin-right: 0;
    }
    .mobile-header-actions .lang-switch-btn {
        padding: 0 6px;
        font-size: 13px;
    }
    .mobile-header-actions .lang-switch-dropdown {
        right: auto;
        left: 50%;
        transform: translateX(-50%) translateY(10px);
    }
    .mobile-header-actions .lang-switch-dropdown.show {
        transform: translateX(-50%) translateY(0);
    }
    .lang-switch-wrapper {
        margin-right: 8px;
    }
    .lang-switch-btn {
        padding: 4px 6px;
    }
}

/* ============================================================
   国旗面板模式样式（flag_panel）- 全屏遮罩 + 网格布局
   ============================================================ */

/* 遮罩层 */
.flag-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 99999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    overflow-y: auto;
}
.flag-panel-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 关闭按钮 */
.flag-panel-close {
    position: fixed;
    top: 16px;
    right: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,1);
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 100000;
}
.flag-panel-close:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

/* 内容容器（无面板背景，直接浮在遮罩上） */
.flag-panel-content {
    width: 90vw;
    max-width: 800px;
    padding: 20px 0 40px;
    animation: flagPanelIn 0.25s ease-out;
}
@keyframes flagPanelIn {
    from { opacity: 0; transform: translateY(15px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 置顶行（zh-cn） */
.flag-top-row {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

/* 分隔线 */
.flag-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.15), transparent);
    margin: 0 0 24px;
}

/* 分组 */
.flag-group {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
.flag-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* 分组标题 */
.flag-group-title {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    padding-left: 4px;
}

/* 网格布局（多列） */
.flag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px 16px;
}

/* 语言项（国旗emoji + 名称，无背景） */
.flag-lang-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s ease;
    white-space: nowrap;
    cursor: pointer;
}
.flag-lang-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}
.flag-lang-item.active {
    color: #fff;
    background: rgba(255,255,255,0.12);
    font-weight: 500;
}

/* 国旗图标（图片） */
.flag-icon {
    width: 24px;
    height: 16px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
}

/* 语言名称 */
.flag-name {
    line-height: 1.3;
}

/* 移动端适配 */
@media (max-width: 600px) {
    .flag-panel-overlay {
        padding-top: 70px;
    }
    .flag-panel-content {
        width: 95vw;
        padding: 16px 0 30px;
    }
    .flag-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 6px 10px;
    }
    .flag-lang-item {
        padding: 6px 8px;
        font-size: 12px;
        gap: 6px;
    }
    .flag-icon {
        width: 20px;
        height: 14px;
    }
    .flag-group-title {
        font-size: 12px;
        margin-bottom: 10px;
    }
    .flag-group {
        margin-bottom: 20px;
    }
    .flag-panel-close {
        top: 18px;
        right: 13px;
    }
}
