/* ============================================
   Экран «Выключите VPN» перед переходом к оплате (static/js/vpn_gate.js).
   Работает на токенах design_system.css, поэтому подхватывает тёмную тему.
   ============================================ */

.vpn-gate {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-16, 16px);
    background: rgba(0, 0, 0, 0);
    opacity: 0;
    z-index: var(--z-popup, 1100);
    transition: all var(--transition-normal, 0.25s ease);
}

.vpn-gate.active {
    background: var(--color-overlay-bg, rgba(0, 0, 0, 0.4));
    opacity: 1;
}

.vpn-gate-content {
    position: relative;
    width: 100%;
    max-width: 360px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: var(--space-24, 24px) var(--space-20, 20px) var(--space-20, 20px);
    border-radius: var(--radius-lg, 18px);
    background: var(--color-surface, #FFFFFF);
    box-shadow: var(--shadow-float, 0 20px 60px rgba(0, 0, 0, 0.12));
    text-align: center;
    transform: scale(0.85);
    transition: transform var(--transition-normal, 0.25s ease);
}

.vpn-gate.active .vpn-gate-content {
    transform: scale(1);
}

.vpn-gate-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-full, 9999px);
    background: var(--color-bg, #F2F2F7);
    color: var(--color-text-secondary, #8E8E93);
    cursor: pointer;
}

.vpn-gate svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.vpn-gate-close svg { width: 16px; height: 16px; }

.vpn-gate-badge {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-16, 16px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: var(--color-accent-bg, rgba(255, 149, 0, 0.1));
    color: var(--color-accent, #FF9500);
}

.vpn-gate-badge svg { width: 32px; height: 32px; }

/* То же окно просит разрешить боту писать (bot_access.js) */
.vpn-gate-badge--primary {
    background: var(--color-primary-bg, rgba(52, 199, 89, 0.08));
    color: var(--color-primary, #34C759);
}

.vpn-gate-title {
    margin: 0 0 var(--space-8, 8px);
    font-size: var(--font-size-lg, 20px);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--color-text, #1C1C1E);
}

.vpn-gate-text {
    margin: 0 0 var(--space-20, 20px);
    font-size: var(--font-size-base, 15px);
    line-height: var(--line-height-relaxed, 1.6);
    color: var(--color-text-secondary, #8E8E93);
}

.vpn-gate-note {
    display: none;
    margin-bottom: var(--space-12, 12px);
    padding: var(--space-10, 10px) var(--space-12, 12px);
    border-radius: var(--radius-sm, 10px);
    background: var(--color-accent-bg, rgba(255, 149, 0, 0.1));
    color: var(--color-text, #1C1C1E);
    font-size: var(--font-size-sm, 13px);
    line-height: var(--line-height-normal, 1.47);
    text-align: left;
}

.vpn-gate-note.is-visible {
    display: block;
    animation: vpn-gate-shake 360ms ease-out;
}

@keyframes vpn-gate-shake {
    0%, 100% { transform: none; }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

.vpn-gate-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-8, 8px);
}

.vpn-gate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-8, 8px);
    width: 100%;
    min-height: 48px;
    padding: var(--space-12, 12px) var(--space-20, 20px);
    border: none;
    border-radius: var(--radius-sm, 10px);
    font-family: inherit;
    font-size: var(--font-size-md, 17px);
    font-weight: var(--font-weight-semibold, 600);
    cursor: pointer;
    transition: all var(--transition-fast, 0.15s ease);
}

.vpn-gate-btn:active { transform: scale(0.97); }

.vpn-gate-btn--primary {
    background: var(--color-primary, #34C759);
    color: #FFFFFF;
}

.vpn-gate-btn--secondary {
    background: var(--color-bg, #F2F2F7);
    color: var(--color-text, #1C1C1E);
    font-size: var(--font-size-base, 15px);
}

.vpn-gate-btn--link {
    min-height: 40px;
    background: none;
    color: var(--color-text-secondary, #8E8E93);
    font-size: var(--font-size-base, 15px);
    font-weight: var(--font-weight-medium, 500);
}

.vpn-gate-btn.is-busy {
    pointer-events: none;
    opacity: 0.75;
}

.vpn-gate-btn.is-busy::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: vpn-gate-spin 0.8s linear infinite;
}

@keyframes vpn-gate-spin {
    to { transform: rotate(360deg); }
}

/* --- Спойлер «из-за границы» --- */
.vpn-gate-abroad {
    margin-top: var(--space-16, 16px);
    border-radius: var(--radius-md, 14px);
    background: var(--color-bg, #F2F2F7);
    text-align: left;
    overflow: hidden;
}

.vpn-gate-abroad summary {
    display: flex;
    align-items: center;
    gap: var(--space-10, 10px);
    padding: var(--space-12, 12px) var(--space-16, 16px);
    list-style: none;
    cursor: pointer;
    font-size: var(--font-size-base, 15px);
    font-weight: var(--font-weight-medium, 500);
    color: var(--color-text, #1C1C1E);
}

.vpn-gate-abroad summary::-webkit-details-marker { display: none; }

.vpn-gate-abroad summary svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--color-text-secondary, #8E8E93);
}

.vpn-gate-abroad summary .vpn-gate-chevron {
    margin-left: auto;
    transition: transform var(--transition-normal, 0.25s ease);
}

.vpn-gate-abroad[open] summary .vpn-gate-chevron { transform: rotate(180deg); }

.vpn-gate-abroad-body {
    padding: 0 var(--space-16, 16px) var(--space-12, 12px);
}

.vpn-gate-abroad-body p {
    margin: 0 0 var(--space-12, 12px);
    font-size: var(--font-size-sm, 13px);
    line-height: var(--line-height-normal, 1.47);
    color: var(--color-text-secondary, #8E8E93);
}

.vpn-gate-abroad .vpn-gate-btn--secondary {
    background: var(--color-surface, #FFFFFF);
}

/* --- Шаги «оплатить из-за границы через браузер» --- */
.vpn-gate-steps {
    margin: 0 0 var(--space-12, 12px);
    padding: 0;
    list-style: none;
    counter-reset: vpn-step;
}

.vpn-gate-steps li {
    position: relative;
    padding-left: 32px;
    margin-bottom: var(--space-10, 10px);
    font-size: var(--font-size-sm, 13px);
    line-height: var(--line-height-normal, 1.47);
    color: var(--color-text, #1C1C1E);
    counter-increment: vpn-step;
}

.vpn-gate-steps li:last-child { margin-bottom: 0; }

.vpn-gate-steps li::before {
    content: counter(vpn-step);
    position: absolute;
    left: 0;
    top: -1px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full, 9999px);
    background: var(--color-primary-bg, rgba(52, 199, 89, 0.12));
    color: var(--color-primary, #34C759);
    font-size: 12px;
    font-weight: var(--font-weight-semibold, 600);
}

.vpn-gate-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* --- На телефоне окно во весь экран: выезжает снизу, содержимое по центру,
       длинное прокручивается. Крестик и отступы не лезут под панель
       Telegram (tg_fullscreen.css) и системную полосу снизу. --- */
@media (max-width: 600px) {
    .vpn-gate {
        padding: 0;
        align-items: stretch;
    }

    .vpn-gate.active {
        background: var(--color-surface, #FFFFFF);
    }

    .vpn-gate-content {
        display: flex;
        flex-direction: column;
        max-width: none;
        max-height: none;
        height: 100%;
        border-radius: 0;
        box-shadow: none;
        padding: calc(var(--space-24, 24px) + 32px) var(--space-20, 20px)
            calc(var(--space-20, 20px) + max(env(safe-area-inset-bottom, 0px), var(--tg-bottom-inset, 0px)));
        transform: translateY(32px);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .vpn-gate.active .vpn-gate-content {
        transform: none;
    }

    /* Блок по центру, пока помещается; иначе обычная прокрутка сверху */
    .vpn-gate-badge { margin-top: auto; }
    .vpn-gate-content > :last-child { margin-bottom: auto; }

    /* Не сжимать блоки под высоту экрана: спойлер с overflow: hidden иначе
       ужимался и прятал кнопку «Открыть заказ в браузере» — пусть прокручивается */
    .vpn-gate-content > * { flex-shrink: 0; }

    .vpn-gate-content > :not(.vpn-gate-close):not(.vpn-gate-badge) {
        width: 100%;
        max-width: 420px;
        margin-left: auto;
        margin-right: auto;
    }

    .vpn-gate-close {
        position: fixed;
        top: 12px;
        right: 12px;
    }

    body.tg-fullscreen .vpn-gate-content {
        padding-top: calc(var(--tg-top-inset) + var(--space-24, 24px));
    }

    body.tg-fullscreen .vpn-gate-close {
        top: calc(var(--tg-top-inset) + 4px);
    }
}
