/* ===== 语言选择器样式 - 全设备响应式 ===== */
.lang-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    vertical-align: middle;
}
.lang-switcher-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid rgba(11,27,51,0.12);
    border-radius: 8px;
    background: rgba(255,255,255,0.6);
    color: var(--text-secondary, #55657a);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.4;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.lang-switcher-btn:hover {
    border-color: var(--gold, #e8832b);
    color: var(--gold, #e8832b);
    background: rgba(232,131,43,0.06);
}
.lang-switcher-btn:active {
    transform: scale(0.97);
}
.lang-switcher-btn .globe-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}
.lang-switcher-btn .arrow {
    font-size: 0.6rem;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.lang-switcher.open .lang-switcher-btn .arrow {
    transform: rotate(180deg);
}

/* 下拉菜单 */
.lang-switcher-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    max-height: 360px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(11,27,51,0.1);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(9,26,49,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    padding: 6px 0;
}
.lang-switcher.open .lang-switcher-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.lang-switcher-dropdown::-webkit-scrollbar {
    width: 4px;
}
.lang-switcher-dropdown::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 2px;
}

/* 语言选项 */
.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary, #0b1b33);
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}
.lang-option:hover {
    background: rgba(232,131,43,0.06);
    color: var(--gold, #e8832b);
}
.lang-option:active {
    background: rgba(232,131,43,0.12);
}
.lang-option.active {
    background: rgba(232,131,43,0.1);
    color: var(--gold, #e8832b);
    font-weight: 600;
}
.lang-option .lang-code {
    font-size: 0.7rem;
    color: var(--text-secondary, #55657a);
    margin-left: auto;
    opacity: 0.6;
}
.lang-option.active .lang-code {
    opacity: 1;
}

/* ===== 平板适配 (768px - 1024px) ===== */
@media (max-width: 1024px) {
    .lang-switcher-btn {
        padding: 7px 12px;
        font-size: 0.82rem;
        gap: 5px;
    }
    .lang-switcher-dropdown {
        min-width: 200px;
        max-height: 320px;
    }
    .lang-option {
        padding: 9px 14px;
        font-size: 0.82rem;
    }
}

/* ===== 手机横屏 / 小平板 (480px - 768px) ===== */
@media (max-width: 768px) {
    .lang-switcher {
        margin-left: 4px;
    }
    .lang-switcher-btn {
        padding: 7px 10px;
        font-size: 0.8rem;
        gap: 4px;
        border-radius: 6px;
        min-height: 36px;
    }
    .lang-switcher-btn .globe-icon {
        font-size: 1rem;
    }
    .lang-switcher-dropdown {
        min-width: 180px;
        max-height: 300px;
        border-radius: 8px;
    }
    .lang-option {
        padding: 9px 12px;
        font-size: 0.8rem;
        min-height: 40px;
    }
}

/* ===== 手机竖屏 (320px - 480px) ===== */
@media (max-width: 480px) {
    .lang-switcher {
        margin-left: 0;
    }
    .lang-switcher-btn {
        padding: 6px 10px;
        font-size: 0.78rem;
        gap: 4px;
        border-radius: 6px;
        min-height: 34px;
    }
    .lang-switcher-btn .globe-icon {
        font-size: 0.95rem;
    }
    .lang-switcher-btn .current-lang {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .lang-switcher-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        min-width: unset;
        max-height: 50vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 40px rgba(9,26,49,0.2);
        transform: translateY(100%);
        padding: 8px 0 20px;
        z-index: 10000;
    }
    .lang-switcher.open .lang-switcher-dropdown {
        transform: translateY(0);
    }
    /* 移动端底部弹出时添加遮罩 */
    .lang-switcher.open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.3);
        z-index: 9999;
        animation: fadeIn 0.2s ease;
    }
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    /* 下拉菜单顶部拖动条 */
    .lang-switcher-dropdown::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: rgba(0,0,0,0.2);
        border-radius: 2px;
        margin: 0 auto 8px;
    }
    .lang-option {
        padding: 11px 20px;
        font-size: 0.9rem;
        min-height: 46px;
        border-radius: 0;
    }
}

/* ===== 小屏手机 (320px - 375px) ===== */
@media (max-width: 375px) {
    .lang-switcher-btn {
        padding: 5px 8px;
        font-size: 0.75rem;
        gap: 3px;
        min-height: 32px;
    }
    .lang-switcher-btn .globe-icon {
        font-size: 0.9rem;
    }
    .lang-switcher-btn .current-lang {
        max-width: 60px;
    }
    .lang-option {
        padding: 10px 16px;
        font-size: 0.85rem;
        min-height: 44px;
    }
}

/* ===== 导航栏内嵌适配 ===== */
/* 在 ul.nav-links 中作为 li 子元素 */
nav .nav-links > li > .lang-switcher,
ul.nav-links > li > .lang-switcher {
    margin-left: 0;
}

/* 在 nav.nav-links 中直接放置 */
nav.nav-links > .lang-switcher {
    margin-left: 8px;
}

/* /kepu/ 页面 div.nav 内适配 */
.nav > .lang-switcher {
    margin-left: auto;
}
.nav > nav[aria-label] > .lang-switcher {
    margin-left: 8px;
}

/* 移动端导航展开时语言选择器适配 */
@media (max-width: 768px) {
    /* 移动端菜单中的语言选择器占满宽度 */
    .nav-links.open .lang-switcher,
    .nav-links.open > li > .lang-switcher {
        width: 100%;
        margin: 4px 0;
    }
    .nav-links.open .lang-switcher-btn {
        width: 100%;
        justify-content: center;
    }
    /* /kepu/ 页面移动端适配 */
    .nav > .lang-switcher {
        margin-left: 0;
        margin-top: 8px;
        width: 100%;
    }
    .nav > .lang-switcher .lang-switcher-btn {
        width: 100%;
        justify-content: center;
    }
}
