/* ─── Pops – Modal Popups — Frontend Popup Styles ─────────────────────────── */

/* ── Root container ── */
#pbp-popups-root { pointer-events: none; }
#pbp-popups-root .pbp-popup-container { pointer-events: none; }
#pbp-popups-root .pbp-popup-container.pbp-visible { pointer-events: auto; }

/* ── Overlay ── */
.pbp-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 99998;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}
.pbp-popup-container.pbp-visible .pbp-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* ── Base popup ── */
.pbp-popup {
    position: fixed;
    z-index: 99999;
    background: var(--pbp-bg, #fff);
    color: var(--pbp-text, #1f2937);
    border-radius: 10px;
    box-shadow: 0 16px 64px rgba(0, 0, 0, .22);
    width: var(--pbp-width, 520px);
    max-width: calc(100vw - 32px);
    max-height: calc(100dvh - 32px);
    overflow: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease, transform .28s ease;
}
.pbp-popup-container.pbp-visible .pbp-popup {
    opacity: 1;
    pointer-events: auto;
}

/* ── Popup positions ── */

/* Modal (center) */
.pbp-type-modal.pbp-pos-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(.95);
}
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, -50%) scale(1);
}

/* Banner — top */
.pbp-type-banner.pbp-pos-top {
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 0;
    transform: translateY(-100%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .12);
}
.pbp-popup-container.pbp-visible .pbp-type-banner.pbp-pos-top {
    transform: translateY(0);
}

/* Banner — bottom */
.pbp-type-banner.pbp-pos-bottom {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 0;
    transform: translateY(100%);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .12);
}
.pbp-popup-container.pbp-visible .pbp-type-banner.pbp-pos-bottom {
    transform: translateY(0);
}

/* Slide-in — bottom-right */
.pbp-type-slide-in.pbp-pos-bottom-right {
    bottom: 24px;
    right: 24px;
    width: 360px;
    transform: translateX(120%);
}
.pbp-popup-container.pbp-visible .pbp-type-slide-in.pbp-pos-bottom-right {
    transform: translateX(0);
}

/* Slide-in — bottom-left */
.pbp-type-slide-in.pbp-pos-bottom-left {
    bottom: 24px;
    left: 24px;
    width: 360px;
    transform: translateX(-120%);
}
.pbp-popup-container.pbp-visible .pbp-type-slide-in.pbp-pos-bottom-left {
    transform: translateX(0);
}

/* Slide-in — top-right */
.pbp-type-slide-in.pbp-pos-top-right {
    top: 24px;
    right: 24px;
    width: 360px;
    transform: translateX(120%);
}
.pbp-popup-container.pbp-visible .pbp-type-slide-in.pbp-pos-top-right {
    transform: translateX(0);
}

/* Slide-in — top-left */
.pbp-type-slide-in.pbp-pos-top-left {
    top: 24px;
    left: 24px;
    width: 360px;
    transform: translateX(-120%);
}
.pbp-popup-container.pbp-visible .pbp-type-slide-in.pbp-pos-top-left {
    transform: translateX(0);
}

/* Fullscreen */
.pbp-type-fullscreen {
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    transform: scale(1.04);
    overflow-y: auto;
}
.pbp-popup-container.pbp-visible .pbp-type-fullscreen {
    transform: scale(1);
}

/* Floating — corner bubbles */
.pbp-type-floating.pbp-pos-bottom-right {
    bottom: 24px;
    right: 24px;
    width: 300px;
    border-radius: 14px;
    transform: translateY(20px);
}
.pbp-type-floating.pbp-pos-bottom-left {
    bottom: 24px;
    left: 24px;
    width: 300px;
    border-radius: 14px;
    transform: translateY(20px);
}
.pbp-type-floating.pbp-pos-top-right {
    top: 24px;
    right: 24px;
    width: 300px;
    border-radius: 14px;
    transform: translateY(-20px);
}
.pbp-type-floating.pbp-pos-top-left {
    top: 24px;
    left: 24px;
    width: 300px;
    border-radius: 14px;
    transform: translateY(-20px);
}
.pbp-popup-container.pbp-visible .pbp-type-floating {
    transform: translateY(0);
}

/* ── Animation overrides ── */

/* fade: keep positional transforms intact; only adjust opacity timing */
.pbp-anim-fade .pbp-popup {
    transition: opacity .35s ease, transform .35s ease;
}

/* bounce */
.pbp-anim-bounce.pbp-popup-container.pbp-visible .pbp-popup {
    animation: pbp-bounce .45s cubic-bezier(.34, 1.56, .64, 1) forwards;
}
@keyframes pbp-bounce {
    from { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* slide */
.pbp-anim-slide .pbp-type-modal.pbp-pos-center,
.pbp-anim-slide-up .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, calc(-50% + 30px)) !important;
}
.pbp-anim-slide.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-center,
.pbp-anim-slide-up.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, -50%) !important;
    transition: opacity .3s ease, transform .3s ease;
}


/* slide-down */
.pbp-anim-slide-down .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, calc(-50% - 30px)) !important;
}
.pbp-anim-slide-down.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, -50%) !important;
}

/* zoom */
.pbp-anim-zoom .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, -50%) scale(.85) !important;
}
.pbp-anim-zoom.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, -50%) scale(1) !important;
}

/* content button helpers */
.pbp-popup-body a.pbp-button,
.pbp-popup-body .button,
.pbp-popup-body button:not(.pbp-close) {
    background: var(--pbp-btn-bg, #2563eb);
    color: var(--pbp-btn-text, #ffffff);
}

/* none */
.pbp-anim-none .pbp-popup {
    transition: none !important;
}

/* ── Close button ── */
.pbp-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, .06);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #555;
    transition: background .15s;
    z-index: 2;
    padding: 0;
    line-height: 1;
}
.pbp-close:hover {
    background: rgba(0, 0, 0, .14);
    color: #111;
}

/* ── Popup body ── */
.pbp-popup-body {
    padding: 28px;
    position: relative;
}

/* Body is a bit slimmer on banners */
.pbp-type-banner .pbp-popup-body {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* ── Variant containers ── */
.pbp-variant { width: 100%; }

/* ── Responsive ── */
@media (max-width: 600px) {
    .pbp-type-modal.pbp-pos-center {
        width: min(var(--pbp-width, 520px), calc(100vw - 32px)) !important;
        top: 50%;
        left: 50%;
        max-height: calc(100dvh - 32px);
        overflow: auto;
    }
    .pbp-type-slide-in {
        width: 90vw !important;
        right: 5vw !important;
        left: auto !important;
    }
    .pbp-type-floating {
        width: 88vw !important;
        right: 6vw !important;
        left: auto !important;
        bottom: 16px !important;
    }
}

/* ── Utility: no-scroll on body when modal/fullscreen visible ── */
body.pbp-noscroll { overflow: hidden; }

/* Built-in CTA button */
.pbp-cta-wrap {
    margin: 18px 0 0;
}
.pbp-popup-body .pbp-cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 18px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    line-height: 1.2;
    border: 0;
    cursor: pointer;
}
.pbp-popup-body .pbp-cta-button:hover,
.pbp-popup-body .pbp-cta-button:focus {
    filter: brightness(.95);
    text-decoration: none;
}

@media (max-width: 480px) {
    .pbp-popup-body .pbp-cta-button {
        width: 100%;
    }
}

/* ── Additional robust positions for modal layouts ── */
.pbp-type-modal.pbp-pos-top {
    top: 24px;
    left: 50%;
    transform: translateX(-50%) scale(.95);
}
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-top {
    transform: translateX(-50%) scale(1);
}
.pbp-type-modal.pbp-pos-bottom {
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) scale(.95);
}
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-bottom {
    transform: translateX(-50%) scale(1);
}
.pbp-type-modal.pbp-pos-top-left { top: 24px; left: 24px; transform: scale(.95); }
.pbp-type-modal.pbp-pos-top-right { top: 24px; right: 24px; transform: scale(.95); }
.pbp-type-modal.pbp-pos-bottom-left { bottom: 24px; left: 24px; transform: scale(.95); }
.pbp-type-modal.pbp-pos-bottom-right { bottom: 24px; right: 24px; transform: scale(.95); }
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-top-left,
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-top-right,
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-bottom-left,
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-bottom-right {
    transform: scale(1);
}

/* Animation overrides should not drag non-centred layouts off-screen. */
.pbp-anim-slide .pbp-type-modal.pbp-pos-center,
.pbp-anim-slide-up .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, calc(-50% + 30px)) !important;
}
.pbp-anim-slide.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-center,
.pbp-anim-slide-up.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, -50%) !important;
}
.pbp-anim-slide-down .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, calc(-50% - 30px)) !important;
}
.pbp-anim-slide-down.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, -50%) !important;
}
.pbp-anim-zoom .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, -50%) scale(.85) !important;
}
.pbp-anim-zoom.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-center {
    transform: translate(-50%, -50%) scale(1) !important;
}

/* Built-in CTA alignment */
.pbp-cta-align-left { text-align: left; }
.pbp-cta-align-center { text-align: center; }
.pbp-cta-align-right { text-align: right; }

@media (max-width: 600px) {
    .pbp-type-modal.pbp-pos-top,
    .pbp-type-modal.pbp-pos-bottom,
    .pbp-type-modal.pbp-pos-center {
        width: min(var(--pbp-width, 520px), calc(100vw - 32px)) !important;
        left: 50%;
    }
    .pbp-type-modal.pbp-pos-bottom { bottom: 16px; }
    .pbp-type-modal.pbp-pos-top { top: 16px; }
    .pbp-type-modal.pbp-pos-top-left,
    .pbp-type-modal.pbp-pos-top-right,
    .pbp-type-modal.pbp-pos-bottom-left,
    .pbp-type-modal.pbp-pos-bottom-right {
        left: 16px !important;
        right: 16px !important;
        width: auto !important;
    }
    .pbp-type-modal.pbp-pos-top-left,
    .pbp-type-modal.pbp-pos-top-right { top: 16px; }
    .pbp-type-modal.pbp-pos-bottom-left,
    .pbp-type-modal.pbp-pos-bottom-right { bottom: 16px; }
}

/* ── Robust layout fallbacks for every type/position combination ──────────── */
.pbp-type-modal.pbp-pos-top {
    top: 24px;
    left: 50%;
    transform: translateX(-50%) scale(.96);
}
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-top {
    transform: translateX(-50%) scale(1);
}
.pbp-type-modal.pbp-pos-bottom {
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) scale(.96);
}
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-bottom {
    transform: translateX(-50%) scale(1);
}
.pbp-type-modal.pbp-pos-top-left,
.pbp-type-modal.pbp-pos-top-right,
.pbp-type-modal.pbp-pos-bottom-left,
.pbp-type-modal.pbp-pos-bottom-right {
    transform: scale(.96);
}
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-top-left,
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-top-right,
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-bottom-left,
.pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-bottom-right {
    transform: scale(1);
}
.pbp-type-modal.pbp-pos-top-left { top: 24px; left: 24px; }
.pbp-type-modal.pbp-pos-top-right { top: 24px; right: 24px; }
.pbp-type-modal.pbp-pos-bottom-left { bottom: 24px; left: 24px; }
.pbp-type-modal.pbp-pos-bottom-right { bottom: 24px; right: 24px; }

/* Only center modals should receive transform-destructive modal animations. */
.pbp-anim-bounce.pbp-popup-container.pbp-visible .pbp-popup:not(.pbp-type-modal),
.pbp-anim-bounce.pbp-popup-container.pbp-visible .pbp-type-modal:not(.pbp-pos-center) {
    animation: none !important;
}

.pbp-cta-wrap { margin: 18px 0 0; }
.pbp-cta-align-left { text-align: left !important; }
.pbp-cta-align-center { text-align: center !important; }
.pbp-cta-align-right { text-align: right !important; }
.pbp-button.pbp-cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    line-height: 1.2;
    border: 0;
}

@media (max-width: 600px) {
    .pbp-popup {
        max-width: calc(100vw - 24px);
        max-height: calc(100dvh - 24px);
    }
    .pbp-type-modal.pbp-pos-center {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        transform: translate(-50%, -50%) scale(.96);
    }
    .pbp-popup-container.pbp-visible .pbp-type-modal.pbp-pos-center {
        transform: translate(-50%, -50%) scale(1);
    }
    .pbp-type-modal.pbp-pos-top,
    .pbp-type-modal.pbp-pos-bottom,
    .pbp-type-modal.pbp-pos-top-left,
    .pbp-type-modal.pbp-pos-top-right,
    .pbp-type-modal.pbp-pos-bottom-left,
    .pbp-type-modal.pbp-pos-bottom-right,
    .pbp-type-slide-in,
    .pbp-type-floating {
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
    }
    .pbp-type-modal.pbp-pos-top,
    .pbp-type-modal.pbp-pos-top-left,
    .pbp-type-modal.pbp-pos-top-right,
    .pbp-type-slide-in.pbp-pos-top-left,
    .pbp-type-slide-in.pbp-pos-top-right,
    .pbp-type-floating.pbp-pos-top-left,
    .pbp-type-floating.pbp-pos-top-right {
        top: 12px !important;
        bottom: auto !important;
    }
    .pbp-type-modal.pbp-pos-bottom,
    .pbp-type-modal.pbp-pos-bottom-left,
    .pbp-type-modal.pbp-pos-bottom-right,
    .pbp-type-slide-in.pbp-pos-bottom-left,
    .pbp-type-slide-in.pbp-pos-bottom-right,
    .pbp-type-floating.pbp-pos-bottom-left,
    .pbp-type-floating.pbp-pos-bottom-right {
        bottom: 12px !important;
        top: auto !important;
    }
}
