/* Prevent Page Scroll when Dialog is Open */
html:has(dialog.bpopup-dialog[open]),
body:has(dialog.bpopup-dialog[open]),
body.bpopup-open {
    overflow: hidden !important;
}

/* Popup Manager Styles */
.bpopup-dialog {
    border: none;
    border-radius: 20px;
    padding: 0;
    max-width: 600px;
    width: 90%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transform: scale(0.9);
    opacity: 0;

    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        display 0.4s allow-discrete;
}

.bpopup-dialog[open] {
    opacity: 1;
    transform: scale(1);
}

/* Entry Animation */
@starting-style {
    .bpopup-dialog[open] {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Backdrop styling */
.bpopup-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.4s ease, display 0.4s allow-discrete;
}

.bpopup-dialog[open]::backdrop {
    opacity: 1;
}

@starting-style {
    .bpopup-dialog[open]::backdrop {
        opacity: 0;
    }
}

/* Content Container */
.bpopup-content {
    position: relative;
    padding: 40px;
    direction: rtl;
    text-align: center;
}

/* Close Button */
:is(button.bpopup-close) {
    position: absolute;
    top: 5px;
    left: 15px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 0;
}

.bpopup-close:hover {
    background: transparent;
}

.bpopup-close svg {
    width: 18px;
    height: 18px;
    color: #4b5563;
}

/* Inner Elements */
.bpopup-text {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #374151;
    margin-bottom: 20px;
}

.bpopup-html-container {
    text-align: initial;
}

/* Optional link wrapping the media */
.bpopup-media-link {
    display: block;
    cursor: pointer;
}

/* Media: image (natural size) / 3:2 video / 9:16 reel video */
.bpopup-media {
    position: relative;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
}

.bpopup-media--3-2 {
    aspect-ratio: 3 / 2;
    background: #000;
}

.bpopup-media--reel {
    aspect-ratio: 9 / 16;
    max-width: 360px;
    max-height: 70vh;
    background: #000;
}

.bpopup-media-el {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Image - full width, natural height (no crop) */
.bpopup-media--image img.bpopup-media-el {
    height: auto;
    max-height: 85vh;
    object-fit: contain;
}

/* Popups with media - no padding, media fills the popup edge to edge; text keeps its padding */
.bpopup-dialog:not(.bpopup-type-text) .bpopup-content {
    padding: 0;
}

.bpopup-dialog:not(.bpopup-type-text) .bpopup-html-container,
.bpopup-dialog:not(.bpopup-type-text) .bpopup-text {
    padding: 20px 30px 0;
}

.bpopup-dialog:not(.bpopup-type-text) .bpopup-text:last-child,
.bpopup-dialog:not(.bpopup-type-text) .bpopup-html-container:last-child {
    padding-bottom: 20px;
    margin-bottom: 0;
}

/* Close button stays readable on top of the media */
.bpopup-dialog:not(.bpopup-type-text) .bpopup-close {
    top: 10px;
    left: 10px;
    width: 32px;
    height: 32px;
    min-height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.bpopup-dialog:not(.bpopup-type-text) .bpopup-close:hover {
    background: #fff;
}

/* Reel popups are narrow, so the 9:16 video is not huge */
.bpopup-dialog.bpopup-type-video_reel {
    max-width: min(420px, 92vw);
}

.bpopup-dialog.bpopup-type-video_reel .bpopup-media--reel {
    max-height: calc(80vh - 80px);
    width: auto;
    aspect-ratio: 9 / 16;
}

/* Media in category WooCommerce notice */
.bpopup-notice .bpopup-media {
    margin-bottom: 15px;
    border-radius: 12px;
}

.bpopup-notice .bpopup-media--3-2,
.bpopup-notice .bpopup-media--image {
    max-width: 600px;
}

.bpopup-notice .bpopup-media--reel {
    max-width: 280px;
}