<?php
session_start();
$pag='login.php';
if (!file_exists('webcore/instld.wap'))
    header('Location: webcore/installation.php');
?>

<!DOCTYPE html>
<html lang="it">
<head>
  <meta charset="utf-8">
  <title>Upload Manager - Login</title>



  <?php include ('lib.php') ?>
  
  <style>
    body {
      background: #f8f9fa;
      min-height: 100vh; /* assicurati che prenda tutta l'altezza */
    }
    .login-card {
      width: 100%;
      max-width: 420px;
      padding: 30px;
      border-radius: 15px;
      box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    }
    .form-control:focus {
      box-shadow: 0 0 0 0.2rem rgba(13,110,253,.25);
    }
    .logo-login {
      width: 120px;
      margin-bottom: 15px;
    }
  </style>
</head>

<body>
<script type="text/javascript">
$(document).ready(function() {
  $('img#captcha-refresh').click(function() {
    change_captcha();
  });
  function change_captcha() {
    document.getElementById('captcha-img').src="get_captcha.php?rnd=" + Math.random();
  }
});
</script>

<div class="d-flex flex-column vh-100">
  <!-- HEADER opzionale -->
  <div id="header">
    <?php include("header.php"); ?>
  </div>

  <!-- CONTENUTO centrato -->
  <div id="content" class="flex-grow-1 d-flex align-items-center justify-content-center">
    <div class="login-card bg-white text-center">
      <!-- Logo centrato -->
      <img src="img/bitonlivelogo.png" alt="Logo" class="logo-login mx-auto d-block">

      <h3 class="mb-4">Login</h3>
      <form name="login" method="post" action="checkpwd.php">
        
        <div class="mb-3 text-start">
          <label for="utente" class="form-label">E-mail</label>
          <input type="text" name="utente" id="utente" class="form-control" placeholder="Inserisci la tua email" required>
        </div>
        
        <div class="mb-3 text-start">
          <label for="password" class="form-label">Password</label>
          <input type="password" name="password" id="password" class="form-control" placeholder="Inserisci la password" required>
        </div>

        <!-- Captcha disabilitato ma pronto -->
        <!--
        <div class="mb-3 text-start">
          <label class="form-label">Captcha</label>
          <div class="d-flex align-items-center mb-2">
            <img src="get_captcha.php" alt="captcha" id="captcha-img" class="me-2 rounded">
            <img src="img/refresh.jpg" alt="refresh" id="captcha-refresh" style="cursor:pointer; width:32px;">
          </div>
          <input name="captcha-code" type="text" id="captcha-code" class="form-control" placeholder="Inserisci le parole">
        </div>
        -->

        <?php if (isset($_GET['err']) && $_GET['err']==1): ?>
          <div class="alert alert-danger text-center" role="alert">
            Login fallito. Riprova.
          </div>
        <?php endif; ?>

        <div class="d-grid mt-5">
          <button type="submit" name="invia" class="btn btn-primary btn-lg rounded-pill">Login</button>
        </div>
      </form>
    </div>
  </div>

  <!-- FOOTER -->
  <div id="footer" class="footer text-center p-3">
    <?php //include("footer.php"); ?>
  </div>
</div>
</body>
</html>
