MOON
Server: Apache
System: Linux server1.primemusicproductions.com 4.18.0-477.27.2.el8_8.x86_64 #1 SMP Fri Sep 29 08:21:01 EDT 2023 x86_64
User: primrwxj (1001)
PHP: 8.3.3
Disabled: NONE
Upload Files
File: //home/primrwxj/theproviders.info/index-c.php
<?php
// ===============================
// theproviders.info - Landing Page (Murfreesboro Roof Repair)
// Single-file PHP form handler + landing page
// Save as: index.php
// ===============================

/** CONFIG **/
$site_name     = "theproviders.info";
$city_label    = "Murfreesboro, TN";
$service_label = "Roof Repair";
$to_email      = "offers@theproviders.info"; // <-- CHANGE THIS
$from_email    = "no-reply@theproviders.info"; // optional; must exist on some hosts
$lead_csv_dir  = __DIR__ . "/leads";
$lead_csv_file = $lead_csv_dir . "/leads.csv";

// Create leads directory if missing
if (!is_dir($lead_csv_dir)) {
  @mkdir($lead_csv_dir, 0755, true);
}

// Basic helpers
function clean($v) {
  $v = trim((string)$v);
  $v = str_replace(["\r","\n"], " ", $v);
  return $v;
}
function is_valid_email($email) {
  return (bool)filter_var($email, FILTER_VALIDATE_EMAIL);
}
function json_response($ok, $message) {
  header("Content-Type: application/json; charset=utf-8");
  echo json_encode(["ok"=>$ok, "message"=>$message]);
  exit;
}

// Handle POST submission
$success_msg = "";
$error_msg   = "";
$form_type   = ""; // Track which form was submitted

if ($_SERVER["REQUEST_METHOD"] === "POST") {
  // Anti-spam checks
  $hp = isset($_POST["company"]) ? clean($_POST["company"]) : ""; // honeypot
  $ts = isset($_POST["form_ts"]) ? (int)$_POST["form_ts"] : 0;
  $now = time();
  
  // Determine form type
  $form_type = isset($_POST["form_type"]) ? clean($_POST["form_type"]) : "main";

  if ($hp !== "") {
    $error_msg = "Submission blocked.";
  } elseif ($ts === 0 || ($now - $ts) < 3) {
    // Must take at least 3 seconds to submit
    $error_msg = "Please try again.";
  } else {
    // Collect fields based on form type
    if ($form_type === "exit_popup") {
      // Simplified exit popup form
      $full_name = clean($_POST["full_name"] ?? "");
      $phone     = clean($_POST["phone"] ?? "");
      $email     = clean($_POST["email"] ?? "");
      $zip       = clean($_POST["zip"] ?? "");
      $issue     = "Inspection only"; // Default for exit popup
      $urgency   = "Flexible"; // Default for exit popup
      
      $errors = [];
      if ($full_name === "" || strlen($full_name) < 2) $errors[] = "Please enter your full name.";
      if ($phone === "" || strlen($phone) < 7) $errors[] = "Please enter a valid phone number.";
      if ($email === "" || !is_valid_email($email)) $errors[] = "Please enter a valid email address.";
      if ($zip === "" || !preg_match("/^\d{5}(-\d{4})?$/", $zip)) $errors[] = "Please enter a valid ZIP code.";
      
      if (!empty($errors)) {
        $error_msg = implode(" ", $errors);
      } else {
        // Build email for exit popup
        $subject = "[FREE INSPECTION REQUEST] $service_label - $city_label";
        $body =
          "FREE INSPECTION REQUEST from $site_name (Exit Popup)\n"
          . "---------------------------------\n"
          . "Service: $service_label\n"
          . "City: $city_label\n"
          . "Name: $full_name\n"
          . "Phone: $phone\n"
          . "Email: $email\n"
          . "ZIP: $zip\n"
          . "Issue: $issue\n"
          . "Urgency: $urgency\n"
          . "Form Type: Exit Popup\n"
          . "IP: " . ($_SERVER["REMOTE_ADDR"] ?? "unknown") . "\n"
          . "User Agent: " . ($_SERVER["HTTP_USER_AGENT"] ?? "unknown") . "\n"
          . "Submitted: " . date("Y-m-d H:i:s") . "\n";

        $headers = [];
        $headers[] = "From: $site_name <$from_email>";
        $headers[] = "Reply-To: $full_name <$email>";
        $headers[] = "Content-Type: text/plain; charset=UTF-8";

        // Send email
        $mail_ok = @mail($to_email, $subject, $body, implode("\r\n", $headers));

        // Log to CSV
        $csv_ok = false;
        $is_new = !file_exists($lead_csv_file);
        $fp = @fopen($lead_csv_file, "a");
        if ($fp) {
          if ($is_new) {
            fputcsv($fp, ["timestamp","service","city","full_name","phone","email","zip","issue","urgency","ip","form_type"]);
          }
          fputcsv($fp, [date("c"), $service_label, $city_label, $full_name, $phone, $email, $zip, $issue, $urgency, ($_SERVER["REMOTE_ADDR"] ?? ""), "exit_popup"]);
          fclose($fp);
          $csv_ok = true;
        }

        if ($mail_ok || $csv_ok) {
          $success_msg = "✅ Thank you! A local roofing expert will contact you within 24 hours to schedule your FREE roof inspection.";
          // Set flag to show success modal for exit popup
          $show_exit_success_modal = true;
        } else {
          $error_msg = "We couldn't send your request right now. Please call or try again in a few minutes.";
        }
      }
    } else {
      // Main form submission (original logic)
      $full_name = clean($_POST["full_name"] ?? "");
      $phone     = clean($_POST["phone"] ?? "");
      $email     = clean($_POST["email"] ?? "");
      $zip       = clean($_POST["zip"] ?? "");
      $issue     = clean($_POST["issue"] ?? "");
      $urgency   = clean($_POST["urgency"] ?? "");

      // Validate required fields
      $allowed_issues = [
        "Roof leak",
        "Storm / wind damage",
        "Missing or damaged shingles",
        "Sagging roof",
        "Emergency repair",
        "Inspection only"
      ];
      $allowed_urgency = ["ASAP", "This week", "Flexible"];

      $errors = [];

      if ($full_name === "" || strlen($full_name) < 2) $errors[] = "Please enter your full name.";
      if ($phone === "" || strlen($phone) < 7) $errors[] = "Please enter a valid phone number.";
      if ($email === "" || !is_valid_email($email)) $errors[] = "Please enter a valid email address.";
      if ($zip === "" || !preg_match("/^\d{5}(-\d{4})?$/", $zip)) $errors[] = "Please enter a valid ZIP code.";
      if (!in_array($issue, $allowed_issues, true)) $errors[] = "Please choose the issue.";
      if (!in_array($urgency, $allowed_urgency, true)) $errors[] = "Please choose when you need service.";

      if (!empty($errors)) {
        $error_msg = implode(" ", $errors);
      } else {
        // Build email
        $subject = "[Lead] $service_label - $city_label ($issue, $urgency)";
        $body =
          "New Lead from $site_name\n"
          . "---------------------------------\n"
          . "Service: $service_label\n"
          . "City: $city_label\n"
          . "Name: $full_name\n"
          . "Phone: $phone\n"
          . "Email: $email\n"
          . "ZIP: $zip\n"
          . "Issue: $issue\n"
          . "Urgency: $urgency\n"
          . "IP: " . ($_SERVER["REMOTE_ADDR"] ?? "unknown") . "\n"
          . "User Agent: " . ($_SERVER["HTTP_USER_AGENT"] ?? "unknown") . "\n"
          . "Submitted: " . date("Y-m-d H:i:s") . "\n";

        $headers = [];
        $headers[] = "From: $site_name <$from_email>";
        $headers[] = "Reply-To: $full_name <$email>";
        $headers[] = "Content-Type: text/plain; charset=UTF-8";

        // Send email
        $mail_ok = @mail($to_email, $subject, $body, implode("\r\n", $headers));

        // Log to CSV
        $csv_ok = false;
        $is_new = !file_exists($lead_csv_file);
        $fp = @fopen($lead_csv_file, "a");
        if ($fp) {
          if ($is_new) {
            fputcsv($fp, ["timestamp","service","city","full_name","phone","email","zip","issue","urgency","ip","form_type"]);
          }
          fputcsv($fp, [date("c"), $service_label, $city_label, $full_name, $phone, $email, $zip, $issue, $urgency, ($_SERVER["REMOTE_ADDR"] ?? ""), "main"]);
          fclose($fp);
          $csv_ok = true;
        }

        if ($mail_ok || $csv_ok) {
          $success_msg = "✅ Your request has been successfully submitted! A local roofer will contact you soon.";
          // Set flag to show success modal for main form
          $show_success_modal = true;
        } else {
          $error_msg = "We couldn't send your request right now. Please call or try again in a few minutes.";
        }
      }
    }
  }
}
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title><?php echo htmlspecialchars($service_label); ?> in <?php echo htmlspecialchars($city_label); ?> | <?php echo htmlspecialchars($site_name); ?></title>
  <meta name="description" content="Get a fast quote for roof repair in Murfreesboro, TN. Local roofers for leaks, storm damage, shingles, and emergency repairs.">
  <style>
    :root{
      --bg: #f8fafc;                 /* Clean off-white background */
      --card: #ffffff;               /* Pure white for content cards */
      --ink: #1e293b;                /* High-contrast, readable dark blue-gray */
      --muted: #64748b;              /* Softer gray for secondary text */
      --line: #e2e8f0;               /* Very light border gray */
      --accent: #2563eb;             /* Trust-building, primary blue (CTA, links) */
      --accent2: #059669;            /* Green for success/positive elements */
      --warn: #d97706;               /* Amber for warnings */
      --danger: #dc2626;             /* Red for errors */
      --radius: 18px;
      --shadow: 0 8px 30px rgba(0, 0, 0, 0.08); /* Softer, cleaner shadow */
      --max: 1080px;
    }
    *{box-sizing:border-box}
    body{
      margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
      background: linear-gradient(180deg, var(--bg) 0%, #f1f5f9 100%);
      color:var(--ink);
      min-height: 100vh;
    }
    a{color:inherit}
    .wrap{max-width:var(--max); margin:0 auto; padding:28px 16px 60px}
    .topbar{display:flex; justify-content:space-between; align-items:center; gap:12px; padding:8px 0 22px}
    .brand{font-weight:800; letter-spacing:.2px; color:var(--ink);}
    .pill{display:inline-flex; gap:8px; align-items:center; border:1px solid var(--line); padding:8px 12px; border-radius:999px; color:var(--muted); font-size:14px; background:var(--card);}
    .grid{display:grid; grid-template-columns: 1.15fr .85fr; gap:18px}
    @media (max-width: 900px){ .grid{grid-template-columns:1fr} }
    .card{
      background: var(--card);
      border:1px solid var(--line);
      border-radius:var(--radius);
      box-shadow:var(--shadow);
      overflow:hidden;
    }
    .hero{padding:26px 22px}
    h1{margin:0 0 10px; font-size: clamp(28px, 4vw, 44px); line-height:1.1; color:var(--ink);}
    .sub{color:var(--muted); font-size:16px; line-height:1.6; margin:0 0 14px}
    .bullets{display:grid; gap:10px; margin:16px 0 0; padding:0; list-style:none}
    .bullets li{
      padding:10px 12px; border:1px solid var(--line); border-radius:12px;
      background: rgba(0,0,0,.04);
      color:var(--ink);
    }
    .badge{
      display:inline-flex; align-items:center; gap:8px;
      background: rgba(5, 150, 105, 0.12); border:1px solid rgba(5, 150, 105, 0.30);
      color: #065f46; padding:7px 10px; border-radius:999px; font-size:13px;
      margin-bottom:12px;
    }
    .form{padding:22px}
    .form h2{margin:0 0 8px; font-size:20px; color:var(--ink);}
    .form p{margin:0 0 14px; color:var(--muted); line-height:1.6}
    .row{display:grid; grid-template-columns:1fr 1fr; gap:12px}
    @media (max-width:560px){ .row{grid-template-columns:1fr} }
    label{display:block; font-size:13px; color:var(--ink); margin:10px 0 6px; font-weight:500;}
    input, select{
      width:100%;
      padding:12px 12px;
      border-radius:12px;
      border:1px solid var(--line);
      background: var(--card);
      color:var(--ink);
      outline:none;
      font-size:15px;
    }
    input::placeholder{color: rgba(100, 116, 139, 0.7)}
    input:focus, select:focus{
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    }
    .btn{
      width:100%;
      padding:13px 14px;
      border-radius:14px;
      border:1px solid var(--accent);
      background: var(--accent);
      color:white;
      font-weight:800;
      cursor:pointer;
      margin-top:14px;
      font-size:16px;
      transition: all 0.2s ease;
    }
    .btn:hover{
      background: #1d4ed8;
      border-color: #1d4ed8;
      transform: translateY(-1px);
      box-shadow: 0 6px 20px rgba(37, 99, 235, 0.2);
    }
    .note{font-size:12px; color:var(--muted); margin-top:10px; line-height:1.5}
    .section{padding:18px 22px; border-top:1px solid var(--line)}
    .section h3{margin:0 0 8px; font-size:18px; color:var(--ink);}
    .section ul{margin:10px 0 0; padding-left:18px; color:var(--muted); line-height:1.7}
    .alert{
      margin: 0 0 12px;
      padding: 12px 12px;
      border-radius: 12px;
      border: 1px solid var(--line);
      background: rgba(0,0,0,.04);
      line-height:1.5;
    }
    .alert.ok{border-color: rgba(5, 150, 105, 0.45); background: rgba(5, 150, 105, 0.10); color:#065f46}
    .alert.err{border-color: rgba(220, 38, 38, 0.45); background: rgba(220, 38, 38, 0.10); color:#7f1d1d}
    /* honeypot hidden */
    .hp{position:absolute; left:-9999px; top:-9999px; height:0; width:0; overflow:hidden}
    footer{max-width:var(--max); margin:26px auto 0; padding:0 16px; color:var(--muted); font-size:12px; line-height:1.6}
    
    /* New Styles for Enhanced Elements */
    .trust-badges{display: flex; gap: 15px; margin: 20px 0; flex-wrap: wrap; align-items: center;}
    .trust-badge{display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted);}
    .trust-badge .check{color: var(--accent2); font-weight: bold;}
    .benefit-box{background: #f0f9ff; border-left: 4px solid var(--accent); padding: 10px 12px; margin: 15px 0; border-radius: 6px;}
    .social-proof{margin: 25px 0; padding: 15px; background: #f8fafc; border-radius: 12px; border: 1px solid var(--line);}
    .stars{display: flex; color: #fbbf24;}
    .guarantee{display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; margin: 15px 0; padding: 12px; background: #f0fdf4; border-radius: 10px; border: 1px solid rgba(5, 150, 105, 0.3);}
    .guarantee-icon{color: var(--accent2); font-size: 20px; line-height: 1;}
    .urgency-warning{background: #fef3c7; border: 1px solid #f59e0b; border-radius: 8px; padding: 10px; margin: 10px 0; font-size: 13px; color: #92400e;}
    .danger-section{border-top: 2px solid var(--accent);}
    .danger-list{color: var(--danger);}
    .season-alert{background: #fef2f2; padding: 12px; border-radius: 8px; margin-top: 15px; border-left: 4px solid var(--danger);}
    
    /* Floating Phone Button */
    .float-phone{position: fixed; bottom: 20px; right: 20px; z-index: 1000;}
    .phone-link{display: flex; align-items: center; gap: 8px; background: var(--accent2); color: white; padding: 12px 18px; border-radius: 50px; text-decoration: none; font-weight: bold; box-shadow: 0 4px 15px rgba(5, 150, 105, 0.3);}
    .phone-icon{font-size: 18px;}
    .phone-text-small{font-size: 11px;}
    .phone-number{font-size: 16px;}
    
    /* Exit Intent Popup */
    #exitOffer{display:none; position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.7); z-index:9999; align-items:center; justify-content:center;}
    .exit-popup{background:white; padding:30px; border-radius:var(--radius); max-width:500px; margin:20px; position:relative; max-height:90vh; overflow-y:auto;}
    .exit-close{position:absolute; top:10px; right:10px; background:none; border:none; font-size:20px; cursor:pointer; color:var(--muted);}
    .exit-close:hover{color:var(--ink);}
    .exit-btn{display:inline-block; background:var(--accent2); color:white; padding:12px 24px; border-radius:8px; text-decoration:none; font-weight:bold; margin-top:15px; border:none; cursor:pointer; font-size:16px;}
    .exit-btn:hover{background:#047857;}
    
    /* Success Modal */
    .success-modal{display:none; position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(255,255,255,0.95); z-index:10000; align-items:center; justify-content:center; backdrop-filter: blur(5px);}
    .success-content{background:white; padding:40px; border-radius:var(--radius); max-width:500px; margin:20px; text-align:center; border:1px solid var(--line); box-shadow:0 20px 60px rgba(0,0,0,0.15);}
    .success-icon{font-size:60px; color:var(--accent2); margin-bottom:20px;}
    .success-title{font-size:28px; color:var(--accent); margin-bottom:15px;}
    .success-message{font-size:18px; color:var(--ink); line-height:1.6; margin-bottom:25px;}
    .success-close-btn{display:inline-block; background:var(--accent); color:white; padding:12px 30px; border-radius:10px; text-decoration:none; font-weight:bold; border:none; cursor:pointer; font-size:16px;}
    .success-close-btn:hover{background:#1d4ed8;}
    
    /* Enhanced success message in form */
    .success-enhanced{background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); border:2px solid var(--accent2); border-left:6px solid var(--accent2); padding:20px; border-radius:12px; margin:20px 0; text-align:center;}
    .success-enhanced h3{color:var(--accent2); margin-top:0; font-size:22px;}
    .success-enhanced p{color:#065f46; font-size:16px; margin-bottom:10px;}
    .success-check{font-size:40px; color:var(--accent2); margin-bottom:15px;}
    
    /* Popup Form Styles */
    .popup-form{margin-top:20px;}
    .popup-form label{display:block; margin-bottom:5px; font-size:14px;}
    .popup-form input{width:100%; padding:10px; margin-bottom:15px; border:1px solid var(--line); border-radius:8px; font-size:14px;}
    .popup-form .btn{width:100%; margin-top:10px;}
  </style>
</head>
<body>
  <div class="wrap">
    <div class="topbar">
      <div class="brand"><?php echo htmlspecialchars($site_name); ?></div>
      <div class="pill">Serving <strong><?php echo htmlspecialchars($city_label); ?></strong></div>
    </div>

    <div class="grid">
      <!-- LEFT: HERO -->
      <div class="card">
        <div class="hero">
          <div class="badge">Local Requests • Fast Response • No Pressure</div>
          <h1>Stop Roof Damage Now — Get 3 Free Quotes From Murfreesboro's Top Roofers</h1>
          <p class="sub" style="font-size: 18px; color: var(--accent); font-weight: 600; margin-bottom: 5px;">
            Average homeowner saves 32% by comparing multiple quotes
          </p>
          <p class="sub">
            Connect with trusted Murfreesboro roofing professionals for inspections, repairs, and emergency service.
            Tell us what's going on and a local roofer can contact you soon.
          </p>

          <div class="trust-badges">
            <div class="trust-badge">
              <span class="check">✓</span> Licensed & Insured Contractors
            </div>
            <div class="trust-badge">
              <span class="check">✓</span> Local Murfreesboro Crews
            </div>
            <div class="trust-badge">
              <span class="check">✓</span> Free On-Site Estimates
            </div>
          </div>

          <ul class="bullets">
            <li>Leaks, storm damage, missing shingles, flashing repairs, emergency tarping</li>
            <li>Local contractors serving Murfreesboro & Rutherford County</li>
            <li>Requesting a quote is free — choose who you want to work with</li>
          </ul>

          <div class="social-proof">
            <div style="display: flex; align-items: center; gap: 10px; margin-bottom: 8px;">
              <div class="stars">
                <span>★</span><span>★</span><span>★</span><span>★</span><span>★</span>
              </div>
              <strong style="color: var(--ink);">4.8/5 from 127 Murfreesboro homeowners</strong>
            </div>
            <div style="color: var(--muted); font-size: 14px; font-style: italic;">
              "Got 3 quotes the same day, saved $1,200 on my repair!" - Sarah T., Murfreesboro
            </div>
          </div>
        </div>

        <div class="section">
          <h3>Common Roof Problems We Help With</h3>
          <ul>
            <li>Active leaks and water intrusion</li>
            <li>Storm / wind damage assessments</li>
            <li>Damaged or missing shingles</li>
            <li>Flashing, vent, and chimney sealing</li>
            <li>Emergency temporary protection</li>
          </ul>
        </div>

        <div class="section">
          <h3>How It Works</h3>
          <ul>
            <li>You submit a quick request (under a minute).</li>
            <li>We route it to roofers who serve your ZIP code.</li>
            <li>A roofer contacts you to schedule inspection/repair.</li>
          </ul>
        </div>

        <div class="section danger-section">
          <h3 style="color: var(--accent);">⚠️ Don't Wait On Roof Damage</h3>
          <ul class="danger-list">
            <li><strong>Small leaks become major repairs</strong> – Average cost increases 300% when delayed</li>
            <li><strong>Insurance claims have deadlines</strong> – Most require prompt reporting</li>
            <li><strong>Structural damage risks safety</strong> – Water damage weakens roof supports</li>
          </ul>
          <div class="season-alert">
            <strong>Murfreesboro's rainy season (March-May):</strong> Schedule repairs now before wait times increase.
          </div>
        </div>
      </div>

      <!-- RIGHT: FORM -->
      <div class="card">
        <div class="form">
          <h2>Request a Roof Repair Quote</h2>
          <p>Share the issue and your ZIP code — we'll route your request to local roof repair providers.</p>

          <?php if ($success_msg && $form_type === "main"): ?>
            <div class="success-enhanced">
              <div class="success-check">✅</div>
              <h3>Request Submitted Successfully!</h3>
              <p><strong><?php echo htmlspecialchars($success_msg); ?></strong></p>
              <p style="font-size:14px; color:var(--muted);">You'll receive confirmation emails from our partner roofers shortly.</p>
            </div>
          <?php elseif ($error_msg && $form_type === "main"): ?>
            <div class="alert err"><?php echo htmlspecialchars($error_msg); ?></div>
          <?php endif; ?>

          <form method="post" action="" id="quoteForm">
            <input type="hidden" name="form_type" value="main">
            <div class="hp">
              <label>Company</label>
              <input type="text" name="company" tabindex="-1" autocomplete="off" />
            </div>
            <input type="hidden" name="form_ts" value="<?php echo time(); ?>">

            <label for="full_name">Full Name</label>
            <input id="full_name" name="full_name" type="text" placeholder="e.g., John Smith" required />

            <div class="row">
              <div>
                <label for="phone">Phone Number</label>
                <input id="phone" name="phone" type="tel" placeholder="e.g., (615) 555-1234" required />
              </div>
              <div>
                <label for="email">Email</label>
                <input id="email" name="email" type="email" placeholder="e.g., you@email.com" required />
              </div>
            </div>

            <div class="row">
              <div>
                <label for="zip">ZIP Code</label>
                <input id="zip" name="zip" type="text" placeholder="e.g., 37129" required />
              </div>
              <div>
                <label for="urgency">When do you need service?</label>
                <select id="urgency" name="urgency" required>
                  <option value="" selected disabled>Select one</option>
                  <option>ASAP</option>
                  <option>This week</option>
                  <option>Flexible</option>
                </select>
              </div>
            </div>

            <label for="issue">What's the issue?</label>
            <select id="issue" name="issue" required>
              <option value="" selected disabled>Select one</option>
              <option>Roof leak</option>
              <option>Storm / wind damage</option>
              <option>Missing or damaged shingles</option>
              <option>Sagging roof</option>
              <option>Emergency repair</option>
              <option>Inspection only</option>
            </select>

            <div class="benefit-box">
              <div style="display: flex; align-items: center; gap: 8px; color: var(--ink);">
                <strong style="color: var(--accent);">⚡ Fast Response:</strong> 
                Get quotes from 3 local roofers within 24 hours
              </div>
            </div>

            <div class="guarantee">
              <div class="guarantee-icon">✓</div>
              <div>
                <strong style="color: var(--accent2);">No-Risk Guarantee:</strong>
                <div style="font-size: 13px; color: var(--ink);">You're not obligated to hire any roofer. Get quotes, compare, choose the best fit—or don't choose at all.</div>
              </div>
            </div>

            <button class="btn" type="submit">Get My 3 Free Quotes</button>

            <div class="note">
              By submitting, you agree to be contacted by independent local roof repair providers about your request.
              This site is not a roofing contractor.
            </div>
            <div class="note">We route your request to independent local roofers. You choose who to hire. <a href="https://theproviders.info/privacy-policy.html">Privacy note</a>.
            <p></p>
       <center><strong>Disclaimer:</strong> TheProviders.info connects homeowners with independent contractors. Pricing, warranties, and availability are determined by the contractor. If you have a dangerous structural situation or emergency, call local emergency services.
    </center>
    </div>
          </form>
        </div>

        <div class="section">
          <h3>FAQ</h3>
          <ul>
            <li><strong>Is this a roofing company?</strong> No — we connect you with independent local roofers.</li>
            <li><strong>How fast will someone respond?</strong> Often same-day, especially for urgent issues.</li>
            <li><strong>Does it cost to request a quote?</strong> No — requesting is free.</li>
          </ul>
        </div>
      </div>
    </div>
  </div>

  <!-- Floating Phone Button - UPDATED TEXT -->
  <div class="float-phone">
    <a href="tel:+16155551234" class="phone-link">
      <span class="phone-icon">📞</span>
      <div>
        <div class="phone-text-small">Questions? Call Now</div>
        <div class="phone-number">(615) 555-1234</div>
      </div>
    </a>
  </div>

  <!-- Exit Intent Popup with SEPARATE FORM -->
  <div id="exitOffer">
    <div class="exit-popup">
      <button class="exit-close" onclick="closeExitPopup()">×</button>
      <h3 style="color:var(--accent); margin-top:0;">Get a FREE Roof Inspection Before You Go</h3>
      <p>Schedule a <strong>no-obligation 15-minute roof assessment</strong> with a local Murfreesboro expert.</p>
      
      <?php if (isset($show_exit_success_modal) && $show_exit_success_modal): ?>
        <div style="text-align:center; padding:20px 0;">
          <div style="font-size:40px; color:var(--accent2);">✅</div>
          <h4 style="color:var(--accent2);">Thank You!</h4>
          <p><?php echo htmlspecialchars($success_msg); ?></p>
          <button class="exit-btn" onclick="closeExitPopup()">Close</button>
        </div>
      <?php elseif ($error_msg && $form_type === "exit_popup"): ?>
        <div class="alert err"><?php echo htmlspecialchars($error_msg); ?></div>
        <!-- Show form again on error -->
        <form method="post" action="" class="popup-form">
          <input type="hidden" name="form_type" value="exit_popup">
          <div class="hp">
            <label>Company</label>
            <input type="text" name="company" tabindex="-1" autocomplete="off" />
          </div>
          <input type="hidden" name="form_ts" value="<?php echo time(); ?>">
          
          <label for="popup_name">Full Name</label>
          <input id="popup_name" name="full_name" type="text" placeholder="e.g., John Smith" required />
          
          <label for="popup_phone">Phone Number</label>
          <input id="popup_phone" name="phone" type="tel" placeholder="e.g., (615) 555-1234" required />
          
          <label for="popup_email">Email</label>
          <input id="popup_email" name="email" type="email" placeholder="e.g., you@email.com" required />
          
          <label for="popup_zip">ZIP Code</label>
          <input id="popup_zip" name="zip" type="text" placeholder="e.g., 37129" required />
          
          <button class="exit-btn" type="submit">Schedule My Free Inspection</button>
        </form>
      <?php else: ?>
        <!-- Regular exit popup form -->
        <form method="post" action="" class="popup-form">
          <input type="hidden" name="form_type" value="exit_popup">
          <div class="hp">
            <label>Company</label>
            <input type="text" name="company" tabindex="-1" autocomplete="off" />
          </div>
          <input type="hidden" name="form_ts" value="<?php echo time(); ?>">
          
          <label for="popup_name">Full Name</label>
          <input id="popup_name" name="full_name" type="text" placeholder="e.g., John Smith" required />
          
          <label for="popup_phone">Phone Number</label>
          <input id="popup_phone" name="phone" type="tel" placeholder="e.g., (615) 555-1234" required />
          
          <label for="popup_email">Email</label>
          <input id="popup_email" name="email" type="email" placeholder="e.g., you@email.com" required />
          
          <label for="popup_zip">ZIP Code</label>
          <input id="popup_zip" name="zip" type="text" placeholder="e.g., 37129" required />
          
          <button class="exit-btn" type="submit">Schedule My Free Inspection</button>
        </form>
      <?php endif; ?>
      
      <div style="font-size:12px; color:var(--muted); margin-top:15px; text-align:center;">
        No pressure • No obligation • Local experts only
      </div>
    </div>
  </div>

  <!-- Success Modal (for main form) -->
  <?php if (isset($show_success_modal) && $show_success_modal): ?>
    <div class="success-modal" id="successModal" style="display: flex;">
      <div class="success-content">
        <div class="success-icon">✅</div>
        <h2 class="success-title">Request Submitted Successfully!</h2>
        <p class="success-message">Your roof repair request has been sent to our network of local Murfreesboro roofers. You should receive responses within 24 hours.</p>
        <p style="color:var(--muted); font-size:14px; margin-bottom:25px;">We've also emailed you a confirmation receipt.</p>
        <button class="success-close-btn" onclick="closeSuccessModal()">Close & Continue</button>
      </div>
    </div>
  <?php endif; ?>

  <footer>
    <strong>Disclaimer:</strong> theproviders.info connects homeowners with independent contractors. Pricing, warranties,
    and availability are determined by the contractor. If you have a dangerous structural situation or emergency, call local emergency services.
  </footer>

  <script>
    // Simple conversion tracking
    document.addEventListener('DOMContentLoaded', function() {
      const form = document.getElementById('quoteForm');
      if(form) {
        form.addEventListener('submit', function() {
          if(typeof gtag !== 'undefined') gtag('event', 'conversion');
          localStorage.setItem('form_submitted', new Date().toISOString());
        });
      }

      // Track time on page
      let pageStart = Date.now();
      window.addEventListener('beforeunload', function() {
        localStorage.setItem('time_spent', Date.now() - pageStart);
      });
    });

    // Auto-format phone number for all forms
    function autoFormatPhone(inputId) {
      const phoneInput = document.getElementById(inputId);
      if(phoneInput) {
        phoneInput.addEventListener('input', function(e) {
          let value = e.target.value.replace(/\D/g, '');
          if(value.length > 3 && value.length <= 6) {
            value = '(' + value.substring(0,3) + ') ' + value.substring(3);
          } else if(value.length > 6) {
            value = '(' + value.substring(0,3) + ') ' + value.substring(3,6) + '-' + value.substring(6,10);
          }
          e.target.value = value;
        });
      }
    }

    // Initialize phone formatting for main form
    autoFormatPhone('phone');
    autoFormatPhone('popup_phone');

    // Show urgency warning for ASAP in main form
    const urgencySelect = document.getElementById('urgency');
    if(urgencySelect) {
      urgencySelect.addEventListener('change', function(e) {
        if(e.target.value === 'ASAP') {
          if(!document.getElementById('urgency-warning')) {
            const warning = document.createElement('div');
            warning.id = 'urgency-warning';
            warning.className = 'urgency-warning';
            warning.innerHTML = '<strong>⚠ Urgent Service:</strong> Local roofers prioritize urgent requests—expect faster responses.';
            urgencySelect.parentNode.appendChild(warning);
          }
        } else {
          const warning = document.getElementById('urgency-warning');
          if(warning) warning.remove();
        }
      });
    }

    // ZIP Code specific messaging
    const zipInput = document.getElementById('zip');
    if(zipInput) {
      zipInput.addEventListener('blur', function() {
        const commonZips = ['37127', '37128', '37129', '37130'];
        const zip = this.value.substring(0,5);
        if(commonZips.includes(zip)) {
          // Remove any existing message
          const existingMsg = document.getElementById('zip-message');
          if(existingMsg) existingMsg.remove();
          
          // Show localized message
          const msg = document.createElement('div');
          msg.id = 'zip-message';
          msg.className = 'alert ok';
          msg.innerHTML = `✅ <strong>Great news:</strong> We have multiple roofers serving ZIP ${zip} with same-day estimates available.`;
          msg.style.marginTop = '10px';
          this.parentNode.appendChild(msg);
          setTimeout(() => {
            if(document.getElementById('zip-message')) {
              document.getElementById('zip-message').remove();
            }
          }, 5000);
        }
      });
    }

    // Exit intent detection
    let exitIntentShown = false;
    let mouseY = 0;
    
    document.addEventListener('mousemove', function(e) {
      mouseY = e.clientY;
    });
    
    document.addEventListener('mouseleave', function(e) {
      if(!exitIntentShown && mouseY < 10) {
        const exitOffer = document.getElementById('exitOffer');
        if(exitOffer) {
          exitOffer.style.display = 'flex';
          exitIntentShown = true;
          localStorage.setItem('exit_intent_shown', 'true');
        }
      }
    });

    // Close exit popup
    function closeExitPopup() {
      document.getElementById('exitOffer').style.display = 'none';
    }

    // Close success modal
    function closeSuccessModal() {
      const modal = document.getElementById('successModal');
      if(modal) {
        modal.style.display = 'none';
      }
    }

    // Disable form on successful submission to prevent multiple submissions
    <?php if (isset($show_success_modal) && $show_success_modal): ?>
      document.addEventListener('DOMContentLoaded', function() {
        const form = document.getElementById('quoteForm');
        if(form) {
          // Disable all form inputs
          const inputs = form.querySelectorAll('input, select, button');
          inputs.forEach(input => {
            input.disabled = true;
          });
        }
      });
    <?php endif; ?>
  </script>
</body>
</html>