/* Multi Custom Popup Styles */
.custom-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    backdrop-filter: blur(5px);
}

.custom-popup-overlay.active {
    display: flex;
    opacity: 1;
}

.custom-popup {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    max-width: 500px;
    width: 90%;
    max-height: 75vh;
    overflow-y: auto;
    transform: scale(0.7);
    transition: transform 0.3s ease-in-out;
    animation: popupFadeIn 0.3s ease-out forwards;
}

.custom-popup-overlay.active .custom-popup {
    transform: scale(1);
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.custom-popup-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    z-index: 1;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.custom-popup-close:hover {
    background-color: #f5f5f5;
    color: #333;
    transform: rotate(90deg);
}

.popup-banner {
    width: 100%;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    margin-bottom: 0;
}

.popup-banner img {
    width: 100%;
    height: auto;
    max-height: 250px;
    object-fit: cover;
    display: block;
}

.popup-title {
    margin: 20px 30px 15px 30px;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    text-align: center;
    line-height: 1.3;
}

.popup-description {
    margin: 0 30px 20px 30px;
    color: #666;
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
}

.popup-embed-code {
    margin: 0 30px 20px 30px;
    min-height: 50px;
}

.popup-footer-description {
    margin: 20px 30px 30px 30px;
    color: #888;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

/* Popup Trigger Button Styles - Base */
.popup-trigger-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.popup-trigger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.popup-trigger-btn:active {
    transform: translateY(0);
}

/* Specific trigger button styles for different popups */
.popup-trigger-btn-1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.popup-trigger-btn-1:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.popup-trigger-btn-2 {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(240, 147, 251, 0.3);
}

.popup-trigger-btn-2:hover {
    box-shadow: 0 6px 20px rgba(240, 147, 251, 0.4);
}

.popup-trigger-btn-3 {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.popup-trigger-btn-3:hover {
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

.popup-trigger-btn-4 {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    box-shadow: 0 4px 15px rgba(67, 233, 123, 0.3);
}

.popup-trigger-btn-4:hover {
    box-shadow: 0 6px 20px rgba(67, 233, 123, 0.4);
}

.popup-trigger-btn-5 {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    box-shadow: 0 4px 15px rgba(250, 112, 154, 0.3);
}

.popup-trigger-btn-5:hover {
    box-shadow: 0 6px 20px rgba(250, 112, 154, 0.4);
}

/* Admin Styles */
.nav-tab-wrapper {
    border-bottom: 1px solid #ccc;
    margin: 0 0 20px;
    padding: 0;
}

.nav-tab {
    background: #f1f1f1;
    border: 1px solid #ccc;
    border-bottom: none;
    color: #555;
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    margin: 0 5px -1px 0;
    padding: 8px 12px;
    text-decoration: none;
    position: relative;
}

.nav-tab:hover {
    background: #e1e1e1;
    color: #333;
}

.nav-tab-active {
    background: #fff;
    border-bottom: 1px solid #fff;
    color: #000;
}

.tab-content {
    background: #fff;
    border: 1px solid #ccc;
    padding: 20px;
    border-radius: 0 5px 5px 5px;
    margin-top: -1px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .custom-popup {
        width: 85%;
        margin: 20px;
        max-height: 65vh;
    }
    
    .popup-title {
        font-size: 18px;
        margin: 15px 20px 10px 20px;
    }
    
    .popup-description,
    .popup-embed-code {
        margin: 0 20px 15px 20px;
    }
    
    .popup-footer-description {
        margin: 15px 20px 20px 20px;
    }
    
    .popup-banner img {
        max-height: 180px;
    }
    
    .custom-popup-close {
        top: 10px;
        right: 15px;
        font-size: 24px;
        width: 35px;
        height: 35px;
    }
    
    /* Mobile tab navigation */
    .nav-tab-wrapper {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-tab {
        display: inline-block;
        white-space: nowrap;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .custom-popup {
        width: 98%;
        margin: 10px;
        border-radius: 8px;
    }
    
    .popup-banner {
        border-radius: 8px 8px 0 0;
    }
    
    .popup-title {
        font-size: 18px;
        margin: 12px 15px 8px 15px;
    }
    
    .popup-description,
    .popup-embed-code,
    .popup-footer-description {
        margin-left: 15px;
        margin-right: 15px;
    }
    
    .popup-banner img {
        max-height: 150px;
    }
    
    .popup-trigger-btn,
    .popup-trigger-btn-1,
    .popup-trigger-btn-2,
    .popup-trigger-btn-3,
    .popup-trigger-btn-4,
    .popup-trigger-btn-5 {
        padding: 10px 20px;
        font-size: 14px;
        width: 100%;
        max-width: 300px;
        margin: 5px 0;
    }
}

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

.custom-popup::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.custom-popup::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.custom-popup::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Form styling inside popup embed code */
.popup-embed-code iframe {
    width: 100% !important;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Loading animation for embed content */
.popup-embed-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    color: #999;
}

.popup-embed-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Popup z-index stacking */
#custom-popup-overlay-1 { z-index: 999999; }
#custom-popup-overlay-2 { z-index: 999998; }
#custom-popup-overlay-3 { z-index: 999997; }
#custom-popup-overlay-4 { z-index: 999996; }
#custom-popup-overlay-5 { z-index: 999995; }

/* Special effects for different popup types */
.custom-popup-overlay[data-popup-id="1"] .custom-popup {
    border: 2px solid #667eea;
}

.custom-popup-overlay[data-popup-id="2"] .custom-popup {
    border: 2px solid #f093fb;
}

.custom-popup-overlay[data-popup-id="3"] .custom-popup {
    border: 2px solid #4facfe;
}

.custom-popup-overlay[data-popup-id="4"] .custom-popup {
    border: 2px solid #43e97b;
}

.custom-popup-overlay[data-popup-id="5"] .custom-popup {
    border: 2px solid #fa709a;
}

/* Admin preview styles */
.preview-popup {
    margin-top: 10px;
}

/* Form table improvements in admin */
.form-table th {
    width: 200px;
    padding: 15px 10px 15px 0;
    vertical-align: top;
}

.form-table td {
    padding: 15px 10px;
}

.form-table textarea,
.form-table input[type="text"],
.form-table input[type="url"],
.form-table input[type="number"] {
    width: 100%;
    max-width: 500px;
}

/* Success/Error messages */
.notice {
    margin: 15px 0;
    padding: 12px;
    border-left: 4px solid;
    background: #fff;
    border-radius: 3px;
}

.notice-success {
    border-left-color: #46b450;
    background: #ecf7ed;
}

.notice-error {
    border-left-color: #dc3232;
    background: #fbeaea;
}

/* Accessibility improvements */
.custom-popup:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
}

.custom-popup-close:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
    background-color: #f0f0f0;
}

/* Print styles */
@media print {
    .custom-popup-overlay {
        display: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .custom-popup {
        border: 2px solid #000;
    }
    
    .custom-popup-close {
        color: #000;
        background: #fff;
        border: 1px solid #000;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .custom-popup-overlay,
    .custom-popup,
    .popup-trigger-btn {
        transition: none;
        animation: none;
    }
    
    .custom-popup-close:hover {
        transform: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .custom-popup {
        background: #2d2d2d;
        color: #ffffff;
        border: 1px solid #555;
    }
    
    .popup-title {
        color: #ffffff;
    }
    
    .popup-description {
        color: #cccccc;
    }
    
    .popup-footer-description {
        color: #aaaaaa;
        border-top-color: #555;
    }
    
    .custom-popup-close {
        color: #cccccc;
    }
    
    .custom-popup-close:hover {
        background-color: #404040;
        color: #ffffff;
    }
}