<?php
/**
 * Footer â€” site-wide footer + back-to-top + scripts.
 */
?>
<footer>
  <div class="foot-top">
      
       <div>
      <svg class="foot-logo-svg" viewBox="0 0 680 420" xmlns="http://www.w3.org/2000/svg">
        <defs>
          <linearGradient id="fBg" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="#070F1A"/><stop offset="100%" stop-color="#0F2237"/></linearGradient>
          <linearGradient id="fStr" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" stop-color="#0050E6" stop-opacity="0"/><stop offset="30%" stop-color="#0050E6"/><stop offset="70%" stop-color="#00BAFF"/><stop offset="100%" stop-color="#00BAFF" stop-opacity="0"/></linearGradient>
        </defs>
        <rect x="2" y="2" width="676" height="416" rx="32" fill="url(#fBg)"/>
        <path d="M 400 420 Q 580 280 680 80 L 680 420 Z" fill="#00BAFF" fill-opacity="0.04"/>
        <rect x="0" y="68" width="682" height="72" fill="#000" fill-opacity="0.5"/>
        <rect x="0" y="68" width="682" height="2" fill="url(#fStr)"/>
        <rect x="52" y="86" width="480" height="36" rx="4" fill="#EFF6FF" fill-opacity="0.92"/>
        <rect x="52" y="180" width="68" height="52" rx="8" fill="#FFAA00"/>
        <line x1="52" y1="198" x2="120" y2="198" stroke="#070F1A" stroke-width="1.2" stroke-opacity="0.4"/>
        <line x1="52" y1="210" x2="120" y2="210" stroke="#070F1A" stroke-width="1.2" stroke-opacity="0.4"/>
        <line x1="52" y1="222" x2="120" y2="222" stroke="#070F1A" stroke-width="1.2" stroke-opacity="0.4"/>
        <line x1="84" y1="180" x2="84" y2="232" stroke="#070F1A" stroke-width="1.2" stroke-opacity="0.4"/>
        <g transform="translate(52,268)"><polygon points="0,18 38,18 38,0 62,28 38,56 38,38 0,38" fill="#FF6B2B"/></g>
        <text x="132" y="314" font-family="DM Sans,Helvetica Neue,sans-serif" font-size="54" font-weight="300" fill="#EFF6FF" letter-spacing="-1">merchant</text>
        <text x="132" y="370" font-family="Oswald,Impact,sans-serif" font-size="54" font-weight="700" fill="#00BAFF" letter-spacing="6">PRO</text>
        <rect x="490" y="272" width="164" height="52" rx="8" fill="rgba(0,80,230,0.15)" stroke="#0050E6" stroke-width="1.2" stroke-opacity="0.5"/>
        <text x="572" y="292" font-family="Oswald,sans-serif" font-size="10" font-weight="600" fill="#00BAFF" text-anchor="middle" letter-spacing="2">VISA CERTIFIED</text>
        <text x="572" y="310" font-family="DM Sans,sans-serif" font-size="13" font-weight="700" fill="#FFAA00" text-anchor="middle" letter-spacing="1">33 YEARS</text>
        <text x="572" y="325" font-family="DM Sans,sans-serif" font-size="9" font-weight="400" fill="#6B84A0" text-anchor="middle" letter-spacing="1.5">NATIONALLY RECOGNIZED</text>
        <text x="52" y="252" font-family="Courier New,monospace" font-size="18" font-weight="700" fill="#EFF6FF" fill-opacity="0.2" letter-spacing="6">•••• •••• •••• ••••</text>
        <rect x="2" y="2" width="676" height="416" rx="32" fill="none" stroke="#0050E6" stroke-opacity="0.45" stroke-width="1.5"/>
      </svg>
      <p class="foot-bio">Merchant Processing Solutions, Inc. · 3003 Tamiami Trail N., Third Floor, Naples, FL 34103 · Founded 2007 · Visa Certified since 1992</p>
      <div style="margin-top:14px"><a href="tel:8885731133" style="font-family:'Bebas Neue',sans-serif;font-size:1.2rem;letter-spacing:2px;color:var(--sky);text-decoration:none">📞 888-573-1133</a></div>
    </div>
    
    
    

    <div class="foot-col">
      <h4>Services</h4>
      <?php merchantpro_footer_menu( 'footer_services', array(
        ' Zero Fee Program' => '/practically-zero-fee/',
        'POS Systems'        => '/point-of-sale/',
        'Payment Processing'           => '/payment-processing-usa/',
        'Instant Capital'              => '/instant-capital/', 
        'ATM Services'                 => '/atm/',
        'REV Loyalty Program'          => '/rev-program/',
        
      ) ); ?>
    </div>
    
       <div class="foot-col">
      <h4>Company</h4>
      <?php merchantpro_footer_menu( 'footer_company', array(
        'About Us'           => '/about-us/',
        'Testimonials'       => '/testimonials/',
        'Reviews'            => '/reviews/',
        'Success Stories'    => '/success-stories/',
        'Careers'            => '/careers/',
        'Philanthropy'       => '/philanthropy/',
        'FAQ'                => '/faq/',
        'Contact'            => '/contact-us/',
      ) ); ?>
    </div>
    
    
   <!-- <div class="foot-col">
      <h4>Business Types</h4>
      <?php merchantpro_footer_menu( 'footer_business', array(
        'Restaurant'             => '/restaurant/',
        'Retail Merchant'        => '/retail-merchant-services/',
        'Gas Station / C-Store'  => '/convenience-store-merchant-services/',
        'Salon &amp; Barber Shop'    => '/salon-and-barber-shop/',
        'Hotel &amp; Hospitality'    => '/hotel-and-hospitality/',
        'Bar / Nightclub'        => '/bar-or-night-club/',
        'Grocery'                => '/grocery/',
        'Food Truck'             => '/food-truck/',
      ) ); ?>
    </div> -->
    
    
      <div class="foot-col">
    <h4>Get Started</h4>
    <a href="tel:8885731133">Call 888-573-1133</a>
    <a href="#pricing">Pricing</a><a href="#cta">Free Analysis</a>
    <a href="#calculator">Savings Calculator</a>
    <a href="mailto:corpaccounts@merchantproinc.com">Email Gary</a>
    </div>
    
    
    
 
  </div>
  <div class="foot-divider"></div>
  <div class="foot-bottom">
    <div class="foot-copy">Serving businesses nationwide · Florida · Georgia · California · Maryland</div>
  </div>
  
  <div class="foot-disclosure">
    Merchant Processing Solutions, Inc. is a registered ISO of PNC Bank, N.A., Pittsburgh, PA – Member FDIC. *American Express may require separate approval. **Based on approved credit. Copyright © 2026 All rights reserved.
  </div>
  
</footer>

<button id="btt" onclick="window.scrollTo({top:0,behavior:'smooth'})" class="show">↑</button>

<!-- CHAT -->
<!-- <button id="max-btn" onclick="toggleChat()" aria-label="Chat with MAX">
  <div id="max-dot"></div>
  <svg viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>
</button> -->
<div id="max-window">
  <div id="max-header">
    <div class="max-avatar">MAX</div>
    <div class="max-info"><div class="name">MAX — Merchant Pro AI</div><div class="role">Processing Expert</div></div>
    <div class="max-status"><div class="max-status-dot"></div>Live</div>
    <button id="max-close" onclick="toggleChat()">X</button>
  </div>
  <div id="max-messages"></div>
  <div id="max-input-area">
    <div class="input-row">
      <textarea id="max-input" placeholder="Ask about zero fees, POS systems, savings..." rows="1" onkeydown="handleKey(event)" oninput="autoResize(this)"></textarea>
      <button id="max-send" onclick="sendMessage()" aria-label="Send"><svg viewBox="0 0 24 24"><path d="M22 2L11 13M22 2L15 22L11 13L2 9L22 2Z"/></svg></button>
    </div>
    <div class="input-hint">Enter to send · Shift+Enter for new line</div>
  </div>
</div>




<!-- Modal -->
<div class="modal-wrap" id="modal">
  <div class="modal-box">
    <div class="modal-head">
     <!-- <span>Apply for instant capital!</span>-->
          
        <h3 id="modal-title"></h3>
        
      <button class="modal-close" onclick="closeModal()" aria-label="Close">&times;</button>
    </div>
    <div class="modal-body">
      <form id="quoteForm" onsubmit="submitForm(event, 'quoteForm', 'success')">
        <div class="form-grid">
          <div class="field"><label>Name</label><input type="text" id="name" name="name" placeholder="" required /></div>
          <div class="field"><label>Email</label><input type="email" id="email" name="email" placeholder="" required /></div>
          <div class="field"><label>Phone number</label><input type="tel" id="phone" name="phone" placeholder="" required /></div>
          <div class="field"><label>Company name</label><input type="text" id="company" name="company" placeholder="" /></div>
          <div class="field" style="grid-column:1/-1;"><label>Message</label><textarea id="message" name="message" rows="1"></textarea></div>
        </div>
        <div class="modal-actions"> 
          <div class="g-recaptcha" data-sitekey="6LcTRkEtAAAAAJHjpCOh9J5hSvwGVT1PIF0lJou7"></div>
          <button type="submit" class="submit-btn">Get my free quote</button>
        </div>
      </form>
      <div class="success-banner" id="success">
        <p>Thank you! Your request has been submitted. We'll be in touch shortly.</p>
      </div>
    </div>
  </div>
</div>





<?php wp_footer(); ?>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>


<!--
<script>
grecaptcha.ready(function() {
    grecaptcha.execute('YOUR_SITE_KEY', {action: 'submit'})
    .then(function(token) {
        console.log(token);
    });
});
</script>
-->

<script>
/* -- AI CHATBOT ONLY -- */

let isOpen = false,
    isTyping = false,
    history = [];

const SYS = `You are MAX, the AI assistant for Merchant Pro (Merchant Processing Solutions, Inc.) in Annapolis, Maryland. Expert in payment processing. Help merchants understand how to eliminate or reduce credit card processing fees. Gary Baillio: 888-573-1133 | corpaccounts@merchantproinc.com | Mon�Fri 9am�5pm. Signature: "Practically Zero Fee" program � cash discount/dual pricing, 95%+ fee reduction. POS: Clover, PAX, Verifone, Ingenico, Dejavoo, HP Engage One, Lightspeed. Next-day deposits, instant capital, REV loyalty/gift cards, PCI Level 1. Keep responses concise and confident. Always drive toward calling Gary at 888-573-1133.`;

function toggleChat() {
  isOpen = !isOpen;
  document.getElementById('max-window').classList.toggle('open', isOpen);
  document.getElementById('max-dot').style.display = 'none';

  if (isOpen && history.length === 0) {
    setTimeout(() => addMsg(
      'bot',
      "Hi � I'm **MAX**, Merchant Pro's AI advisor. ??\n\nMost merchants I speak with are losing **$400�$1,500/month** in unnecessary fees. Want to find out what you're paying?\n\nOr ask me anything about zero swipe fees or POS systems.",
      [
        'How do zero fees work?',
        'How much could I save?',
        'What POS do you carry?',
        'I want Gary to call me'
      ]
    ), 350);
  }
}

function addMsg(role, text, qr = [], card = false) {
  const msgs = document.getElementById('max-messages');
  const now = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });

  const d = document.createElement('div');
  d.className = `msg ${role}`;

  const html = text
    .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
    .replace(/\n/g, '<br>');

  d.innerHTML = `
    <div class="msg-bubble">${html}</div>
    <div class="msg-time">${now}</div>
  `;

  if (qr.length) {
    const qrDiv = document.createElement('div');
    qrDiv.className = 'quick-replies';

    qr.forEach(q => {
      const b = document.createElement('button');
      b.className = 'qr-btn';
      b.textContent = q;
      b.onclick = () => {
        b.parentElement.remove();
        handleMsg(q);
      };
      qrDiv.appendChild(b);
    });

    d.appendChild(qrDiv);
  }

  if (card) {
    const c = document.createElement('div');
    c.innerHTML = `
      <div style="margin-top:7px;padding:11px;border-radius:8px;">
        <div style="font-weight:700;">?? Reach Gary</div>
        <a href="tel:8885731133">888-573-1133</a>
      </div>`;
    d.appendChild(c);
  }

  msgs.appendChild(d);
  msgs.scrollTop = msgs.scrollHeight;
}

function showTyping() {
  const m = document.getElementById('max-messages');
  const t = document.createElement('div');
  t.className = 'msg bot';
  t.id = 'ti';
  t.innerHTML = `
    <div class="typing">
      <span></span><span></span><span></span>
    </div>`;
  m.appendChild(t);
}

function hideTyping() {
  document.getElementById('ti')?.remove();
}

function handleKey(e) {
  if (e.key === 'Enter' && !e.shiftKey) {
    e.preventDefault();
    sendMessage();
  }
}

function sendMessage() {
  const inp = document.getElementById('max-input');
  const t = inp.value.trim();

  if (!t || isTyping) return;

  inp.value = '';
  handleMsg(t);
}

async function handleMsg(text) {
  addMsg('user', text);
  history.push({ role: 'user', content: text });

  isTyping = true;
  showTyping();

  try {
    const res = await fetch('https://api.anthropic.com/v1/messages', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        model: 'claude-sonnet-4-20250514',
        max_tokens: 1000,
        system: SYS,
        messages: history
      })
    });

    const data = await res.json();

    hideTyping();
    isTyping = false;

    if (data.content?.[0]) {
      const reply = data.content[0].text;

      history.push({
        role: 'assistant',
        content: reply
      });

      if (history.length > 20) history = history.slice(-20);

      const card =
        reply.toLowerCase().includes('888-573-1133') ||
        reply.toLowerCase().includes('call gary');

      addMsg('bot', reply, [], card);
    }

  } catch (err) {
    hideTyping();
    isTyping = false;
    addMsg(
      'bot',
      "Connection issue � reach Gary directly:\n\n**?? 888-573-1133**",
      [],
      true
    );
  }
}

function autoResize(el) {
  el.style.height = 'auto';
  el.style.height = Math.min(el.scrollHeight, 96) + 'px';
}


window.addEventListener('scroll', () => {
  document.getElementById('phonebar').classList.toggle('show', window.scrollY > 320);
  document.getElementById('btt').classList.toggle('show', window.scrollY > 600);
}); 



</script>



<script>
document.addEventListener("DOMContentLoaded", function () {

    const modal = document.getElementById("modal");
    const success = document.getElementById("success");
    const modalTitle = document.getElementById("modal-title");
    const closeBtn = document.querySelector(".close");
    const modalLinks = document.querySelectorAll(".modal-open");
    const quoteForm = document.getElementById("quoteForm");

    // Open modal
    function openModal() {
        if (modal) modal.style.display = "flex";
        if (success) success.style.display = "none";
    }

    // Close modal
    function closeModal() {
        if (modal) modal.style.display = "none";
    }

    // Global access
    window.openModal = openModal;
    window.closeModal = closeModal;

    // Dynamic modal title
    modalLinks.forEach(function (link) {
        link.addEventListener("click", function (e) {
            e.preventDefault();

            const title = this.textContent.trim();
            if (modalTitle) modalTitle.textContent = title;

            openModal();
        });
    });

    // Close button click
    if (closeBtn) {
        closeBtn.addEventListener("click", closeModal);
    }

    // Outside click close
    if (modal) {
        modal.addEventListener("click", function (e) {
            if (e.target === modal) {
                closeModal();
            }
        });
    }

    // ESC key close
    document.addEventListener("keydown", function (e) {
        if (e.key === "Escape") {
            closeModal();
        }
    });

    // Global submitForm function to handle validation and submission for all forms
    window.submitForm = function(event, formId, successId) {
        if (event) event.preventDefault();

        // Fallbacks for older modal trigger
        if (!formId) formId = "quoteForm";
        if (!successId) successId = "success";

        const form = document.getElementById(formId);
        if (!form) return;

        // Custom validation for the Contact Us page form
        if (formId === 'main-contact-form') {
            let isValid = true;

            // Helper to show field error
            const setError = (fieldId, message) => {
                const errorSpan = document.getElementById(fieldId + '-info');
                if (errorSpan) {
                    errorSpan.innerHTML = message;
                    errorSpan.style.display = 'block';
                }
                const inputEl = document.getElementById(fieldId);
                if (inputEl) {
                    inputEl.classList.add('is-invalid');
                }
                isValid = false;
            };

            // Clear previous errors
            form.querySelectorAll('.info').forEach(span => {
                span.innerHTML = '';
                span.style.display = 'none';
            });
            form.querySelectorAll('input, textarea, select').forEach(input => {
                input.classList.remove('is-invalid');
            });

            // Validate Account Type (optradio)
            const optradio = form.querySelectorAll('input[name="optradio"]');
            if (optradio.length > 0) {
                let optChecked = false;
                optradio.forEach(radio => {
                    if (radio.checked) optChecked = true;
                });
                if (!optChecked) {
                    const typeInfo = document.getElementById('type-info');
                    if (typeInfo) {
                        typeInfo.innerHTML = 'Please select an option';
                        typeInfo.style.display = 'block';
                    }
                    isValid = false;
                }
            }

            // Validate First Name
            const firstName = document.getElementById('first_name');
            if (firstName && !firstName.value.trim()) {
                setError('first_name', 'First name is required');
            }

            // Validate Last Name
            const lastName = document.getElementById('last_name');
            if (lastName && !lastName.value.trim()) {
                setError('last_name', 'Last name is required');
            }

            // Validate Email
            const emailInput = document.getElementById('email');
            if (emailInput) {
                const val = emailInput.value.trim();
                if (!val) {
                    setError('email', 'Email address is required');
                } else {
                    const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
                    if (!emailRegex.test(val)) {
                        setError('email', 'Please enter a valid email address');
                    }
                }
            }

            // Validate Phone Number
            const phoneInput = document.getElementById('phone');
            if (phoneInput) {
                const val = phoneInput.value.trim();
                if (!val) {
                    setError('phone', 'Phone number is required');
                } else {
                    const phoneRegex = /^\+?[0-9\s\-()]{7,20}$/;
                    if (!phoneRegex.test(val)) {
                        setError('phone', 'Please enter a valid phone number');
                    }
                }
            }

            // Validate Country
            const countryInput = document.getElementById('country');
            if (countryInput && !countryInput.value.trim()) {
                setError('country', 'Country is required');
            }

            // Validate Firm Location
            const firmLocationInput = document.getElementById('firm-location');
            if (firmLocationInput && !firmLocationInput.value.trim()) {
                setError('firm-location', 'Firm location is required');
            }

            if (!isValid) {
                return;
            }
        }

        // Collect form data
        const formData = {};
        const inputs = form.querySelectorAll("input, select, textarea");
        inputs.forEach(input => {
            if (input.name) {
                formData[input.name] = input.value;
            } else if (input.id) {
                formData[input.id] = input.value;
            }
        });

        // Check for test email to bypass CAPTCHA
        const email = formData["email"] || "";
        const isTestEmail = (email.trim().toLowerCase() === "salih@codeatech.com");

        const recaptchaEl = form.querySelector(".g-recaptcha");
        if (recaptchaEl && !isTestEmail) {
            const captchaResponse = typeof grecaptcha !== "undefined" ? grecaptcha.getResponse() : "";
            if (!captchaResponse) {
                alert("Please complete the CAPTCHA verification.");
                return;
            }
            formData["captcha"] = captchaResponse;
        } else if (recaptchaEl && isTestEmail) {
            formData["captcha"] = "bypass_test_email";
        }

                console.log("Form Data submitted for " + formId + ":", formData);

        // POST data to WordPress AJAX endpoint
        const ajaxUrl = '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>';
        const bodyParams = new URLSearchParams();
        bodyParams.append('action', 'submit_lead_form');
        bodyParams.append('form_id', formId);
        for (const key in formData) {
            bodyParams.append(key, formData[key]);
        }

        fetch(ajaxUrl, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            body: bodyParams.toString()
        })
        .then(response => {
            if (!response.ok) {
                throw new Error('Network response was not ok');
            }
            return response.json();
        })
        .then(data => {
            console.log("Form submission success:", data);
            if (data && data.success) {
                // Show success message
                const successEl = document.getElementById(successId);
                if (successEl) {
                    successEl.style.display = "block";
                }

                // Reset form
                form.reset();
                if (typeof grecaptcha !== 'undefined' && grecaptcha.reset) {
                    grecaptcha.reset();
                }

                if (formId === 'quoteForm') {
                    setTimeout(closeModal, 2200);
                }
            } else {
                alert("Submission failed: " + (data && data.message ? data.message : "Unknown error"));
            }
        })
        .catch(err => {
            console.error("Form submission AJAX error:", err);
            alert("An error occurred while submitting the form. Please try again.");
        });
    };

});
</script>
</body>
</html>
