/* ==========================================================================
   i18n：语言切换器 + 语言调试层
   颜色全部走站点主题变量（static/css/theme.css），浅色/深色自动适配。
   ========================================================================== */

/* 加载词条前先隐藏正文，避免「先闪一下中文再变外语」 */
html.i18n-loading body {
    visibility: hidden;
}

/* ---------------------------------------------------------- 语言切换器 */
.i18n-switch {
    position: relative;
    flex: 0 0 auto;
}

.i18n-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    margin: 0 2px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel-soft);
    color: var(--text);
    font-size: .86rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.i18n-btn:hover,
.i18n-switch.is-open .i18n-btn {
    border-color: var(--accent-border);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.i18n-globe {
    font-size: .95rem;
    line-height: 1;
}

.i18n-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    display: none;
    flex-direction: column;
    min-width: 208px;
    max-height: min(70vh, 460px);
    overflow: auto;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.i18n-switch.is-open .i18n-menu,
.i18n-switch:hover .i18n-menu,
.i18n-switch:focus-within .i18n-menu {
    display: flex;
}

.i18n-option {
    display: grid;
    grid-template-columns: 22px 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 0 6px;
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    transition: background .12s ease, color .12s ease;
}

.i18n-option .i18n-flag {
    grid-row: 1 / span 2;
    font-size: 1.05rem;
    text-align: center;
}

.i18n-option span:not(.i18n-flag) {
    font-size: .92rem;
    font-weight: 600;
}

.i18n-option small {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 400;
}

.i18n-option:hover {
    background: var(--panel-soft);
    color: var(--accent-dark);
}

.i18n-option.is-active {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.i18n-option.is-active::after {
    content: "✓";
    justify-self: end;
    margin-left: 8px;
    color: var(--accent);
    font-size: .8rem;
}

.i18n-menu-foot {
    margin: 4px 6px 2px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .74rem;
}

.i18n-menu-foot a {
    color: var(--muted);
}

.i18n-menu-foot a:hover {
    color: var(--accent-dark);
}

/* 手机端：抽屉里语言按钮铺满一行 */
@media (max-width: 1024px) {
    .i18n-switch {
        width: 100%;
        margin: 6px 0 2px;
    }

    .i18n-btn {
        width: 100%;
        height: 44px;
        margin: 0;
        justify-content: center;
    }

    .i18n-menu {
        position: static;
        display: none;
        width: 100%;
        max-height: none;
        margin: 4px 0 2px;
        box-shadow: none;
    }

    .i18n-switch.is-open .i18n-menu {
        display: flex;
    }
}

/* 语言菜单里的「翻译用户内容」开关 */
.i18n-content-option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 6px 0;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--panel-soft);
    color: var(--text);
    font-size: .82rem;
    cursor: pointer;
}

.i18n-content-option input {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* 用户内容翻译状态浮标 */
.i18n-content-badge {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 9000;
    padding: 8px 12px;
    border: 1px solid var(--accent-border);
    border-radius: 999px;
    background: var(--panel);
    color: var(--accent-dark);
    font-size: .8rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    cursor: pointer;
    user-select: none;
}

.i18n-content-badge:hover {
    background: var(--accent-soft);
}

.i18n-content-badge.is-idle {
    color: var(--muted);
    border-color: var(--border);
}

.i18n-content-badge.is-off {
    color: var(--muted);
    border-color: var(--border);
    opacity: .8;
}

.i18n-content-badge.is-original {
    color: var(--warn);
    border-color: var(--warn);
}

@media (max-width: 900px) {
    .i18n-content-badge {
        left: 10px;
        right: 10px;
        bottom: 10px;
        text-align: center;
    }
}

/* ---------------------------------------------------------- 调试模式 */
.i18n-debug-layer {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
}

.i18n-debug-box {
    position: fixed;
    border: 1px dashed rgba(220, 38, 38, .85);
    background: rgba(248, 113, 113, .16);
    border-radius: 3px;
}

.i18n-debug-panel {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    width: min(420px, calc(100vw - 32px));
    max-height: min(60vh, 560px);
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: .82rem;
    overflow: hidden;
}

.i18n-debug-panel[hidden] {
    display: none;
}

.i18n-debug-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--panel-soft);
    border-bottom: 1px solid var(--border);
}

.i18n-debug-head strong {
    color: var(--accent-dark);
    font-size: .9rem;
}

.i18n-debug-head button {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
}

.i18n-debug-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 10px 12px;
}

.i18n-debug-stat {
    margin-bottom: 8px;
    color: var(--muted);
}

.i18n-debug-stat b {
    color: var(--danger);
}

.i18n-debug-list {
    margin: 0;
    padding-left: 20px;
}

.i18n-debug-list li {
    margin: 3px 0;
    color: var(--text);
    line-height: 1.45;
    word-break: break-all;
}

.i18n-debug-count {
    display: inline-block;
    min-width: 26px;
    margin-right: 6px;
    padding: 0 4px;
    border-radius: 6px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: .72rem;
    text-align: center;
}

.i18n-debug-more {
    margin-top: 8px;
    color: var(--muted);
    font-size: .76rem;
}

.i18n-debug-ok {
    padding: 12px 4px;
    color: var(--success);
    font-weight: 600;
}

.i18n-debug-foot {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}

.i18n-debug-foot button {
    flex: 1 1 auto;
    padding: 8px 10px;
    border: 1px solid var(--accent-border);
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}

.i18n-debug-foot button:hover {
    background: var(--accent);
    color: #fff;
}
