/* Popup Overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    /* Slightly darker for better contrast */
    backdrop-filter: blur(5px);
    z-index: 2147483647;
    /* Max Z-Index to ensure it's on top of everything */
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* Prevent blocking clicks when not fully active */
}

.popup-overlay.active {
    display: flex;
    /* Flex to center */
    opacity: 1;
    pointer-events: auto;
    /* Enable clicks only when active */
}

/* Popup Container */
.popup-container {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    background: transparent;
    /* Funnel has its own background/styling */
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

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

/* Ensure the card has a background since we removed the stars */
#organic-popup-container .funnel-card {
    background: #130f25;
    /* Dark purple/navy to match theme but solid */
    border-radius: 20px;
    overflow: hidden;
    /* Keep children clipped */
    box-shadow: none;
    /* Container has shadow */
    padding: 20px !important;
    /* Force smaller padding */
    min-height: auto !important;
    /* Allow height to shrink */
    max-width: 100%;
}

/* Override global section padding for the popup */
#popup-signup-form.funnel-section {
    padding: 0 !important;
    margin: 0 !important;
}

/* Close Button */
.popup-close {
    position: absolute;
    /* Absolute relative to the fixed overlay */
    top: 30px;
    right: 20px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    color: #000000;
    font-size: 28px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2147483648;
    /* Highest Z-Index */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.popup-close:hover {
    background: #f3f4f6;
    transform: scale(1.1);
}

/* Minimized State */
.popup-minimized {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #7c3aed 0%, #d946ef 100%);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.5);
    z-index: 2147483646;
    /* Just below overlay */
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    animation: pulseMin 3s infinite;
}

.popup-minimized:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.7);
}

.popup-minimized i {
    color: white;
    font-size: 24px;
}

.popup-minimized .notification-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 15px;
    height: 15px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
}

@keyframes pulseMin {
    0% {
        box-shadow: 0 0 0 0 rgba(217, 70, 239, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(217, 70, 239, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(217, 70, 239, 0);
    }
}

/* Scrollbar for popup */
.popup-container::-webkit-scrollbar {
    width: 8px;
}

.popup-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.popup-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

@media (max-width: 768px) {
    .popup-container {
        width: 95%;
        max-height: 85vh;
        margin-top: 20px;
        /* Ensure space from top */
    }

    /* Mobile Close Button */
    .popup-close {
        position: absolute;
        top: 20px;
        right: 15px;
        width: 36px;
        height: 36px;
        font-size: 20px;
        background: #ffffff;
        color: #000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        border: 2px solid #f3f4f6;
        z-index: 2147483648;
    }
}