<?php
require_once __DIR__ . '/../../config/database.php';
$conn = getConnection();

$sql = "SELECT TOP 1 * FROM configuracion_sistema";
$stmt = sqlsrv_query($conn, $sql);
$config = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);

$nombre        = $config['nombre_plataforma'] ?? 'Sistema Integral para Importadores de Hidrocarburos';
$siglas        = $config['siglas'] ?? 'SIIH';
$logo          = $config['logo_url'] ?? 'assets/img/logo_siih.png';
$color1        = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')[0];
$color2        = explode(',', $config['colores_primarios'] ?? '#003366,#0055A5')[1];
?>

<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <title>Gracias por tu solicitud | <?= htmlspecialchars($siglas) ?></title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  <style>
    body { background-color: #f4f6f9; font-family: 'Segoe UI', sans-serif; text-align: center; padding-top: 100px; }
    .swal2-popup { font-size: 1.1rem !important; animation: fadeInUp 0.6s ease-out; }
    @keyframes fadeInUp {
      0% { transform: translateY(20px); opacity: 0; }
      100% { transform: translateY(0); opacity: 1; }
    }
  </style>
</head>
<body>

<script>
  document.addEventListener('DOMContentLoaded', function () {
    Swal.fire({
      icon: 'success',
      title: '¡Gracias por tu solicitud!',
      html: `<p>Tu información fue enviada correctamente.<br>Un agente aduanal revisará tu expediente y te contactará por correo.</p>`,
      confirmButtonText: 'Volver al inicio',
      confirmButtonColor: '<?= $color1 ?>',
      allowOutsideClick: false,
      allowEscapeKey: false
    }).then((result) => {
      if (result.isConfirmed) {
        window.location.href = '/IMPORTADORES/';
      }
    });
  });
</script>

</body>
</html>