<iframe srcdoc='
<style>
  body { font-family: Arial, sans-serif; margin: 0; padding: 0; background: #f8f9fb; }
  .container { max-width: 800px; margin: 40px auto; padding: 30px; background: white; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
  h2 { font-size: 26px; font-weight: 700; margin-bottom: 5px; }
  p.description { margin-bottom: 25px; font-size: 15px; color: #555; }
  label { display: block; margin-top: 15px; font-weight: 500; }
  input, textarea, select {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
  }
  .radio-group { margin-top: 8px; }
  .radio-group label { display: inline-block; margin-right: 20px; font-weight: normal; }
  button {
    margin-top: 25px;
    width: 100%;
    padding: 12px;
    background-color: #005a9c;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
  }
  button:hover { background-color: #004080; }
  .message { margin-top: 20px; text-align: center; font-size: 14px; color: #333; }
</style>

<div class="container">
  <h2>Police Station Representative Registration</h2>
  <p class="description">Please fill out this form to register as a Police Station Representative.</p>
  <form id="repForm">
    <label>First Name<input type="text" id="firstName" required></label>
    <label>Last Name<input type="text" id="lastName" required></label>
    <label>Email Address<input type="email" id="email" required></label>
    <label>Primary Phone Number<input type="tel" id="phone"></label>
    <label>County<input type="text" id="county"></label>
    <label>Town<input type="text" id="town"></label>
    <label>Area(s) Covered (e.g., London, West Midlands, all police stations)<input type="text" id="area"></label>
    <label>Stations Covered (if applicable)<textarea id="stations"></textarea></label>
    <label>Availability (e.g., 24/7, Mon-Fri 9-5, weekends only)<input type="text" id="availability"></label>
    <label>Date of Birth<input type="text" id="dob" placeholder="Day, month, year"></label>

    <label>Do you wish to be a member of the WhatsApp group?</label>
    <div class="radio-group">
      <label><input type="radio" name="whatsappGroup" value="Yes"> Yes</label>
      <label><input type="radio" name="whatsappGroup" value="No"> No</label>
    </div>

    <label>Pin Number (Need to prove you are a rep)!<input type="text" id="pinNumber"></label>
    <label>Any additional notes or information?<textarea id="notes"></textarea></label>
    <div style="display:none;"><label>Leave this blank:<input type="text" id="honeypot"></label></div>

    <button type="submit">Submit Registration</button>
    <div id="formMessage" class="message"></div>
  </form>

  <script>
    function submitRep() {
      const data = {
        firstName: document.getElementById("firstName").value,
        lastName: document.getElementById("lastName").value,
        email: document.getElementById("email").value,
        phone: document.getElementById("phone").value,
        county: document.getElementById("county").value,
        town: document.getElementById("town").value,
        area: document.getElementById("area").value,
        stations: document.getElementById("stations").value,
        availability: document.getElementById("availability").value,
        dob: document.getElementById("dob").value,
        whatsappGroup: document.querySelector('input[name="whatsappGroup"]:checked')?.value || "",
        pinNumber: document.getElementById("pinNumber").value,
        notes: document.getElementById("notes").value,
        honeypot: document.getElementById("honeypot").value
      };

      fetch("/_functions/registerRep", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(data)
      })
      .then(res => res.json())
      .then(response => {
        document.getElementById("formMessage").innerText = response.message || "Submitted successfully!";
      })
      .catch(error => {
        document.getElementById("formMessage").innerText = "Submission error: " + error.message;
      });
    }

    document.addEventListener("DOMContentLoaded", function () {
      const form = document.getElementById("repForm");
      if (form) {
        form.addEventListener("submit", function (e) {
          e.preventDefault();
          submitRep();
        });
      }
    });
  </script>
</div>' width="100%" height="2050px" style="border: none;"></iframe>