<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>WhatsApp Chat</title>
    <meta content='#008069' name='theme-color'/>
    <meta property='og:image' content='img/grupo/1.jpg'/>
    <meta content='width=device-width, initial-scale=1.0' name='viewport'/>
    <link href='https://site-assets.fontawesome.com/releases/v6.1.1/css/all.css' rel='stylesheet'/>
    <link rel="stylesheet" href="complementos/stylo.css">
    <style>
        .user, .user2 { margin-bottom: 15px !important; width: 100%; display: flex; flex-direction: column; }
        .number { font-size: 11px; font-weight: bold; color: #075E54; margin-bottom: 3px; margin-left: 15px; }
        .video { position: relative; max-width: 280px; margin-left: 15px; }
        .video img { border-radius: 10px; width: 100%; display: block; border: 1px solid #ddd; }
        .videodetails { position: absolute; bottom: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; align-items: center; color: white; font-size: 11px; background: rgba(0,0,0,0.4); padding: 5px; border-radius: 5px; }
        .download { display: flex; align-items: center; gap: 5px; cursor: pointer; }
        .user2-box { position: relative; background: #fff; padding: 8px 12px; border-radius: 0 10px 10px 10px; margin-left: 15px; max-width: 80%; box-shadow: 0 1px 1px rgba(0,0,0,0.1); }
        .user2-box::before { content: ""; position: absolute; left: -10px; top: 0; width: 10px; height: 15px; background: #fff; clip-path: polygon(100% 0, 0 0, 100% 100%); }
        .msg-text { font-size: 14px; color: #111; line-height: 1.4; }
        .hora { font-size: 10px; color: #999; text-align: right; margin-top: 4px; }
    </style>
</head>
<body oncontextmenu="return false;">
    <div class='widget-content'>
        <header>
            <div class="left">
                <i class="fa-regular fa-arrow-left"></i>
                <img src="img/grupo/1.jpg" id="header-img" />
                <div class="text">
                    <h1 id="header-title">Cargando...</h1>
                    <p id="header-numbers">Cargando participantes...</p>
                </div>
            </div>
            <div class="right">
                <i class="fa-solid fa-phone-plus"></i>
                <i class="fa-regular fa-ellipsis-vertical"></i>
            </div>
        </header>
        <main id="chat-container" style="padding-top: 70px; padding-bottom: 20px;">
            <div class="date">
                <p><span id="day"></span> de <span id="month"></span> de <span id="year"></span></p>
            </div>
        </main>

        <div class="modal" style="display: none;">
            <div class="info">
                <div id="intro">
                    <img class="profile" src="img/grupo/1.jpg" id="modal-img" />
                    <h1 class="title" id="modal-title">Cargando...</h1>
                    <p class="created">Creado el <span id="created"></span></p>
                    <div class="reactions">
                        <img src="img/perfiles/mujer/1.jpg" />
                        <img src="img/perfiles/mujer/7.jpg" />
                        <img src="img/perfiles/hombre/1.jpg" />
                        <span class="total" id="modal-total">+450</span>
                    </div>
                    <button id="join">Ver Grupo</button>
                </div>
                <div id="share" style="display: none;">
                    <div class="last" style="margin-bottom: 15px; font-size: 14px; color: #555;">
                        Para usar el chat, haz clic en invitar y comparte el grupo en otros grupos de WhatsApp.
                    </div>
                    <div class="percentage">Progreso: <span id="percentage-text">0%</span></div>
                    <div class="bar">
                        <div class="fill" id="fill-bar"></div>
                    </div>
                    <button id="invite">invitar</button>
                </div>
                <div id="offer" style="display: none;">
                    <button id="get">Unirme al grupo</button>
                </div>
            </div>
        </div>

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                const groupPool = [
                    { title: "😍 Full Porno XXX 🥵", img: "img/grupo/1.jpg" },
                    { title: "🔞 VIDEOS HOT PRIVADOS 💦", img: "img/grupo/6.jpg" },
                    { title: "😈 CHICAS CALIENTES 😈", img: "img/grupo/8.jpg" },
                    { title: "🔥 GRUPO VIP 18+ 🔥", img: "img/grupo/10.jpg" },
                    { title: "🍑 SOLAS Y CALIENTES 🍑", img: "img/grupo/3.jpg" },
                    { title: "🔞 CONTENIDO EXCLUSIVO 🔞", img: "img/grupo/4.jpg" }
                ];

                function genNum() {
                    const codes = ["+52", "+34", "+57", "+54", "+505", "+593", "+56"];
                    return codes[Math.floor(Math.random()*codes.length)] + " " + Math.floor(Math.random()*900+100) + " " + Math.floor(Math.random()*900+100) + " " + Math.floor(Math.random()*9000+1000);
                }

                let idx = localStorage.getItem('lastScenarioIdx');
                let newIdx = (idx === null) ? Math.floor(Math.random()*groupPool.length) : (parseInt(idx) + 1) % groupPool.length;
                localStorage.setItem('lastScenarioIdx', newIdx);
                
                const group = groupPool[newIdx];
                $("#header-img, #modal-img").attr("src", group.img);
                $("#header-title, #modal-title").text(group.title);
                $("#header-numbers").text(`${genNum()}, ${genNum()}, +1 (682) 200-9962`);

                const d = new Date();
                const months = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
                $("#day").text(d.getDate()); $("#month").text(months[d.getMonth()]); $("#year").text(d.getFullYear());
                $("#created").text(d.getDate() + "/" + (d.getMonth()+1) + "/" + d.getFullYear().toString().slice(-2));

                function cargarMensaje() {
                    $.ajax({
                        url: "complementos/mensajes.php",
                        success: function(respuesta) {
                            $("#chat-container").append(respuesta);
                            $('html, body').animate({ scrollTop: $('#chat-container')[0].scrollHeight }, 1000);
                        },
                        error: function() {
                            // Fallback para servidores sin PHP (simulación local)
                            const fallbackMsgs = [
                                '<div class="system-msg" style="margin: 10px auto;">' + genNum() + ' se unió mediante el enlace del grupo</div>',
                                '<div class="user2"><div class="number">' + genNum() + '</div><div class="user2-box"><div class="msg-text">Hola! Mira este video 🔞</div><div class="hora">14:20</div></div></div>'
                            ];
                            $("#chat-container").append(fallbackMsgs[Math.floor(Math.random()*fallbackMsgs.length)]);
                        }
                    });
                }

                let msgCount = 0;
                let timer = setInterval(function() {
                    cargarMensaje();
                    msgCount++;
                    if (msgCount >= 10) {
                        clearInterval(timer);
                        setTimeout(() => $(".modal").fadeIn(), 3000);
                    }
                }, 2000);

                let progress = 0;
                const currentDomain = window.location.origin + window.location.pathname.replace('grupo.php', '').replace('chat.html', '');
                const shareText = "🥵😈 ÚNETE a este GRUPO XXX, hay muchos videos y chicas enviando sus fotos privadas. Únete antes de que se llene. 🔞💋🔥💦⬇️⬇️⬇️ " + currentDomain;
                
                $("#join").click(function () { $("#intro").hide(); $("#share").show(); });
                $("#invite").click(function () {
                    window.location.href = "whatsapp://send?text=" + encodeURIComponent(shareText);
                    if (progress === 0) progress = 40; else if (progress === 40) progress = 70; else if (progress === 70) progress = 90; else if (progress === 90) progress = 100;
                    setTimeout(() => { 
                        $("#fill-bar").css("width", progress + "%"); 
                        $("#percentage-text").text(progress + "%"); 
                        if (progress === 100) { $("#share").hide(); $("#offer").show(); }
                    }, 1500);
                });
                $("#get").click(function () { window.open("https://tu-oferta-cpa.com/", "_blank"); });
            });
        </script>
    </div>
</body>
</html>
