/* 语言选择器 — 官网 / 登录 / 用户中心通用 */

/* 非中文用户：首屏先隐藏，避免中文→目标语言闪烁 */
html.i18n-pending body {
    visibility: hidden !important;
}
html.i18n-ready body,
html.i18n-pending.i18n-ready body {
    visibility: visible !important;
}

.site-lang-wrap,
.wm-lang-wrap {
    display: inline-flex;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

.site-lang-dropdown {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
}

button.site-lang-trigger {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px;
    min-height: 36px;
    min-width: 0;
    width: auto !important;
    max-width: 168px;
    padding: 6px 12px 6px 10px;
    margin: 0;
    border-radius: 999px;
    border: 1px solid #dbe3ee;
    background: #fff;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    box-sizing: border-box;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    white-space: nowrap;
    transition: border-color .2s, box-shadow .2s, background .2s;
}

button.site-lang-trigger:hover,
.site-lang-dropdown.is-open button.site-lang-trigger {
    border-color: #ff9800;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, .12);
}

.site-lang-trigger-label {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-lang-trigger-chevron {
    display: block;
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    opacity: .55;
    transition: transform .2s;
}

.site-lang-dropdown.is-open .site-lang-trigger-chevron {
    transform: rotate(180deg);
}

.site-lang-flag,
.site-lang-flag-emoji,
.site-lang-flag-img-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 18px;
    flex: 0 0 24px;
    font-size: 16px;
    line-height: 1;
    border-radius: 3px;
    overflow: hidden;
    background: #f1f5f9;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .08);
}

.site-lang-flag-img {
    display: block;
    width: 24px;
    height: 18px;
    object-fit: cover;
    border-radius: 3px;
}

.site-lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    min-width: 200px;
    max-width: min(260px, calc(100vw - 24px));
    max-height: min(360px, calc(100vh - 120px));
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    padding: 6px 0;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .14), 0 2px 8px rgba(15, 23, 42, .08);
    z-index: 2000;
    scrollbar-width: thin;
}

.site-lang-menu[hidden] {
    display: none !important;
}

button.site-lang-option {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px;
    width: 100% !important;
    min-height: 44px;
    padding: 10px 14px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #334155;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    transition: background .15s;
}

button.site-lang-option:hover,
button.site-lang-option:focus-visible {
    background: #f3f4f6;
    outline: none;
}

button.site-lang-option.is-active {
    background: #fff3e0;
    color: #e65100;
    font-weight: 600;
}

.site-lang-option-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 官网深色导航 */
.site-nav-actions .site-lang-trigger,
.site-nav .site-lang-trigger {
    border-color: var(--site-border, rgba(255, 255, 255, .14));
    background: var(--site-card, rgba(255, 255, 255, .06));
    color: var(--site-text, #e2e8f0);
}

.site-nav-actions .site-lang-trigger:hover,
.site-nav-actions .site-lang-dropdown.is-open .site-lang-trigger {
    border-color: var(--site-accent, #ff9800);
    box-shadow: 0 0 0 3px rgba(255, 152, 0, .12);
}

html[data-theme="light"] .site-nav-actions .site-lang-trigger {
    background: #fff;
    color: #334155;
    border-color: #dbe3ee;
}

/* 用户中心 / 登录页 — 浅色顶栏 */
.wm-user-header-actions .site-lang-trigger,
.auth-card .site-lang-trigger,
.auth-card-top .site-lang-trigger {
    background: #fff;
    border-color: #dbe3ee;
    color: #334155;
}

.wm-user-header-actions .site-lang-dropdown.is-open .site-lang-trigger,
.wm-user-header-actions .site-lang-trigger:hover,
.auth-card .site-lang-dropdown.is-open .site-lang-trigger,
.auth-card .site-lang-trigger:hover {
    border-color: #ff8f00;
    box-shadow: 0 0 0 3px rgba(255, 143, 0, .12);
    background: #fff;
    color: #334155;
}

.site-lang-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px dashed #dbe3ee;
    color: #94a3b8;
    font-size: 12px;
    background: #fff;
}

.profile-lang-switcher {
    display: block;
    width: 100%;
    max-width: 320px;
}

.profile-lang-switcher .site-lang-dropdown {
    display: flex;
    width: 100%;
}

.profile-lang-switcher button.site-lang-trigger {
    width: 100% !important;
    max-width: none;
    border-radius: 8px;
    min-height: 40px;
    padding: 8px 12px;
}

.profile-lang-switcher .site-lang-menu {
    left: 0;
    right: auto;
    min-width: 100%;
    max-width: 320px;
}

@media (max-width: 768px) {
    .profile-lang-switcher {
        max-width: none;
    }

    .profile-lang-switcher button.site-lang-trigger {
        max-width: none !important;
        width: 100% !important;
        min-height: 40px;
        padding: 8px 12px;
    }

    .profile-lang-switcher .site-lang-menu {
        max-width: none;
    }

    button.site-lang-trigger {
        min-height: 34px;
        padding: 5px 10px 5px 8px;
        gap: 6px;
        max-width: 132px;
    }

    .site-lang-trigger-label {
        max-width: 72px;
        font-size: 12px;
    }

    .site-lang-flag,
    .site-lang-flag-emoji,
    .site-lang-flag-img-wrap {
        width: 22px;
        height: 16px;
        flex-basis: 22px;
    }

    .site-lang-flag-img {
        width: 22px;
        height: 16px;
    }

    .site-lang-menu {
        min-width: 180px;
    }
}

/* 用户中心顶栏 — 单个下拉语言选择器（国旗圆标 + 文案，与客服/消息/退出同列对齐） */
.wm-uc-topbar-actions .wm-uc-lang-stack {
    display: none !important;
}

.wm-uc-topbar-actions .wm-uc-lang-host {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    min-width: 42px;
    max-width: 72px;
    position: relative;
    overflow: visible;
    z-index: 50;
}

.wm-uc-topbar-actions .wm-uc-lang-host .site-lang-dropdown {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: visible;
}

.wm-uc-topbar-actions .wm-uc-lang-host button.site-lang-trigger {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    min-width: 42px;
    max-width: 72px;
    width: auto !important;
    min-height: 0;
    height: auto;
    padding: 0 !important;
    margin: 0;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #64748b;
    font-weight: 500;
}

.wm-uc-topbar-actions .wm-uc-lang-host button.site-lang-trigger:hover,
.wm-uc-topbar-actions .wm-uc-lang-host .site-lang-dropdown.is-open button.site-lang-trigger {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    color: #2563eb;
}

.wm-uc-topbar-actions .wm-uc-lang-host .site-lang-trigger-chevron {
    display: none !important;
}

.wm-uc-topbar-actions .wm-uc-lang-host .site-lang-trigger-label {
    font-size: 11px;
    font-weight: 500;
    color: inherit;
    max-width: 72px;
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wm-uc-topbar-actions .wm-uc-lang-host .site-lang-flag,
.wm-uc-topbar-actions .wm-uc-lang-host .site-lang-flag-emoji,
.wm-uc-topbar-actions .wm-uc-lang-host .site-lang-flag-img-wrap {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 50%;
    background: #e4eefe;
    box-shadow: none;
    overflow: hidden;
    font-size: 14px;
}

.wm-uc-topbar-actions .wm-uc-lang-host .site-lang-flag-img {
    width: 22px;
    height: 16px;
    border-radius: 2px;
}

.wm-uc-topbar-actions .wm-uc-lang-host .site-lang-loading {
    min-width: 42px;
    max-width: 72px;
    height: auto;
    min-height: 32px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    font-size: 10px;
}

.wm-uc-topbar-actions .wm-uc-lang-host .site-lang-menu,
.site-lang-menu.site-lang-menu--uc-fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    bottom: auto;
    margin: 0;
    min-width: 200px;
    max-width: min(280px, calc(100vw - 24px));
    max-height: min(420px, calc(100vh - 96px));
    z-index: 10060;
    transform: none;
}
