@php
    $offer_popups = App\Models\OfferPopUp::where('status', 1)->get();
@endphp
@if ($offer_popups->count() > 0)
    @foreach ($offer_popups as $index => $offer_popup)
        <div class="overlay" id="overlay{{ $index }}" onclick="closePopup('{{ $index }}')">
            <div class="popup_wrapper">
                <div class="popup_sucessfull" onclick="event.stopPropagation()">
                    <span class="close" onclick="closePopup('{{ $index }}')"><img src="/assets/cross.png"></span>
                    <div class="popup_content">
                        <h3>
                            {{ $offer_popup->title }}
                        </h3>
                        <div class="popup_info">
                            <img src="{{ asset('/storage/' . $offer_popup->image) }}" alt="">
                        </div>
                    </div>
                </div>
            </div>

        </div>
    @endforeach
@endif



<style>
    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 9999;
    }

    .popup_wrapper {
        position: relative;
        z-index: 10000;
    }

    .popup_sucessfull {
        background-color: #FFFFFF;
        border-radius: 20px;
        box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
        padding: 20px;
        min-width: 700px;
        min-height: 500px;
        max-width: 90%;
        max-height: 90%;
        overflow-y: auto;
    }

    .outercontent {
        position: relative;
    }

    .popup_sucessfull .close {

        position: absolute;
        top: 20px;
        right: 20px;
        cursor: pointer;
        color: gray;
        z-index: 1;
    }

    .popup_sucessfull .close img {
        height: 15px;
        width: 15px;
    }

    .popup_content {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
    }

    .popup_content h3 {
        font-weight: 700;
        font-size: 20px;
        color: #007BC5;

    }

    .popup_info {
        margin: 5%;
        text-align: center;
        z-index: 2;
        margin-top: 10px 0;
    }

    .popup_info img {
        padding: 10px;
        border-radius: 6px;
        width: 500px;
        height: 400px;
    }

    @media only screen and (max-width: 768px) {
        .popup_sucessfull {
            min-width: 182px;
            max-width: 182px;
            max-height: 246.42;
            min-height: 246.42;
            border-radius: 10px;
            overflow: hidden;
        }

        .popup_sucessfull .close {
            font-size: 12px;
            font-weight: 500;
            height: 0px;
            width: 5px;
        }

        .popup_info img {
            width: 180px;
            height: 160px;
        }

        .popup_sucessfull .close {
            top: 5px;
            right: 5px;
        }

    }
</style>
<script>
    function closePopup(index) {
        var overlay = document.querySelector('#overlay' + index);
        overlay.style.display = 'none';
    }
</script>
