<?php
require_once __DIR__ . '/config/config.php';
$pageTitle = 'Fantom Insure - Get Insured Today';
include __DIR__ . '/includes/header.php';
?>

<!-- Hero Section with Background Image and Form -->
<section class="relative min-h-screen flex items-center" style="background: linear-gradient(rgba(33, 21, 148, 0.7), rgba(33, 21, 148, 0.7)), url('assets/images/family.jpg') center/cover no-repeat fixed;">
  <div class="container mx-auto px-4 py-16">
    <div class="grid md:grid-cols-2 gap-12 items-center">
      <!-- Left: Caption -->
      <div class="text-white space-y-6">
        <h1 class="text-5xl md:text-6xl font-bold leading-tight">Get Insured Today</h1>
        <p class="text-xl md:text-2xl opacity-90">Protect what matters most. Comprehensive coverage for your family, vehicles, and peace of mind.</p>
        <div class="flex items-center gap-3">
          <svg class="w-6 h-6 text-primary-green" fill="currentColor" viewBox="0 0 20 20">
            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
          </svg>
          <span class="text-lg">Fast approval within 24 hours</span>
        </div>
        <div class="flex items-center gap-3">
          <svg class="w-6 h-6 text-primary-green" fill="currentColor" viewBox="0 0 20 20">
            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
          </svg>
          <span class="text-lg">Affordable premiums</span>
        </div>
        <div class="flex items-center gap-3">
          <svg class="w-6 h-6 text-primary-green" fill="currentColor" viewBox="0 0 20 20">
            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
          </svg>
          <span class="text-lg">Expert claims assistance</span>
        </div>
      </div>
      
      <!-- Right: Insurance Enquiry Form -->
      <div class="bg-white rounded-2xl shadow-2xl p-8">
        <h2 class="text-3xl font-bold text-gray-900 mb-2">Insurance Enquiry</h2>
        <p class="text-gray-600 mb-6">Fill in your details and we'll contact you shortly</p>
        
        <form id="insuranceForm" class="space-y-4">
          <div>
            <label class="block text-sm font-semibold text-gray-700 mb-2">Full Name *</label>
            <input type="text" name="name" required class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-blue" placeholder="Your full name">
          </div>
          
          <div class="grid grid-cols-2 gap-4">
            <div>
              <label class="block text-sm font-semibold text-gray-700 mb-2">Email *</label>
              <input type="email" name="email" required class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-blue" placeholder="you@email.com">
            </div>
            <div>
              <label class="block text-sm font-semibold text-gray-700 mb-2">Phone *</label>
              <input type="tel" name="phone" required class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-blue" placeholder="07xx xxx xxx">
            </div>
          </div>
          
          <div>
            <label class="block text-sm font-semibold text-gray-700 mb-2">Insurance Type *</label>
            <select id="insuranceType" name="insurance_type" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-blue" required>
              <option value="">Select insurance type</option>
              <option value="Car Insurance">Car Insurance</option>
              <option value="Family Health Insurance">Family Health Insurance</option>
              <option value="Business Insurance">Business Insurance</option>
              <option value="Property Insurance">Property Insurance</option>
            </select>
          </div>
          
          <div>
            <label class="block text-sm font-semibold text-gray-700 mb-2">Your Message *</label>
            <textarea name="message" rows="3" required class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-blue resize-none" placeholder="Tell us what you need help with"></textarea>
          </div>
          
          <button type="submit" class="w-full bg-primary-blue text-white px-6 py-4 rounded-lg font-bold text-lg hover:bg-opacity-90 transition shadow-lg hover:shadow-xl">
            Submit Enquiry
          </button>
          
          <p class="text-xs text-gray-500 text-center">We will respond promptly</p>
        </form>
        
        <div id="insuranceResult" class="mt-4 hidden"></div>
      </div>
    </div>
  </div>
</section>

<!-- How It Works - Process Cards -->
<section class="py-20 bg-soft-gray">
  <div class="container mx-auto px-4">
    <div class="text-center mb-16">
      <h2 class="text-4xl md:text-5xl font-bold text-gray-900 mb-4">How Easy Is Our Application Process?</h2>
      <p class="text-xl text-gray-600 max-w-2xl mx-auto">Get insured in three simple steps. No hassle, no delays.</p>
    </div>
    
    <div class="grid md:grid-cols-3 gap-8 max-w-5xl mx-auto">
      <!-- Step 1 -->
      <div class="bg-white rounded-2xl p-8 shadow-xl hover:shadow-2xl transition-all duration-300 transform hover:-translate-y-2">
        <div class="w-20 h-20 mx-auto mb-6 bg-gradient-to-br from-primary-blue to-blue-600 rounded-full flex items-center justify-center">
          <svg class="w-10 h-10 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
          </svg>
        </div>
        <h3 class="text-2xl font-bold text-gray-900 mb-3 text-center">Expert Advice & Guidance</h3>
        <p class="text-gray-600 text-center leading-relaxed">We assess your unique insurance requirements, explain different policy options, and help you choose the most suitable coverage.</p>
      </div>
      
      <!-- Step 2 -->
      <div class="bg-white rounded-2xl p-8 shadow-xl hover:shadow-2xl transition-all duration-300 transform hover:-translate-y-2">
        <div class="w-20 h-20 mx-auto mb-6 bg-gradient-to-br from-primary-green to-green-600 rounded-full flex items-center justify-center">
          <svg class="w-10 h-10 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
          </svg>
        </div>
        <h3 class="text-2xl font-bold text-gray-900 mb-3 text-center">Personalized Service</h3>
        <p class="text-gray-600 text-center leading-relaxed">We take the time to understand your specific needs, answer your questions, and assist you throughout the insurance process.</p>
      </div>
      
      <!-- Step 3 -->
      <div class="bg-white rounded-2xl p-8 shadow-xl hover:shadow-2xl transition-all duration-300 transform hover:-translate-y-2">
        <div class="w-20 h-20 mx-auto mb-6 bg-gradient-to-br from-orange-500 to-red-600 rounded-full flex items-center justify-center">
          <svg class="w-10 h-10 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5"/>
          </svg>
        </div>
        <h3 class="text-2xl font-bold text-gray-900 mb-3 text-center">Claims Assistance</h3>
        <p class="text-gray-600 text-center leading-relaxed">In the unfortunate event that you need to file a claim, we provide valuable support and advocacy on your behalf.</p>
      </div>
    </div>
  </div>
</section>

<!-- Why Insurance Matters -->
<section class="py-20 bg-white">
  <div class="container mx-auto px-4">
    <div class="max-w-6xl mx-auto">
      <div class="text-center mb-16">
        <h2 class="text-4xl md:text-5xl font-bold text-gray-900 mb-4">Why Insurance Matters</h2>
        <p class="text-xl text-gray-600">Securing your family's future is the best investment you can make</p>
      </div>
      
      <div class="grid md:grid-cols-2 gap-12 items-center mb-16">
        <div>
          <img src="assets/images/family3.jpg" alt="Happy African family" class="rounded-2xl shadow-2xl w-full object-cover" loading="lazy">
        </div>
        <div class="space-y-6">
          <h3 class="text-3xl font-bold text-gray-900">Protect Your Loved Ones</h3>
          <p class="text-lg text-gray-700 leading-relaxed">
            Insurance is more than just a policy—it's peace of mind. Whether it's protecting your family's health, securing your vehicle, or safeguarding your home, the right insurance coverage ensures that unexpected events don't derail your financial stability.
          </p>
          <p class="text-lg text-gray-700 leading-relaxed">
            Life is unpredictable, but your preparedness doesn't have to be. With comprehensive insurance coverage, you can face the future with confidence, knowing that you and your loved ones are protected.
          </p>
        </div>
      </div>
      
      <div class="grid md:grid-cols-2 gap-12 items-center mb-16">
        <div class="space-y-6 order-2 md:order-1">
          <h3 class="text-3xl font-bold text-gray-900">Financial Security for Your Family</h3>
          <p class="text-lg text-gray-700 leading-relaxed">
            The importance of insurance cannot be overstated. Medical emergencies, accidents, and unforeseen circumstances can create financial burdens that are difficult to overcome. Insurance acts as a safety net, providing the resources you need when you need them most.
          </p>
          <div class="space-y-4">
            <div class="flex items-start gap-3">
              <svg class="w-6 h-6 text-primary-green mt-1 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
                <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
              </svg>
              <div>
                <h4 class="font-bold text-gray-900 mb-1">Health Coverage</h4>
                <p class="text-gray-700">Access quality healthcare without the worry of overwhelming medical bills</p>
              </div>
            </div>
            <div class="flex items-start gap-3">
              <svg class="w-6 h-6 text-primary-green mt-1 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
                <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
              </svg>
              <div>
                <h4 class="font-bold text-gray-900 mb-1">Asset Protection</h4>
                <p class="text-gray-700">Safeguard your vehicle, property, and valuables from damage or loss</p>
              </div>
            </div>
            <div class="flex items-start gap-3">
              <svg class="w-6 h-6 text-primary-green mt-1 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
                <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
              </svg>
              <div>
                <h4 class="font-bold text-gray-900 mb-1">Peace of Mind</h4>
                <p class="text-gray-700">Sleep better knowing you're prepared for life's uncertainties</p>
              </div>
            </div>
          </div>
        </div>
        <div class="order-1 md:order-2">
          <img src="assets/images/family2.jpg" alt="African family together" class="rounded-2xl shadow-2xl w-full object-cover" loading="lazy">
        </div>
      </div>
      
      <div class="grid md:grid-cols-2 gap-12 items-center">
        <div>
          <img src="https://images.unsplash.com/photo-1511895426328-dc8714191300?w=800&h=600&fit=crop" alt="Happy family at home" class="rounded-2xl shadow-2xl w-full object-cover" loading="lazy">
        </div>
        <div class="space-y-6">
          <h3 class="text-3xl font-bold text-gray-900">Building a Secure Future</h3>
          <p class="text-lg text-gray-700 leading-relaxed">
            At Fantom Capital, we understand the unique needs of Kenyan families. Our insurance solutions are designed to be affordable, accessible, and comprehensive. We work with leading insurance providers to bring you the best coverage at competitive rates.
          </p>
          <p class="text-lg text-gray-700 leading-relaxed">
            Don't wait until it's too late. Get insured today and take the first step towards securing your family's future. Our expert team is ready to guide you through the process and help you find the perfect coverage for your needs.
          </p>
          <a href="#" onclick="document.getElementById('insuranceForm').scrollIntoView({behavior: 'smooth'}); return false;" class="inline-flex items-center gap-2 bg-primary-blue text-white px-8 py-4 rounded-full font-bold text-lg hover:bg-opacity-90 transition shadow-lg hover:shadow-xl">
            Get Your Free Quote
            <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 8l4 4m0 0l-4 4m4-4H3"/>
            </svg>
          </a>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- Call to Action -->
<section class="py-16 bg-gradient-to-br from-primary-blue to-blue-900 text-white">
  <div class="container mx-auto px-4 text-center">
    <h2 class="text-3xl md:text-4xl font-bold mb-4">Ready to Get Protected?</h2>
    <p class="text-xl mb-8 max-w-2xl mx-auto">Join thousands of satisfied customers who trust Fantom Capital for their insurance needs</p>
    <div class="flex flex-wrap justify-center gap-4">
      <a href="tel:0723 00 500" class="bg-primary-green text-white px-8 py-4 rounded-full font-bold text-lg hover:bg-opacity-90 transition shadow-lg hover:shadow-xl inline-flex items-center gap-2">
        <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>
        </svg>
        Call Us Now
      </a>
      <a href="https://wa.link/ymy3in" target="_blank" rel="noopener" class="bg-white text-primary-blue px-8 py-4 rounded-full font-bold text-lg hover:bg-opacity-90 transition shadow-lg hover:shadow-xl inline-flex items-center gap-2">
        <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24">
          <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/>
        </svg>
        WhatsApp Us
      </a>
    </div>
  </div>
</section>

<script>
const insuranceForm = document.getElementById('insuranceForm');
const insuranceResult = document.getElementById('insuranceResult');
const insuranceTypeEl = document.getElementById('insuranceType');

if (insuranceForm) {
  insuranceForm.addEventListener('submit', async (e) => {
    e.preventDefault();
    const form = e.currentTarget;
    const data = new FormData(form);
    const insType = insuranceTypeEl.value || 'Insurance';
    data.set('subject', `Insurance Enquiry - ${insType}`);
    data.set('inquiry_type', 'insurance');

    insuranceResult.className = 'mt-4 text-sm text-gray-600';
    insuranceResult.textContent = 'Submitting...';
    insuranceResult.classList.remove('hidden');

    try {
      data.append('csrf_token', document.querySelector('meta[name="csrf-token"]')?.content || '');
      const res = await fetch('<?php echo SITE_URL; ?>/api/submit_contact.php', { method: 'POST', body: data });
      const result = await res.json().catch(() => ({ success: false, message: 'Invalid server response' }));
      if (result.success) {
        insuranceResult.className = 'mt-4 text-sm font-semibold text-green-700';
        insuranceResult.textContent = 'Thank you! Your enquiry has been received. We will contact you shortly.';
        form.reset();
      } else {
        insuranceResult.className = 'mt-4 text-sm font-semibold text-red-700';
        insuranceResult.textContent = result.message || 'Failed to submit enquiry. Please try again.';
      }
    } catch (err) {
      console.error(err);
      insuranceResult.className = 'mt-4 text-sm font-semibold text-red-700';
      insuranceResult.textContent = 'Network error. Please try again later.';
    }
  });
}
</script>

<?php include __DIR__ . '/includes/footer.php'; ?>
