<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Jardines de Ranelagh - Wi-Fi</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body>

<div class="bg"></div>

<div class="card">
    <h1 class="title">
        Jardines de Ranelagh<br>
        <span class="subtitle">Wi-Fi</span>
    </h1>

    <p class="text-small">Acceso gratuito por 30 minutos</p>

    <!-- LOGIN HOTSPOT -->
    <form method="post" action="http://10.170.0.1/login">
        <input type="hidden" name="dst" value="http://google.com">
        <input type="hidden" name="popup" value="true">

        <!-- CAMPOS VISUALES -->
        <label>Nombre completo</label>
        <input type="text" id="nombre" placeholder="Escribí tu nombre" required>

        <label>Correo electrónico</label>
        <input type="email" id="email" placeholder="nombre@correo.com" required>

        <!-- CAMPOS PARA MIKROTIK (TRIAL) -->
        <input type="hidden" name="username" value="trial">
        <input type="hidden" name="password" value="trial">

        <button type="submit">Conectarse</button>
    </form>

    <p class="provider">Servicio provisto por</p>
    <img src="fibergo.png" class="logo">
</div>

<script>
/* Envío a Google Sheets sin bloquear el login */
document.getElementById("loginForm").addEventListener("submit", function () {
    fetch("https://script.google.com/macros/s/AKfycbxIKzsU7KLoZgpryajimNH9OjQZeAcp-xPNpNspElmvk0sJnlrbwCwpoMAf_RtERS9Y/exec", {
        method: "POST",
        mode: "no-cors",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
            nombre: document.getElementById("nombre").value,
            email: document.getElementById("email").value,
            mac: "externo",
            ip: "externo",
            link: "externo"
            agent: navigator.userAgent,
            hotspot: "JARDINES WIFI",
            fecha: new Date().toISOString()
        })
    });
});

/* Detección Apple Captive Network (solo UX, no redirige) */
(function () {
    const ua = navigator.userAgent || "";
    if (ua.includes("CaptiveNetworkSupport") || ua.includes("wispr")) {
        document.body.classList.add("apple-cna");
    }
})();
</script>

</body>
</html>