/* 美盛 — 语言选择器 */
.xh-lang-modal:not(.is-open) {
    position: fixed;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: -1;
}

.xh-lang-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    padding: 6px 12px;
    border: 1px solid rgba(91, 97, 223, 0.2);
    border-radius: 999px;
    background: rgba(253, 251, 250, 0.94);
    color: #26233b;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(38, 35, 59, 0.07);
}

.xh-lang-trigger:hover {
    background: #fdfbfa;
    border-color: rgba(91, 97, 223, 0.45);
    color: #5b61df;
    box-shadow: 0 2px 8px rgba(91, 97, 223, 0.12);
}

.xh-lang-trigger-label {
    color: inherit;
}

.xh-lang-trigger-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(38, 35, 59, 0.12);
    box-shadow: none;
    background: #fff;
}

.xh-lang-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.xh-lang-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 9999;
}

.xh-lang-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
}

.xh-lang-panel {
    position: relative;
    width: min(720px, 96vw);
    max-height: min(85vh, 720px);
    overflow: auto;
    padding: 24px 22px 28px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.xh-lang-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.xh-lang-head h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
}

.xh-lang-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: #f1f5f9;
    color: #334155;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.xh-lang-close:hover {
    background: #e2e8f0;
}

.xh-lang-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.xh-lang-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 10px 14px;
    border: 1px solid #e8ecf1;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.xh-lang-item:hover {
    border-color: rgba(91, 97, 223, 0.45);
    box-shadow: 0 4px 16px rgba(91, 97, 223, 0.1);
}

.xh-lang-item.is-active {
    border-color: #5b61df;
    background: #f5f3ff;
    box-shadow: 0 0 0 1px #5b61df;
}

.xh-lang-item.is-active .xh-lang-name {
    color: #5b61df;
}

.xh-lang-flag {
    position: relative;
    width: 48px;
    height: 48px;
}

.xh-lang-flag img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
    background: #fff;
}

.xh-lang-code {
    position: absolute;
    right: -4px;
    bottom: -2px;
    min-width: 22px;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e2e8f0;
    font-size: 9px;
    font-weight: 800;
    color: #475569;
    text-align: center;
    line-height: 1.3;
}

.xh-lang-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    text-align: center;
    line-height: 1.35;
}

.xh-lang-country {
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    text-align: center;
    line-height: 1.3;
}

body.xh-rtl {
    direction: rtl;
}

/* Header 保持 LTR：Logo 在左、语言切换在右，与其他语言一致 */
body.xh-rtl .header-area,
body.xh-rtl .header-area .nav-wrap,
body.xh-rtl .header-area .nav-wrap .purchase-button {
    direction: ltr;
}

body.xh-rtl .xh-lang-trigger {
    margin-left: 12px;
    margin-right: 0;
}

body.xh-rtl .xh-bg-trigger {
    margin-left: 8px;
    margin-right: 0;
}

body.xh-rtl .header-area .nav-wrap .purchase-button .navbar-toggler {
    margin-right: 20px;
    margin-left: 0;
}

@media (max-width: 640px) {
    .xh-lang-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .xh-lang-trigger-label {
        display: none;
    }
}

@media (max-width: 767px) {
    .header-area .xh-lang-trigger {
        margin-left: 0;
        padding: 8px;
        min-width: 40px;
        min-height: 40px;
        justify-content: center;
        gap: 0;
    }
    .header-area .xh-lang-trigger-icon {
        width: 22px;
        height: 22px;
    }
}

@media (max-width: 1199px) {
    .purchase-button {
        display: flex;
        align-items: center;
        gap: 6px;
    }
}

/* 美盛演示站导航栏 — 与菜单文字 #26233b 保持一致 */
.header-area .nav-wrap .purchase-button {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-area .xh-lang-trigger,
.header-area.sticky .xh-lang-trigger {
    color: #26233b;
    border-color: rgba(91, 97, 223, 0.2);
    background: rgba(253, 251, 250, 0.94);
    box-shadow: 0 1px 4px rgba(38, 35, 59, 0.07);
}

.header-area .xh-lang-trigger:hover,
.header-area.sticky .xh-lang-trigger:hover {
    color: #5b61df;
    border-color: rgba(91, 97, 223, 0.45);
    background: #fdfbfa;
    box-shadow: 0 2px 8px rgba(91, 97, 223, 0.12);
}

/* Telegram 跳转确认弹窗 */
.ms-tg-modal:not(.is-open) {
    position: fixed;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: -1;
}

.ms-tg-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.ms-tg-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ms-tg-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(38, 35, 59, 0.45);
    backdrop-filter: blur(2px);
}

.ms-tg-panel {
    position: relative;
    width: min(420px, 100%);
    padding: 22px 22px 18px;
    border-radius: 16px;
    background: #fdfbfa;
    box-shadow: 0 16px 48px rgba(38, 35, 59, 0.18);
    border: 1px solid rgba(91, 97, 223, 0.12);
}

.ms-tg-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.ms-tg-head h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #26233b;
    line-height: 1.35;
}

.ms-tg-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 999px;
    background: rgba(91, 97, 223, 0.08);
    color: #26233b;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.ms-tg-close:hover {
    background: rgba(91, 97, 223, 0.16);
    color: #5b61df;
}

.ms-tg-msg {
    margin: 0 0 12px;
    font-size: 14px;
    line-height: 1.6;
    color: #4a4760;
}

.ms-tg-url-label {
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 600;
    color: #7a7790;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ms-tg-url {
    margin: 0 0 18px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(91, 97, 223, 0.06);
    font-size: 14px;
    font-weight: 600;
    color: #5b61df;
    word-break: break-all;
}

.ms-tg-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.ms-tg-btn {
    min-width: 96px;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.ms-tg-btn--cancel {
    background: #fff;
    border-color: rgba(91, 97, 223, 0.22);
    color: #4a4760;
}

.ms-tg-btn--cancel:hover {
    border-color: rgba(91, 97, 223, 0.4);
    color: #26233b;
}

.ms-tg-btn--confirm {
    background: linear-gradient(135deg, #5b61df 0%, #7b6cf0 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(91, 97, 223, 0.28);
}

.ms-tg-btn--confirm:hover {
    box-shadow: 0 6px 18px rgba(91, 97, 223, 0.36);
}

html.ms-tg-modal-open {
    overflow: hidden;
}
