<?php
// paneladm.jatpluss.com/home.php

require_once __DIR__ . '/config/config.php';   //  ← solo una vez
if (session_status() === PHP_SESSION_NONE) session_start();

$resultado     = $_SESSION['resultado']     ?? '';
$error_message = $_SESSION['error_message'] ?? '';
unset($_SESSION['resultado'], $_SESSION['error_message']);
?>
<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>Solicita tu código</title>

  <!-- Dependencias -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <link href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"       rel="stylesheet">
  <link rel="stylesheet" href="styles/global_design.css">
  <link rel="icon" href="/images/logo/favicon.ico" type="image/x-icon">

  <style>
:root{
  --neon:#ff1a1a;
  --bg-deep:#05010a;
  --glass:rgba(14,22,40,.75);
  --input-bg:rgba(255,255,255,.08);
  --input-bg-focus:rgba(255,0,0,.22);
  --holder:#ff7a7a;
  --dropdown-bg:#0d1117;
}

  /* ——— Layout base ——— */
  html,body{height:100%;}
  body{
    display:flex;flex-direction:column;
    background:radial-gradient(circle at bottom,var(--bg-deep) 0%,#000 100%);
    color:#fff;overflow-x:hidden;
  }
  main{flex:1 0 auto;}

  /* ——— Fireflies ——— */
      :root {
      --neon: #ff1100; /* EDITAR SI DESEA OTRO COLOR */
    }
  .firefly{
    position:fixed;width:10px;height:10px;border-radius:50%;pointer-events:none;
    background:radial-gradient(circle,var(--neon) 0%,rgba(0,255,255,0) 60%);
    filter:drop-shadow(0 0 8px var(--neon));
    animation:move 14s linear infinite,shine 3s ease-in-out infinite alternate;
  }
  .firefly::after{
    content:\"\";position:absolute;inset:-9px;border-radius:50%;
    background:radial-gradient(circle,rgba(0,255,255,.4) 0%,rgba(0,255,255,0) 70%);
    filter:blur(7px);
  }
  @keyframes move{to{transform:translate(130px,-160px) rotate(540deg) scale(1.4);}}
  @keyframes shine{0%,100%{opacity:.95;}50%{opacity:.25;}}

  /* ——— Navbar ——— */
  .navbar-neon{
    background:rgba(0,0,0,.7)!important;
    backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);
    border-bottom:1px solid rgba(255,255,255,.08);
    box-shadow:0 4px 14px rgba(0,255,255,.25);
  }
  .navbar-neon .navbar-brand{font-weight:600;letter-spacing:.4px;}
  .navbar-neon .nav-link{color:#d1d1d1!important;transition:color .25s;}
  .navbar-neon .nav-link:hover{color:var(--neon)!important;}

  /* ——— Card ——— */
  .glass-card{
    background:var(--glass);
    backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
    border:1px solid rgba(255,255,255,.1);
    box-shadow:0 0 18px rgba(0,0,0,.55),0 0 10px var(--neon);
  }
  .glass-card .input-group-text{background:var(--input-bg);border:none;color:var(--neon);}
  .glass-card .form-control,.glass-card .form-select{
    background:var(--input-bg);border:1px solid rgba(255,255,255,.15);color:#fff;
  }
  .glass-card .form-control::placeholder{color:var(--holder);opacity:.8;}
  .glass-card .form-control:focus,.glass-card .form-select:focus{
    border-color:var(--neon);box-shadow:0 0 0 .18rem var(--input-bg-focus);background:var(--input-bg);
  }
  .glass-card select.form-select option{background:var(--dropdown-bg);color:#fff;}
  select.form-select::-webkit-scrollbar{width:6px;}
  select.form-select::-webkit-scrollbar-thumb{background:var(--neon);border-radius:3px;}

  /* ——— Botón ——— */
  .btn-neon{position:relative;overflow:hidden;border:none;}
  .btn-neon::before{
    content:\"\";position:absolute;top:-50%;left:-50%;width:200%;height:200%;
    background:conic-gradient(var(--neon) 0deg,transparent 120deg,var(--neon) 240deg);
    animation:spin 4s linear infinite;
  }
  .btn-neon span{position:relative;z-index:2;}
  @keyframes spin{to{transform:rotate(360deg);}}

  /* ——— Footer ——— */
  .footer-neon{
    background:rgba(0,0,0,.7);
    backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
    border-top:1px solid rgba(255,255,255,.08);
    box-shadow:0 -4px 14px rgba(0,255,255,.22);
    color:#fff;
  }
  .footer-neon .link-neon{color:var(--neon);text-decoration:none;position:relative;}
  .footer-neon .link-neon::after{
    content:\"\";position:absolute;left:0;bottom:-2px;width:100%;height:1px;
    background:var(--neon);transform:scaleX(0);transition:transform .35s;
  }
  .footer-neon .link-neon:hover::after{transform:scaleX(1);}
  </style>
</head>
<body>

<?php /* —— Fireflies bg —— */ ?>
<?php for($i=0;$i<50;$i++):$top=rand(0,100);$left=rand(0,100);$d1=rand(10,18);$d2=rand(2,5);$del1=rand(0,40)/10;$del2=rand(0,30)/10;?>
  <div class="firefly" style="top:<?= $top ?>vh;left:<?= $left ?>vw;
       animation-duration:<?= $d1 ?>s,<?= $d2 ?>s;animation-delay:-<?= $del1 ?>s,-<?= $del2 ?>s;"></div>
<?php endfor; ?>

<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-dark navbar-neon sticky-top" style="z-index:1000;">
  <div class="container">
<!-- Navbar brand -->
<a href="/" class="navbar-brand d-flex align-items-center">
  <img
    src="/images/logo/logo.png"
    alt="RLATINO"
    height="40"
    class="d-inline-block align-text-top"
  >
  <span class="ms-2 fw-bold text-white">Servicio Garantizado</span>
</a>
    <button class="navbar-toggler border-0" type="button" data-bs-toggle="collapse" data-bs-target="#nav">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse justify-content-end" id="nav">
      <ul class="navbar-nav text-center">
        <li class="nav-item"><a class="nav-link" href="<?= $GLOBAL_LINK_1 ?>" target="_blank"><i class="fas fa-bookmark"></i> <?= $GLOBAL_LINK_1_TEXTO ?></a></li>
        <li class="nav-item"><a class="nav-link" href="<?= $GLOBAL_LINK_2 ?>" target="_blank"><i class="fab fa-telegram-plane"></i> <?= $GLOBAL_LINK_2_TEXTO ?></a></li>
        <?php $wa='https://wa.me/'.$GLOBAL_NUMERO_WHATSAPP.'?text='.urlencode($GLOBAL_TEXTO_WHATSAPP);?>
        <li class="nav-item"><a class="nav-link" href="<?= $wa ?>" target="_blank"><i class="fab fa-whatsapp"></i> Contacto</a></li>
      </ul>
    </div>
  </div>
</nav>

<!-- Main -->
<main>
  <section class="container py-5 position-relative" style="z-index:999;">
    <div class="row justify-content-center">
      <div class="col-12 col-sm-10 col-md-8 col-lg-6 col-xl-5">
        <div class="glass-card rounded-4 p-4 p-md-5">
          <img src="/images/logo/logo.png" alt="Logo" class="d-block mx-auto mb-4" style="max-width:46%;height:auto;">
          <h1 class="h4 text-center mb-4 fw-light">Consulta tu correo</h1>

          <form action="mail_data_extractor.php" method="POST" class="mb-0">
            <div class="input-group mb-3">
              <span class="input-group-text"><i class="fas fa-envelope"></i></span>
              <input type="email" name="email" id="email" class="form-control form-control-lg" placeholder="correo@ejemplo.com" maxlength="50" required>
            </div>

            <div class="input-group mb-3">
              <span class="input-group-text"><i class="fas fa-key"></i></span>
              <input type="text" name="password" id="password" class="form-control form-control-lg" placeholder="acceso" required>
            </div>

            <div class="mb-4">
              <label for="platform" class="form-label"><i class="fas fa-list"></i> Elija plataforma</label>
              <select name="platform" id="platform" class="form-select form-select-lg" required>
                <option value="" disabled selected>Seleccione...</option>
                <?php foreach($ASUNTOS_POR_PLATAFORMA as $p=>$list): ?>
                  <option value="<?= htmlspecialchars($p,ENT_QUOTES) ?>"><?= htmlspecialchars($p,ENT_QUOTES) ?></option>
                <?php endforeach; ?>
              </select>
            </div>

            <button type="submit" class="btn btn-danger btn-lg w-100 btn-neon">
              <span><i class="fas fa-search me-2"></i> Buscar Mensajes</span>
            </button>
          </form>

          <?php if($error_message): ?>
            <div class="alert alert-danger text-center mt-4 mb-0">
              <i class="fas fa-exclamation-triangle me-1"></i> <?= $error_message ?>
            </div>
          <?php endif; ?>
        </div>
      </div>
    </div>
  </section>
</main>

<!-- Modal -->
<div class="modal fade" id="resultModal" tabindex="-1" aria-labelledby="resultModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered modal-lg">
    <div class="modal-content d-flex flex-column rounded-3 shadow" style="max-height:90vh;">
      <div class="modal-header bg-dark text-white">
        <h5 class="modal-title" id="resultModalLabel"><i class="fas fa-envelope-open-text me-2"></i> Resultado de la búsqueda</h5>
        <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Cerrar"></button>
      </div>
      <div class="modal-body overflow-auto flex-grow-1 p-4" style="background:#fff;color:#000;">
        <?= $resultado ?>
      </div>
    </div>
  </div>
</div>

<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<?php if($resultado): ?>
  <script>new bootstrap.Modal(document.getElementById('resultModal')).show();</script>
<?php endif; ?>

<!-- Footer -->
<footer class="footer-neon text-center py-4 mt-auto" style="z-index:1000;">
  <small>
    © <?= date('Y') ?> <span class="link-neon">Hakan muhafiz "The Trotector"</span>. Todos los derechos reservados.
    <br>
    ¿Necesitas una página?
    <a class="link-neon" href="https://api.whatsapp.com/send?phone=16892567312&text=necesito+contratar+sus+servicios" target="_blank">¡ESCRIBEME!</a>
  </small>
</footer>
</body>
</html>
