/* Z-Blog多语言插件 · 前台语言切换 */
.zbml-lang-switch,
.zbml-lang-float {
    --zbml-switch-bg: #ffffff;
    --zbml-switch-bg-soft: #f8fafc;
    --zbml-switch-line: rgba(15, 23, 42, 0.1);
    --zbml-switch-text: #0f172a;
    --zbml-switch-muted: #64748b;
    --zbml-switch-accent: #2563eb;
    --zbml-switch-accent-soft: #eff6ff;
    --zbml-switch-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
    --zbml-switch-radius: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    color: var(--zbml-switch-text);
    -webkit-font-smoothing: antialiased;
}

.zbml-lang-switch__toggle {
    list-style: none;
    cursor: pointer;
    user-select: none;
    outline: none;
}

.zbml-lang-switch__toggle::-webkit-details-marker {
    display: none;
}

.zbml-lang-switch__toggle::marker {
    content: "";
}

.zbml-lang-switch__label {
    color: var(--zbml-switch-muted);
    margin-right: 8px;
    font-size: 12px;
}

/* 主题内联 */
.zbml-lang-switch--inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.zbml-lang-switch__inline {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.zbml-lang-switch__link--inline {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--zbml-switch-line);
    background: var(--zbml-switch-bg);
    color: var(--zbml-switch-text);
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.zbml-lang-switch__link--inline:hover {
    border-color: rgba(37, 99, 235, 0.28);
    color: var(--zbml-switch-accent);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.zbml-lang-switch__link--inline.is-current {
    background: var(--zbml-switch-accent-soft);
    border-color: rgba(37, 99, 235, 0.22);
    color: var(--zbml-switch-accent);
    font-weight: 600;
}

/* 主题下拉 / 列表 */
.zbml-lang-switch--dropdown,
.zbml-lang-switch--list {
    display: inline-block;
    position: relative;
}

.zbml-lang-switch--float .zbml-lang-switch__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    max-width: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

/* 主题下拉 - 单列列表风格 */
.zbml-lang-switch--dropdown.select-dropdown {
    position: relative;
    display: inline-block;
}

.zbml-lang-switch--dropdown .dropdown-toggle {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    padding: 0;
    border: 0;
    background: transparent;
    color: #333;
    font-size: 14px;
    font-weight: 400;
    text-decoration: none;
    cursor: pointer;
    box-shadow: none;
    list-style: none;
    user-select: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.zbml-lang-switch--dropdown .dropdown-toggle::after {
    display: inline-block;
    margin-left: 2px;
    vertical-align: middle;
    content: "";
    border-top: 0.35em solid #999;
    border-right: 0.35em solid transparent;
    border-bottom: 0;
    border-left: 0.35em solid transparent;
}

.zbml-lang-switch--dropdown .zbml-lang-switch__current {
    color: #333;
    font-weight: 400;
    font-size: 14px;
    margin-left: 0;
    max-width: none;
}

.zbml-lang-switch--dropdown .zbml-lang-switch__flag-wrap {
    position: relative;
    flex-shrink: 0;
    width: 24px;
    height: 18px;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.zbml-lang-switch--dropdown .zbml-lang-switch__flag-wrap::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.12) 42%, transparent 100%);
    pointer-events: none;
}

.zbml-lang-switch--dropdown .zbml-lang-switch__flag {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
}

.zbml-lang-switch--dropdown .zbml-lang-switch__flag--fallback {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 0;
    background: rgba(148, 163, 184, 0.35);
}

.zbml-lang-switch--dropdown .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 99998;
    min-width: 168px;
    margin: 8px 0 0;
    padding: 0;
    font-size: 14px;
    color: #333;
    text-align: left;
    list-style: none;
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        visibility 0s linear 0.2s;
    display: block;
    pointer-events: none;
    overflow: hidden;
    max-height: 320px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.zbml-lang-switch--dropdown .dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    margin-top: 8px;
    transform: translateY(0);
    pointer-events: auto;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        visibility 0s;
}

.zbml-lang-switch--dropdown .dropdown-menu.show[data-zbml-placement="top"] {
    top: auto;
    bottom: calc(100% + 8px);
    margin-top: 0;
    margin-bottom: 0;
    transform: translateY(0);
}

.zbml-lang-switch--dropdown .dropdown-item {
    display: flex !important;
    align-items: center;
    width: 100%;
    padding: 10px 14px;
    min-height: 44px;
    white-space: nowrap !important;
    clear: both;
    font-weight: 400;
    font-size: 14px;
    color: #333;
    text-align: inherit;
    text-decoration: none;
    background-color: #fff;
    border: 0;
    border-bottom: 1px solid #eee;
    gap: 10px;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.zbml-lang-switch--dropdown .dropdown-item:last-child {
    border-bottom: 0;
}

.zbml-lang-switch--dropdown .dropdown-item .zbml-lang-switch__name {
    flex: 1;
    min-width: 0;
}

.zbml-lang-switch--dropdown .dropdown-item .zbml-lang-switch__meta {
    margin-left: auto;
}

.zbml-lang-switch--dropdown .dropdown-item .zbml-lang-switch__check {
    color: #f39c12;
}

.zbml-lang-switch--dropdown .dropdown-item:hover,
.zbml-lang-switch--dropdown .dropdown-item.is-current {
    background-color: #fff9e1;
    color: #f39c12;
}

.zbml-lang-switch--dropdown .dropdown-item.is-current {
    font-weight: 400;
}

.zbml-lang-switch__flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    font-size: 16px;
    line-height: 1;
}

.zbml-lang-switch-item {
    list-style: none;
    display: flex;
    align-items: center;
}

.zbml-lang-switch--float .zbml-lang-switch__menu--float {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.zbml-lang-switch--float .zbml-lang-switch__menu--float::-webkit-scrollbar {
    display: none;
}

.zbml-lang-switch--float .zbml-lang-switch__flag-wrap {
    position: relative;
    flex-shrink: 0;
    width: 26px;
    height: 22px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.zbml-lang-switch--float .zbml-lang-switch__flag-wrap::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 45%, transparent 100%);
    pointer-events: none;
}

.zbml-lang-switch--float .zbml-lang-switch__flag {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.zbml-lang-switch__link--float {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    line-height: 0;
    color: var(--zbml-switch-text);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.zbml-lang-switch__link--float:hover {
    transform: scale(1.08);
    background: transparent;
    border-color: transparent;
    color: inherit;
}

.zbml-lang-switch__link--float.is-current .zbml-lang-switch__flag-wrap {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #f39c12, 0 2px 6px rgba(0, 0, 0, 0.2);
}

.zbml-lang-switch__icon {
    display: inline-flex;
    flex-shrink: 0;
    color: var(--zbml-switch-accent);
}

.zbml-lang-switch__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 0 2px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--zbml-switch-text);
    line-height: 1;
}

.zbml-lang-switch__current {
    font-weight: 600;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zbml-lang-switch__chevron {
    display: inline-flex;
    flex-shrink: 0;
    margin-left: 2px;
    color: var(--zbml-switch-muted);
    transition: transform 0.2s ease, color 0.15s ease;
}

details[open] > .zbml-lang-switch__toggle .zbml-lang-switch__chevron {
    transform: rotate(180deg);
    color: var(--zbml-switch-accent);
}

/* 下拉面板 */
.zbml-lang-switch__panel {
    position: absolute;
    z-index: 99998;
    min-width: 240px;
    border-radius: var(--zbml-switch-radius);
    border: 1px solid var(--zbml-switch-line);
    background: var(--zbml-switch-bg);
    box-shadow: var(--zbml-switch-shadow);
    overflow: hidden;
    animation: zbmlLangPanelIn 0.18s ease;
}

@keyframes zbmlLangPanelIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

.zbml-lang-switch--list .zbml-lang-switch__menu {
    min-width: 148px;
    border-radius: var(--zbml-switch-radius);
    border: 1px solid var(--zbml-switch-line);
    background: var(--zbml-switch-bg);
    box-shadow: var(--zbml-switch-shadow);
}

.zbml-lang-switch__item {
    margin: 0;
    padding: 0;
}

.zbml-lang-switch__link {
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.zbml-lang-switch__name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.zbml-lang-switch__meta {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    min-width: 22px;
}

.zbml-lang-switch__code {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--zbml-switch-muted);
    opacity: 0.85;
}

.zbml-lang-switch__check {
    display: block;
    color: var(--zbml-switch-accent);
}

.zbml-lang-switch__link--list {
    display: block;
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--zbml-switch-text);
}

.zbml-lang-switch__link--list:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--zbml-switch-accent);
}

.zbml-lang-switch__link--list.is-current {
    background: var(--zbml-switch-accent-soft);
    color: var(--zbml-switch-accent);
    font-weight: 600;
}

/* 页面浮动 */
.zbml-lang-float {
    position: fixed;
    z-index: 99999;
    left: 0;
    right: 0;
    margin: auto;
    width: max-content;
    max-width: calc(100vw - 28px);
}

.zbml-lang-float--bc {
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
}

.zbml-lang-float--br {
    right: 18px;
    bottom: 18px;
}

.zbml-lang-float--bl {
    left: 18px;
    bottom: 18px;
}

.zbml-lang-float--tr {
    right: 18px;
    top: 18px;
}

.zbml-lang-float--tl {
    left: 18px;
    top: 18px;
}

.zbml-lang-switch--float {
    display: inline-block;
    width: max-content;
    max-width: 100%;
    padding: 6px 10px;
    border-radius: 999px;
    background: hsl(0deg 0% 0% / 24%);
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.16);
}

@media (max-width: 1080px) {
    /* 主题移动端导航内：下拉改为内联展开 */
    .zbml-lang-switch-item {
        display: block;
        width: 100%;
        line-height: normal;
    }

    .zbml-lang-switch--dropdown.select-dropdown {
        display: block;
        width: 100%;
    }

    .zbml-lang-switch--dropdown .dropdown-toggle {
        width: 100%;
        min-height: 44px;
        padding: 0 18px;
        box-sizing: border-box;
    }

    .zbml-lang-switch--dropdown .dropdown-menu {
        position: static;
        left: auto;
        right: auto;
        float: none;
        width: 100%;
        min-width: 0;
        margin: 0;
        opacity: 1;
        visibility: visible;
        transform: none;
        max-height: 0;
        overflow: hidden;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        pointer-events: none;
        transition: max-height 0.25s ease;
    }

    .zbml-lang-switch--dropdown .dropdown-menu.show {
        max-height: min(70vh, 420px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        pointer-events: auto;
        margin: 0;
        transform: none;
        border-top: 1px solid #eee;
    }

    .zbml-lang-switch--dropdown .dropdown-item {
        padding: 12px 18px;
    }

    .zbml-lang-switch--inline {
        flex-wrap: wrap;
        width: 100%;
    }

    .zbml-lang-switch__inline {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .zbml-lang-float {
        max-width: calc(100vw - 24px);
    }

    .zbml-lang-float--bc {
        left: 12px;
        right: 12px;
        width: auto;
        transform: none;
    }

    .zbml-lang-float--bc,
    .zbml-lang-float--br,
    .zbml-lang-float--bl {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .zbml-lang-float--tr,
    .zbml-lang-float--tl {
        top: calc(12px + env(safe-area-inset-top, 0px));
    }

    .zbml-lang-float--br {
        right: 12px;
    }

    .zbml-lang-float--bl {
        left: 12px;
    }

    .zbml-lang-switch--float {
        display: block;
        width: 100%;
        box-sizing: border-box;
        padding: 10px 12px;
        border-radius: 999px;
    }

    .zbml-lang-switch--float .zbml-lang-switch__menu--float {
        gap: 8px;
        scroll-snap-type: x proximity;
        padding: 2px 0;
    }

    .zbml-lang-switch--float .zbml-lang-switch__item {
        scroll-snap-align: start;
    }

    .zbml-lang-switch--float .zbml-lang-switch__flag-wrap {
        width: 26px;
        height: 20px;
    }

    .zbml-lang-switch__link--float:active {
        transform: scale(1.05);
    }

    .zbml-lang-switch--dropdown .dropdown-menu.show {
        max-height: min(60vh, 360px);
    }
}

@media (prefers-color-scheme: dark) {
    .zbml-lang-switch,
    .zbml-lang-float {
        --zbml-switch-bg: #1e293b;
        --zbml-switch-bg-soft: #0f172a;
        --zbml-switch-line: rgba(255, 255, 255, 0.1);
        --zbml-switch-text: #f1f5f9;
        --zbml-switch-muted: #94a3b8;
        --zbml-switch-accent: #60a5fa;
        --zbml-switch-accent-soft: rgba(37, 99, 235, 0.18);
        --zbml-switch-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    }

    .zbml-lang-switch--float {
        background: rgba(30, 41, 59, 0.96);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    }
}
