.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

/* No overlay for movable_mobile type */
.popup-overlay.no-overlay {
    background: transparent;
    pointer-events: none;
}

.popup-overlay.no-overlay .popup-container {
    pointer-events: auto;
    z-index: 99999; /* Higher z-index for non-center positions */
}

/* Higher z-index for non-center positions */
.popup-overlay.high-zindex {
    z-index: 99999;
}

.popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Popup Container */
.popup-container {
    max-width: 90%;
    max-height: 90%;
    
    position: relative;
    transform: scale(0.7);
    transition: transform 0.3s ease;
}

/* Larger width for center positions */


.popup-overlay.show .popup-container {
    transform: scale(1);
}

/* Popup Content */
.popup-content {
    /* background: #ffffff; */
    border-radius: 12px;
    /* box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); */
    overflow: hidden;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

/* Popup content without frame (image only) */
.popup-content.no-frame {
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

/* Close Button */
.popup-close {
    position: absolute;
    top: -10px;
    right: -10px;
    background: rgba(0, 0, 0, 1);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 15;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    touch-action: manipulation; /* Improve touch responsiveness */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
}

/* Close button for image-only popup */
.popup-content.no-frame .popup-close {
    top: -8px;
    right: -8px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid white;
}

.popup-close:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Popup Header */
.popup-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
}

.popup-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.4;
}

/* Popup Body */
.popup-body {
    padding: 20px;
    width: auto;
}

/* Image Section */
.popup-image-section {
    margin-bottom: 20px;
    text-align: center;
    position: relative;
    display: inline-block;
}

.popup-image-desktop,
.popup-image-mobile {
    border-radius: 8px;
    
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); */
    position: relative;
}

.popup-image-desktop img,
.popup-image-mobile img {
    width: auto;
    height: auto;
    max-width: 600px;
    min-width: 200px; /* Đảm bảo ảnh không quá nhỏ trên desktop */
}

/* Image link styling */
.popup-image-link {
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
    touch-action: manipulation; /* Ensure touch works on mobile */
    -webkit-tap-highlight-color: rgba(0,0,0,0.1); /* Light tap highlight */
}

.popup-image-link:hover {
    transform: scale(1.02);
}

/* Ensure images are clickable on mobile */
.popup-image-desktop img,
.popup-image-mobile img {
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}

/* Remove box shadow for image-only popup */
.popup-content.no-frame .popup-image-desktop,
.popup-content.no-frame .popup-image-mobile {
    box-shadow: none;
    border-radius: 0;
}

/* Hide mobile image on desktop by default */
.popup-image-mobile {
    display: none;
}

/* Content Section */
.popup-content-section {
    text-align: center;
}

.popup-action {
    margin-bottom: 20px;
}

.popup-btn {
    display: inline-block;
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.popup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
    color: white;
    text-decoration: none;
}

/* Iframe Section */
.popup-iframe {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.popup-iframe-content {
    width: 100%;
    height: 400px;
    border: none;
}

/* Special styling for iframe in bottom-right position */


/* Desktop Positioning Classes */
/* Top Positions */
.popup-overlay[data-position-desktop="top-left"],
.popup-overlay[data-position-desktop="top-center"],
.popup-overlay[data-position-desktop="top-right"] {
    align-items: flex-start;
    padding-top: 50px;
}

.popup-overlay[data-position-desktop="top-left"] {
    justify-content: flex-start;
    padding-left: 50px;
}

.popup-overlay[data-position-desktop="top-center"] {
    justify-content: center;
}

.popup-overlay[data-position-desktop="top-right"] {
    justify-content: flex-end;
    padding-right: 50px;
}

/* Center Positions */
.popup-overlay[data-position-desktop="center-left"] {
    align-items: center;
    justify-content: flex-start;
    padding-left: 50px;
}

.popup-overlay[data-position-desktop="center"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.popup-overlay[data-position-desktop="center-right"] {
    align-items: center;
    justify-content: flex-end;
    padding-right: 50px;
}

/* Bottom Positions */
.popup-overlay[data-position-desktop="bottom-left"],
.popup-overlay[data-position-desktop="bottom-center"],
.popup-overlay[data-position-desktop="bottom-right"] {
    align-items: flex-end;
    padding-bottom: 50px;
}

.popup-overlay[data-position-desktop="bottom-left"] {
    justify-content: flex-start;
    padding-left: 50px;
}

.popup-overlay[data-position-desktop="bottom-center"] {
    justify-content: center;
}

.popup-overlay[data-position-desktop="bottom-right"] {
    justify-content: flex-end;
    padding-right: 50px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .popup-container {
        max-width: 95%;
        max-height: 95%;
    }
    
    /* Ảnh mobile với kích thước mặc định 90px cho các vị trí không phải center */
    .popup-image-desktop img,
    .popup-image-mobile img {
        width: 90px;
        height: auto;
        max-width: 90px;
        min-width: auto;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    }
    
    /* Ảnh mobile với kích thước lớn khi ở vị trí center */
    .popup-overlay[data-position-mobile="center"] .popup-image-desktop img,
    .popup-overlay[data-position-mobile="center"] .popup-image-mobile img {
        width: auto;
        max-width: 90vw;
        min-width: auto;    
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    }
 
    
    .popup-title {
        font-size: 20px;
    }
    
    .popup-body {
        padding: 15px;
    }
    
    /* Show mobile image on mobile, hide desktop image */
    .popup-image-desktop {
        display: none;
    }
    
    .popup-image-mobile {
        display: block;
    }
    
    .popup-iframe-content {
        height: 250px;
    }
    
    /* Mobile Positioning */
    .popup-overlay[data-position-mobile="top-left"],
    .popup-overlay[data-position-mobile="top-center"],
    .popup-overlay[data-position-mobile="top-right"] {
        align-items: flex-start !important;
        padding-top: 20px !important;
        padding-bottom: 0 !important;
    }
    
    .popup-overlay[data-position-mobile="top-left"] {
        justify-content: flex-start !important;
        padding-left: 20px !important;
        padding-right: 0 !important;
    }
    
    .popup-overlay[data-position-mobile="top-center"] {
        justify-content: center !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .popup-overlay[data-position-mobile="top-right"] {
        justify-content: flex-end !important;
        padding-right: 20px !important;
        padding-left: 0 !important;
    }
    
    .popup-overlay[data-position-mobile="center-left"] {
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 0 0 0 20px !important;
    }
    
    .popup-overlay[data-position-mobile="center"] {
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
    }
    
    .popup-overlay[data-position-mobile="center-right"] {
        align-items: center !important;
        justify-content: flex-end !important;
        padding: 0 20px 0 0 !important;
    }
    
    .popup-overlay[data-position-mobile="bottom-left"],
    .popup-overlay[data-position-mobile="bottom-center"],
    .popup-overlay[data-position-mobile="bottom-right"] {
        align-items: flex-end !important;
        padding-bottom: 20px !important;
        padding-top: 0 !important;
    }
    
    .popup-overlay[data-position-mobile="bottom-left"] {
        justify-content: flex-start !important;
        padding-left: 20px !important;
        padding-right: 0 !important;
    }
    
    .popup-overlay[data-position-mobile="bottom-center"] {
        justify-content: center !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .popup-overlay[data-position-mobile="bottom-right"] {
        justify-content: flex-end !important;
        padding-right: 20px !important;
        padding-left: 0 !important;
    }
}

@media (max-width: 480px) {
   
    
    .popup-header {
        padding: 15px;
    }
    
    .popup-title {
        font-size: 18px;
    }
    
    .popup-body {
        padding: 12px;
    }
    
    .popup-close {
        top: -8px;
        right: -8px;
        width: 28px;
        height: 28px;
        font-size: 16px;
        z-index: 9999; /* Đảm bảo close button luôn ở trên */
        min-width: 28px; /* Đảm bảo kích thước tối thiểu cho mobile */
        min-height: 28px;
    }
}