<?php
require_once 'conexao.php';

$sql = "SELECT id, nome FROM formularios ORDER BY id DESC";
$result = $conn->query($sql);
?>

<!DOCTYPE html>
<html lang="pt-BR">
<head>
  <meta charset="UTF-8">
  <title>Formulários Disponíveis</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      padding: 20px;
    }
    h2 {
      margin-bottom: 20px;
    }
    .formulario {
      background: #f9f9f9;
      padding: 12px;
      border: 1px solid #ccc;
      border-radius: 6px;
      margin-bottom: 12px;
    }
    .formulario a {
      text-decoration: none;
      color: #fff;
      background: #28a745;
      padding: 6px 12px;
      border-radius: 4px;
      font-size: 14px;
    }
  </style>
</head>
<body>

<h2>Formulários Disponíveis para Responder</h2>

<?php if ($result->num_rows > 0): ?>
  <?php while ($row = $result->fetch_assoc()): ?>
    <div class="formulario">
      <strong><?= htmlspecialchars($row['nome']) ?></strong><br><br>
      <a href="responder_formulario.php?id=<?= $row['id'] ?>">📋 Responder</a>
    </div>
  <?php endwhile; ?>
<?php else: ?>
  <p>Nenhum formulário disponível no momento.</p>
<?php endif; ?>
<script src="notificacoes_global.js"></script>
</body>
</html>
