<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Become a Sponsor | Loveworld Trade & Investment Forum 2025</title>

  <link rel="icon" type="image/png" href="images/favicon.png">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="css/style.css?v=8" />
  <link rel="stylesheet" href="css/responsive.css?v=9" />
  <link rel="stylesheet" href="css/register.css?v=1.1" />
  <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap" rel="stylesheet">

  <style>
    #formMessage {
      margin-top: 20px;
      font-weight: 500;
    }
    .spinner-border {
      width: 1.2rem;
      height: 1.2rem;
    }
  </style>
</head>

<body>
  <!-- HERO -->
  <section class="register-hero d-flex align-items-center justify-content-center text-center">
    <div class="container position-relative text-white">
      <a href="index.php"> <img src="images/logo-light.png" alt="Logo" /> </a>
      <h1 class="fw-bold mb-3">Become a Sponsor</h1>
      <p class="lead">Partner with the Loveworld Trade & Investment Forum 2025</p>
    </div>
  </section>

  <!-- FORM -->
  <section class="sponsor-form py-5">
    <div class="container">
      <div class="form-container p-5">
        <h2 class="text-left mb-5">Sponsorship Application</h2>

        <form id="sponsorshipForm" method="POST">
          <!-- A. Organization Details -->
          <div class="form-section mb-5">
            <h4 class="section-title">A. Organization Details</h4>
            <div class="row g-4">
              <div class="col-md-6">
                <label class="form-label">Company / Name *</label>
                <input type="text" class="form-control" name="companyName" required>
              </div>
              <div class="col-md-6">
                <label class="form-label">Contact Person & Title</label>
                <input type="text" class="form-control" name="contactPersonAndTitle">
              </div>
              <div class="col-md-6">
                <label class="form-label">Email</label>
                <input type="email" class="form-control" name="email">
              </div>
              <div class="col-md-6">
                <label class="form-label">Phone</label>
                <input type="tel" class="form-control" name="phone">
              </div>
              <div class="col-md-6">
                <label class="form-label">Business City</label>
                <input type="text" class="form-control" name="businessCity">
              </div>
              <div class="col-md-6">
                <label class="form-label">Business Country</label>
                <input type="text" class="form-control" name="businessCountry">
              </div>
              <div class="col-md-6">
                <label class="form-label">Website</label>
                <input type="url" class="form-control" name="website">
              </div>
            </div>
          </div>

          <!-- B. Sponsorship Package Interest -->
          <div class="form-section mb-5">
            <h4 class="section-title">B. Sponsorship Package Interest</h4>
            <div class="row g-2">
              <div class="col-md-3 col-6">
                <input type="radio" name="packageInterest" value="PLATINUM" required> Platinum (Headline)
              </div>
              <div class="col-md-3 col-6">
                <input type="radio" name="packageInterest" value="GOLD"> Gold (Sector Sponsor)
              </div>
              <div class="col-md-3 col-6">
                <input type="radio" name="packageInterest" value="SILVER"> Silver (Brand Integration)
              </div>
              <div class="col-md-3 col-6">
                <input type="radio" name="packageInterest" value="MEDIA_TECH_SUPPORT"> Media / Tech Support
              </div>
              <div class="col-md-3 col-6">
                <input type="radio" name="packageInterest" value="CUSTOM"> Custom (specify)
              </div>
            </div>
            <input type="text" class="form-control mt-2" name="customPackageDetails" placeholder="If Custom, please specify details">
          </div>

          <!-- C. Preferred Sector -->
          <div class="form-section mb-5">
            <h4 class="section-title">C. Preferred Sector for Visibility</h4>
            <div class="row g-2">
              <div class="col-md-3 col-6"><input type="checkbox" name="preferredSectors[]" value="HEALTHCARE"> Healthcare</div>
              <div class="col-md-3 col-6"><input type="checkbox" name="preferredSectors[]" value="TECHNOLOGY"> Technology</div>
              <div class="col-md-3 col-6"><input type="checkbox" name="preferredSectors[]" value="FOOD_AGRICULTURE"> Food & Agriculture</div>
              <div class="col-md-3 col-6"><input type="checkbox" name="preferredSectors[]" value="ENERGY"> Energy</div>
              <div class="col-md-3 col-6"><input type="checkbox" name="preferredSectors[]" value="FINANCE"> Finance</div>
              <div class="col-md-3 col-6"><input type="checkbox" name="preferredSectors[]" value="EDUCATION"> Education</div>
              <div class="col-md-3 col-6"><input type="checkbox" name="preferredSectors[]" value="OTHER"> Other</div>
            </div>
            <input type="text" class="form-control mt-2" name="preferredSectorsOther" placeholder="If Other, specify">
          </div>

          <!-- D. Sponsorship Objectives -->
          <div class="form-section mb-5">
            <h4 class="section-title">D. Sponsorship Objectives / ROI</h4>
            <label class="form-label">Briefly describe your objectives (brand visibility, CSR, lead generation, etc.)</label>
            <textarea class="form-control" rows="4" name="objectivesRoi"></textarea>
          </div>

          <!-- E. Consent -->
          <div class="form-section mb-5">
            <div class="form-check mt-3">
              <input class="form-check-input" type="checkbox" required>
              <label class="form-check-label">
                I acknowledge the Forum terms and brand guidelines.
              </label>
            </div>
          </div>

          <!-- Submit -->
          <button type="submit" class="btn btn-primary px-5 py-3" id="submitBtn">
            <span id="btnText">Submit Sponsorship</span>
            <div class="spinner-border text-light ms-2 d-none" id="btnSpinner" role="status"></div>
          </button>

          <div id="formMessage" class="mt-4"></div>
        </form>
      </div>
    </div>
  </section>

  <?php include 'footer.php'; ?>

  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script>
  $(document).ready(function() {
    $('#sponsorshipForm').on('submit', function(e) {
      e.preventDefault();

      $('#btnSpinner').removeClass('d-none');
      $('#btnText').text('Submitting...');
      $('#submitBtn').prop('disabled', true);

      const formData = {};
      $(this).serializeArray().forEach(field => {
        if (formData[field.name]) {
          if (!Array.isArray(formData[field.name])) {
            formData[field.name] = [formData[field.name]];
          }
          formData[field.name].push(field.value);
        } else {
          formData[field.name] = field.value;
        }
      });

      $.ajax({
        url: 'api/auth-sponsor.php',
        type: 'POST',
        data: JSON.stringify(formData),
        contentType: 'application/json',
        dataType: 'json',
        success: function(response) {
          if (response.status === 'success') {
            window.location.href = 'success.php?type=sponsor';
          } else {
            $('#formMessage').html(`<div class="alert alert-danger">${response.message.errorMessage || 'Submission failed. Please try again.'}</div>`);
          }
        },
        error: function() {
          $('#formMessage').html(`<div class="alert alert-danger">Network error. Please try again later.</div>`);
        },
        complete: function() {
          $('#btnSpinner').addClass('d-none');
          $('#btnText').text('Submit Sponsorship');
          $('#submitBtn').prop('disabled', false);
        }
      });
    });
  });
  </script>

  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
