/* Base Modal Styles */
.enp-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
}

/* Editor Mode Fixes */
.enp-popup-overlay.enp-is-editor {
    position: relative !important;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 99 !important;
    background: rgba(0, 0, 0, 0.1);
    height: 500px;
    /* Fixed height for preview */
    display: flex;
    justify-content: center;
    align-items: center;
}

.enp-popup-overlay.enp-is-editor .enp-popup-content {
    transform: scale(1) !important;
}

.enp-popup-overlay.enp-show {
    opacity: 1;
    visibility: visible;
}

.enp-popup-content {
    background: #fff;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.enp-popup-overlay.enp-show .enp-popup-content {
    transform: scale(1);
}

/* Close Button */
.enp-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    background: none;
    border: none;
    color: #333;
    transition: color 0.3s;
    line-height: 1;
    padding: 0;
}

.enp-close-btn:hover {
    color: #000;
}

/* Layouts */

/* Slide-in Bottom Right */
.enp-layout-slide-in-br {
    justify-content: flex-end;
    align-items: flex-end;
    padding: 20px;
}

.enp-layout-slide-in-br .enp-popup-content {
    transform: translateY(100px);
    margin: 0;
}

.enp-popup-overlay.enp-show.enp-layout-slide-in-br .enp-popup-content {
    transform: translateY(0);
}

/* Slide-in Bottom Left */
.enp-layout-slide-in-bl {
    justify-content: flex-start;
    align-items: flex-end;
    padding: 20px;
}

.enp-layout-slide-in-bl .enp-popup-content {
    transform: translateY(100px);
    margin: 0;
}

.enp-popup-overlay.enp-show.enp-layout-slide-in-bl .enp-popup-content {
    transform: translateY(0);
}

/* Float Corner */
.enp-layout-floating {
    background: transparent;
    pointer-events: none;
}

.enp-layout-floating .enp-popup-content {
    pointer-events: auto;
    position: absolute;
    bottom: 30px;
    right: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

/* Top Bar */
.enp-layout-top-bar {
    align-items: flex-start;
    padding: 0;
}

.enp-layout-top-bar .enp-popup-content {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    transform: translateY(-100%);
}

.enp-popup-overlay.enp-show.enp-layout-top-bar .enp-popup-content {
    transform: translateY(0);
}

/* Fullscreen Overlay */
.enp-layout-fullscreen .enp-popup-content {
    width: 100%;
    height: 100%;
    max-width: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Glassmorphism */
.enp-glassmorphism .enp-popup-content {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Custom Overlays */
.enp-overlay-gradient {
    background: linear-gradient(135deg, rgba(66, 134, 244, 0.8), rgba(55, 59, 68, 0.8));
}

/* Content Styles */
.enp-popup-image img {
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 20px;
    border-radius: 5px;
}

.enp-popup-text h3 {
    margin: 0 0 10px;
    font-size: 24px;
}

.enp-popup-text p {
    margin: 0 0 20px;
    font-size: 16px;
    color: #666;
}

.enp-popup-cta {
    display: inline-block;
    padding: 12px 25px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: background 0.3s;
}

.enp-popup-cta:hover {
    background: #005177;
}

/* Shortcode Container */
.enp-popup-shortcode {
    margin-top: 15px;
}

/* Step Animations */
.enp-step {
    display: none;
    animation: fadeIn 0.5s;
}

.enp-step.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- New Sizes --- */
.enp-size-small .enp-popup-content {
    max-width: 400px;
}

.enp-size-medium .enp-popup-content {
    max-width: 600px;
}

.enp-size-large .enp-popup-content {
    max-width: 800px;
}

.enp-size-fullscreen .enp-popup-content {
    width: 95%;
    height: 95%;
    max-width: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* --- Logo Styles --- */
.enp-popup-logo {
    margin-bottom: 20px;
    display: flex;
    width: 100%;
}

.enp-popup-logo img {
    max-width: 100%;
    height: auto;
    display: block;
}

.enp-logo-left {
    justify-content: flex-start;
}

.enp-logo-center {
    justify-content: center;
}

.enp-logo-right {
    justify-content: flex-end;
}

/* --- Template Styles --- */

/* Sale Template - Horizontal Layout */
.enp-template-sale.enp-popup-overlay .enp-popup-content {
    border: none;
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
    padding: 0;
    max-width: 750px;
    display: flex;
    /* Horizontal Layout */
    flex-direction: row;
    align-items: center;
    overflow: hidden;
    border-radius: 15px;
}

.enp-template-sale .enp-step {
    display: flex;
    flex-direction: row;
    width: 100%;
    align-items: center;
}

.enp-template-sale .enp-popup-image {
    width: 40%;
    margin-bottom: 0;
    line-height: 0;
}

.enp-template-sale .enp-popup-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    min-height: 300px;
    border-radius: 0;
}

/* If no image, make text full width */
.enp-template-sale .enp-step:not(:has(.enp-popup-image)) .enp-popup-text-wrapper {
    width: 100%;
}

/* Wrapper for text/cta to group them on the right */
.enp-template-sale .enp-popup-text,
.enp-template-sale .enp-popup-actions {
    /* We need to wrap these in PHP or hack via CSS if structure is flat. 
       Since structure is flat, we'll use order or flex tweaks. 
       Ideally we should change PHP structure for templates, but CSS grid/flex can save us.
    */
    padding: 20px;
}

/* Hacky Grid for Flat HTML Structure in CSS */
.enp-template-sale .enp-step {
    display: grid;
    grid-template-areas:
        "img content";
    grid-template-columns: 40% 60%;
}

.enp-template-sale .enp-popup-image {
    grid-area: img;
    height: 100%;
}

.enp-template-sale .enp-popup-logo {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 5;
    width: auto;
}

.enp-template-sale .enp-popup-text {
    grid-area: content;
    align-self: end;
    /* Push to middle/end */
    padding: 30px 30px 10px 30px;
    text-align: left;
}

.enp-template-sale .enp-popup-actions {
    grid-area: content;
    align-self: start;
    /* below text */
    padding: 10px 30px 30px 30px;
    text-align: left;
    margin-top: 100px;
    /* Space for text */
}

/* Fix stacking for text/actions in grid cells */
.enp-template-sale .enp-popup-text {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.enp-template-sale .enp-popup-actions {
    grid-column: 2;
    grid-row: 1;
    margin-top: auto;
    /* Push to bottom */
}


.enp-template-sale h3 {
    font-size: 32px;
    font-weight: 900;
    text-transform: uppercase;
    color: #e74c3c;
    margin-bottom: 15px;
    line-height: 1.1;
}

.enp-template-sale .enp-popup-text p {
    font-size: 16px;
    color: #555;
    margin-bottom: 20px;
}

.enp-template-sale .enp-popup-cta {
    background: #e74c3c;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    padding: 15px 35px;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.3);
    border: none;
    cursor: pointer;
    display: inline-block;
}

/* Mobile Responsive for Template */
@media (max-width: 768px) {
    .enp-template-sale .enp-step {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        grid-template-areas:
            "img"
            "content";
    }

    .enp-template-sale .enp-popup-image {
        width: 100%;
        height: 200px;
    }

    .enp-template-sale .enp-popup-text,
    .enp-template-sale .enp-popup-actions {
        text-align: center;
        grid-column: 1;
        grid-row: 2;
    }

    .enp-template-sale .enp-popup-actions {
        margin-top: 0;
        position: relative;
    }
}

/* Video Template */
.enp-template-video .enp-popup-content {
    background: #000;
    padding: 0;
    overflow: hidden;
}

.enp-template-video .enp-close-btn {
    color: #fff;
    z-index: 10;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.enp-template-video .enp-popup-shortcode iframe,
.enp-template-video .enp-popup-shortcode video {
    width: 100%;
    aspect-ratio: 16/9;
    display: block;
    border: none;
}

.enp-template-video .enp-popup-shortcode {
    margin-top: 0;
}

/* GDPR Template */
.enp-template-gdpr.enp-popup-overlay {
    align-items: flex-end;
    /* Force bottom alignment */
}

.enp-template-gdpr .enp-popup-content {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    margin: 0;
    transform: translateY(100%);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 20px 40px;
    background: #2c3e50;
    color: #fff;
}

.enp-popup-overlay.enp-show.enp-layout-center.enp-template-gdpr .enp-popup-content,
.enp-popup-overlay.enp-show.enp-template-gdpr .enp-popup-content {
    transform: translateY(0);
}

.enp-template-gdpr .enp-popup-text {
    flex: 1;
    margin-right: 20px;
    text-align: left;
}

.enp-template-gdpr .enp-popup-text p {
    color: #ecf0f1;
    margin: 0;
    font-size: 14px;
}

.enp-template-gdpr .enp-gdpr-actions {
    display: flex;
    gap: 10px;
}

.enp-template-gdpr .enp-accept-btn {
    background: #27ae60;
    border: none;
    color: #fff;
    cursor: pointer;
}

.enp-template-gdpr .enp-decline-btn {
    background: transparent;
    border: 1px solid #95a5a6;
    color: #bdc3c7;
    cursor: pointer;
}

.enp-template-gdpr .enp-close-btn {
    display: none;
    /* Usually GDPR bars don't have a close X, they have buttons */
}

/* --- Close Button Outside --- */
.enp-close-outside .enp-popup-content {
    overflow: visible;
}

.enp-close-outside .enp-close-btn {
    top: -40px;
    right: 0;
    color: #fff;
    font-size: 30px;
}

/* --- Animation Classes --- */
.animated {
    animation-duration: 0.8s;
    animation-fill-mode: both;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
    }
}

.zoomIn {
    animation-name: zoomIn;
}

@keyframes slideInUp {
    from {
        transform: translate3d(0, 100%, 0);
        visibility: visible;
    }

    to {
        transform: translate3d(0, 0, 0);
    }
}

.slideInUp {
    animation-name: slideInUp;
}

@keyframes slideInDown {
    from {
        transform: translate3d(0, -100%, 0);
        visibility: visible;
    }

    to {
        transform: translate3d(0, 0, 0);
    }
}

.slideInDown {
    animation-name: slideInDown;
}

@keyframes bounceIn {

    from,
    20%,
    40%,
    60%,
    80%,
    to {
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    }

    0% {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }

    20% {
        transform: scale3d(1.1, 1.1, 1.1);
    }

    40% {
        transform: scale3d(0.9, 0.9, 0.9);
    }

    60% {
        opacity: 1;
        transform: scale3d(1.03, 1.03, 1.03);
    }

    80% {
        transform: scale3d(0.97, 0.97, 0.97);
    }

    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

.bounceIn {
    animation-name: bounceIn;
}

/* Responsive adjustments for GDPR */
@media (max-width: 768px) {
    .enp-template-gdpr .enp-popup-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .enp-template-gdpr .enp-popup-text {
        margin-right: 0;
        margin-bottom: 15px;
    }

    .enp-template-gdpr .enp-gdpr-actions {
        width: 100%;
        justify-content: flex-end;
    }
}