<!-- views/proveedores/crear.php -->
<?php include __DIR__ . '/../partials/sidebar_importador.php'; ?>

<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <title>➕ Registro de Proveedor</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Bootstrap CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- SweetAlert2 -->
  <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  <style>
    body { font-family: 'Segoe UI', sans-serif; background-color: #f4f6f9; }
    .sidebar { width: 220px; height: 100vh; background-color: #343a40; position: fixed; top: 0; left: 0; padding-top: 56px; z-index: 1040; }
    .sidebar .nav-link { color: #ccc; padding: 12px 20px; }
    .sidebar .nav-link:hover,
    .sidebar .nav-link.active { background-color: #495057; color: #fff; }
    .content { margin-top: 56px; padding: 40px 20px; background-color: #f4f6f9; transition: margin-left .3s ease; }
    @media (min-width: 768px) { .content { margin-left: 250px; } }
    @media (max-width: 767.98px) { .content { margin-left: 0; } }
    .card { border-radius: 12px; }
  </style>
</head>
<body>

  <?php
    // Mostrar alerta si hay error en sesión
    if (!empty($_SESSION['flash_error'])):
  ?>
    <script>
      Swal.fire({
        icon: 'error',
        title: 'Error al registrar',
        text: '<?= addslashes($_SESSION['flash_error']) ?>'
      });
    </script>
  <?php
    unset($_SESSION['flash_error']);
    endif;
  ?>

  <div class="content">
    <h4 class="mb-4">➕ Registro de Proveedor</h4>
    <div class="card p-4 shadow-sm">
      <form action="/IMPORTADORES/proveedores/guardar" method="POST">
        <div class="row g-3">
          <div class="col-md-4">
            <label for="Clave" class="form-label">Clave *</label>
            <input type="text" name="Clave" id="Clave" class="form-control" required>
          </div>
          <div class="col-md-8">
            <label for="Nombre" class="form-label">Nombre *</label>
            <input type="text" name="Nombre" id="Nombre" class="form-control" required>
          </div>
          <div class="col-md-4">
            <label for="RFC" class="form-label">RFC *</label>
            <input type="text" name="RFC" id="RFC" class="form-control" required>
          </div>
          <div class="col-md-4">
            <label for="Ciudad" class="form-label">Ciudad *</label>
            <input type="text" name="Ciudad" id="Ciudad" class="form-control" required>
          </div>
          <div class="col-md-4">
            <label for="Telefono" class="form-label">Teléfono</label>
            <input type="tel" name="Telefono" id="Telefono" class="form-control">
          </div>
          <div class="col-md-6">
            <label for="Pais" class="form-label">País</label>
            <input type="text" name="Pais" id="Pais" class="form-control">
          </div>
          <div class="col-md-6">
            <label for="EntidadFederativa" class="form-label">Entidad Federativa</label>
            <input type="text" name="EntidadFederativa" id="EntidadFederativa" class="form-control">
          </div>
          <div class="col-md-4">
            <label for="Municipio" class="form-label">Municipio</label>
            <input type="text" name="Municipio" id="Municipio" class="form-control">
          </div>
          <div class="col-md-4">
            <label for="Colonia" class="form-label">Colonia</label>
            <input type="text" name="Colonia" id="Colonia" class="form-control">
          </div>
          <div class="col-md-4">
            <label for="CodigoPostal" class="form-label">Código Postal</label>
            <input type="text" name="CodigoPostal" id="CodigoPostal" class="form-control">
          </div>
        </div>
        <div class="mt-4 text-end">
          <a href="/IMPORTADORES/proveedores" class="btn btn-secondary me-2">Cancelar</a>
          <button type="submit" class="btn btn-primary">Guardar Proveedor</button>
        </div>
      </form>
    </div>
  </div>

  <!-- Bootstrap JS Bundle -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>

</body>
</html>