/**
 * VPN Popups - Modal Styles
 *
 * Minimal wrapper styles. Content inside uses theme CSS.
 */

/* Overlay */
.vpn-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    visibility: hidden;
    opacity: 0;
    transition: background 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
}

.vpn-popup-overlay.is-visible {
    background: rgba(0, 0, 0, 0.75);
    visibility: visible;
    opacity: 1;
}

/* Container — theme-aware via --surface-0 / [data-theme="dark"] */
.vpn-popup-container {
    position: relative;
    background: var(--surface-0, #fff);
    color: var(--heading, #0a0a0a);
    border: 1px solid var(--border-1, rgba(0, 0, 0, 0.08));
    border-radius: 16px;
    max-width: 560px; /* default size */
    width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
[data-theme="dark"] .vpn-popup-container {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

/* Size presets (controlled from the popup CPT "Size" field) */
.vpn-popup-container[data-size="compact"] { max-width: 440px; }
.vpn-popup-container[data-size="default"] { max-width: 560px; }
.vpn-popup-container[data-size="wide"]    { max-width: 680px; }
.vpn-popup-container[data-size="xwide"]   { max-width: 860px; }

.vpn-popup-overlay.is-visible .vpn-popup-container {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Content wrapper */
.vpn-popup-content {
    padding: 32px;
    max-height: calc(90vh - 64px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for content */
.vpn-popup-content::-webkit-scrollbar {
    width: 6px;
}

.vpn-popup-content::-webkit-scrollbar-track {
    background: transparent;
}

.vpn-popup-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.vpn-popup-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .vpn-popup-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
}
[data-theme="dark"] .vpn-popup-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* Close button — theme-aware */
.vpn-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    cursor: pointer;
    color: var(--muted, #6b7280);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    z-index: 10;
    padding: 0;
}

.vpn-popup-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--heading, #0a0a0a);
}

.vpn-popup-close:active {
    transform: scale(0.95);
}

[data-theme="dark"] .vpn-popup-close {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted, #9ca3af);
}
[data-theme="dark"] .vpn-popup-close:hover {
    background: rgba(255, 255, 255, 0.16);
    color: var(--heading, #fff);
}

.vpn-popup-close svg {
    width: 20px;
    height: 20px;
}

/* Body scroll lock when popup is open */
body.vpn-popup-open {
    overflow: hidden;
}

/* Mobile styles - Bottom sheet */
@media (max-width: 640px) {
    .vpn-popup-overlay {
        align-items: flex-end;
    }

    .vpn-popup-container {
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }

    .vpn-popup-overlay.is-visible .vpn-popup-container {
        transform: translateY(0);
    }

    .vpn-popup-content {
        padding: 24px;
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
        max-height: calc(85vh - 48px);
    }

    .vpn-popup-close {
        top: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
    }

    .vpn-popup-close svg {
        width: 18px;
        height: 18px;
    }

    /* Drag handle indicator for mobile */
    .vpn-popup-container::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: rgba(0, 0, 0, 0.15);
        border-radius: 2px;
    }
    [data-theme="dark"] .vpn-popup-container::before {
        background: rgba(255, 255, 255, 0.22);
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .vpn-popup-overlay,
    .vpn-popup-container,
    .vpn-popup-close {
        transition: none;
    }
}

/* Focus styles for accessibility — matches theme (black ring, not WP admin blue) */
.vpn-popup-close:focus-visible {
    outline: 2px solid var(--heading, #0a0a0a);
    outline-offset: 2px;
}
[data-theme="dark"] .vpn-popup-close:focus-visible {
    outline-color: #fff;
}

/* Animation for content appearing */
.vpn-popup-content > * {
    animation: vpn-popup-fade-in 0.4s ease 0.1s both;
}

@keyframes vpn-popup-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .vpn-popup-content > * {
        animation: none;
    }
}
