/* Auto Popup Styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    /* Debug: Make sure it's visible when active */
    pointer-events: none;
}

.popup-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.popup-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: transparent;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.7) translateY(50px);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    animation: popupFloat 6s ease-in-out infinite;
    display: inline-block;
    width: auto;
    height: auto;
    /* Auto-size based on content */
    min-width: 300px;
    min-height: 200px;
    /* Smooth transitions for size changes */
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55),
                width 0.3s ease,
                height 0.3s ease;
}

.popup-overlay.active .popup-container {
    transform: scale(1) translateY(0);
}

@keyframes popupFloat {
    0%, 100% { transform: scale(1) translateY(0) rotate(0deg); }
    25% { transform: scale(1.01) translateY(-3px) rotate(0.3deg); }
    50% { transform: scale(1) translateY(0) rotate(0deg); }
    75% { transform: scale(1.01) translateY(-2px) rotate(-0.3deg); }
}

.popup-header {
    position: relative;
    padding: 2rem;
    text-align: center;
    color: white;
    overflow: hidden;
}

.popup-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 15px 15px 0 0;
    position: relative;
    z-index: 1;
}

.popup-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(102, 126, 234, 0.8), rgba(118, 75, 162, 0.8));
    z-index: 2;
}

.popup-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.popup-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: logoSpin 4s ease-in-out infinite;
}

@keyframes logoSpin {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(5deg) scale(1.1); }
}

.popup-logo img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.popup-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); }
    to { text-shadow: 2px 2px 20px rgba(255, 255, 255, 0.5); }
}

.popup-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.popup-body {
    padding: 0;
    color: white;
    text-align: center;
}

.popup-content {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Legacy styles removed - now using full ad display */

/* Clean Advertisement Image Only - Auto Size */
.popup-clean-ad {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 20px;
    transition: all 0.3s ease;
    display: block;
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: 90vh;
    /* Ensure the container fits the image exactly */
    line-height: 0;
}

.popup-clean-ad:hover {
    transform: scale(1.02);
}

.clean-ad-image {
    display: block;
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    transition: transform 0.3s ease;
    border-radius: 20px;
    object-fit: contain;
    /* Ensure image maintains aspect ratio and auto-sizes container */
    vertical-align: top;
}

.popup-clean-ad:hover .clean-ad-image {
    transform: scale(1.05);
}

/* Old CTA styles removed - now using overlay CTA */

.popup-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.popup-feature {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    transition: all 0.3s ease;
    animation: featureFloat 3s ease-in-out infinite;
}

.popup-feature:nth-child(1) { animation-delay: 0s; }
.popup-feature:nth-child(2) { animation-delay: 0.5s; }
.popup-feature:nth-child(3) { animation-delay: 1s; }

@keyframes featureFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.popup-feature:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
}

.popup-feature i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #ffd700;
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.popup-feature h4 {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.popup-feature p {
    font-size: 0.8rem;
    opacity: 0.9;
    margin: 0;
}

.popup-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.popup-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.popup-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.popup-btn:hover::before {
    left: 100%;
}

.popup-btn-primary {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.popup-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

.popup-btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.popup-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.popup-timer {
    position: absolute;
    bottom: 10px;
    right: 15px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.popup-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff6b6b, #ffd700);
    border-radius: 0 0 20px 20px;
    animation: progressBar 10s linear;
}

@keyframes progressBar {
    from { width: 100%; }
    to { width: 0%; }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .popup-container {
        max-width: 95vw;
        max-height: 85vh;
        margin: 1rem auto;
        /* Allow auto-sizing on mobile too */
        width: auto !important;
        height: auto !important;
    }

    .popup-clean-ad {
        max-width: 95vw;
        max-height: 85vh;
    }

    .clean-ad-image {
        max-width: 95vw;
        max-height: 85vh;
        width: auto;
        height: auto;
    }
}

@media (max-width: 480px) {
    .popup-overlay {
        padding: 0.5rem;
    }

    .popup-container {
        width: auto !important;
        height: auto !important;
        margin: 0;
        max-width: 95vw;
        max-height: 95vh;
        border-radius: 15px;
    }

    .popup-image {
        height: 120px;
        border-radius: 15px 15px 0 0;
    }

    .popup-header {
        padding: 0.8rem;
    }

    .popup-title {
        font-size: 1.2rem;
    }

    .popup-subtitle {
        font-size: 0.85rem;
    }

    .popup-body {
        padding: 0;
    }

    .popup-logo {
        width: 50px;
        height: 50px;
    }

    .popup-logo img {
        width: 30px;
        height: 30px;
    }

    .popup-clean-ad {
        max-width: 95vw;
        max-height: 80vh;
        width: auto;
        height: auto;
    }

    .clean-ad-image {
        max-width: 95vw;
        max-height: 80vh;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .popup-overlay {
        background: rgba(0, 0, 0, 0.9);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .popup-container,
    .popup-overlay,
    .popup-btn,
    .popup-close {
        animation: none;
        transition: none;
    }
    
    .popup-overlay.active .popup-container {
        transform: scale(1) translateY(0);
    }
}
