<!-- WhatsApp Floating Button -->
<?php $wa = setting('whatsapp'); if ($wa): ?>
<a href="https://wa.me/<?= preg_replace('/[^0-9]/', '', $wa) ?>" target="_blank" rel="noopener"
   class="fixed bottom-6 right-6 z-[60] w-14 h-14 bg-green-500 hover:bg-green-600 text-white rounded-full flex items-center justify-center shadow-[0_10px_30px_rgba(22,163,74,0.4)] transition-all hover:scale-110 group"
   title="Chat on WhatsApp">
  <svg viewBox="0 0 32 32" fill="currentColor" class="w-7 h-7 transform group-hover:rotate-12 transition-transform">
    <path d="M16 0C7.164 0 0 7.164 0 16c0 2.82.738 5.469 2.031 7.766L.062 31.078a.5.5 0 00.617.617l7.297-1.969A15.9 15.9 0 0016 32c8.836 0 16-7.164 16-16S24.836 0 16 0zm8.078 22.195c-.336.945-1.953 1.875-2.68 1.953-.688.074-1.328.324-4.336-.906-3.625-1.5-5.953-5.195-6.133-5.438-.18-.242-1.477-1.965-1.477-3.75s.934-2.664 1.266-3.023c.332-.359.723-.449.965-.449h.695c.223 0 .527-.086.824.629.309.742 1.047 2.559 1.14 2.742.094.184.156.398.031.637-.125.238-.188.387-.375.594-.188.207-.395.46-.562.617-.188.176-.383.367-.164.719.219.352.973 1.605 2.09 2.602 1.438 1.281 2.648 1.676 3 1.863.352.188.559.156.766-.094.207-.25.883-1.031 1.121-1.383.238-.352.477-.293.805-.176.328.117 2.082.984 2.441 1.164.359.18.598.27.688.418.09.148.09.852-.246 1.801z"/>
  </svg>
</a>
<?php endif; ?>

<style>
  .footer-3d-scene { perspective: 1000px; }
  .footer-column-dynamic {
    transition: all 0.5s ease;
    transform-style: flat; /* Changing to flat for better click reliability */
  }
  
  /* PURE 3D CAPSULE MENU */
  .capsule-menu {
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
    z-index: 20;
  }
  .capsule-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #9ca3af;
    width: fit-content;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    z-index: 30;
  }
  .capsule-link:hover {
    background: rgba(249, 115, 22, 0.15);
    border-color: rgba(249, 115, 22, 0.5);
    color: #fff;
    transform: translateX(10px) scale(1.05); /* Simplified but still dynamic */
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
  }
  .capsule-link span:first-child {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
  }
  .capsule-link:hover span:first-child {
    transform: scale(1.3) rotate(15deg);
  }

  .tech-hq-capsule {
    background: rgba(10, 14, 26, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 24px;
    transition: all 0.4s ease;
  }
  .tech-hq-capsule:hover {
    border-color: rgba(249, 115, 22, 0.3);
    transform: translateY(-5px);
  }
</style>

<!-- Footer: The Industrial Foundation -->
<footer class="bg-navy-950 border-t border-white/5 mt-32 relative overflow-hidden text-gray-400">
  <!-- Subtle background branding -->
  <div class="absolute top-0 right-0 w-[500px] h-[500px] bg-orange-600/5 rounded-full blur-[120px] -mr-64 -mt-64 pointer-events-none"></div>
  <div class="absolute bottom-0 left-0 w-[300px] h-[300px] bg-blue-600/5 rounded-full blur-[100px] -ml-32 -mb-32 pointer-events-none"></div>

  <div class="max-w-7xl mx-auto px-4 pt-20 pb-12 relative z-10 footer-3d-scene">
    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-12 gap-12 lg:gap-16">

      <!-- Column 1: Identity -->
      <div class="lg:col-span-4 footer-column-dynamic">
        <div class="flex items-center gap-3 mb-8">
          <?php $footerLogo = setting('logo'); ?>
          <?php if ($footerLogo): ?>
          <img src="<?= rtrim(SITE_URL, '/') ?>/uploads/<?= e($footerLogo) ?>" alt="Rig N Dig" class="h-10 w-auto">
          <?php else: ?>
          <div class="w-10 h-10 rounded-full bg-orange-600 flex items-center justify-center text-white font-black ring-4 ring-orange-500/20">R</div>
          <div class="text-2xl font-black tracking-tighter text-white uppercase">RIG <span class="text-orange-500">N</span> DIG</div>
          <?php endif; ?>
        </div>
        <p class="text-sm leading-relaxed mb-8 max-w-sm">
          A premier engineering house in Pakistan, Rig N Dig specializes in the procurement and manufacturing of API-standard equipment and spares for the energy and manufacturing sectors.
        </p>
        <div class="flex gap-3">
          <?php 
          $socials = [
            'linkedin' => ['url' => '#', 'icon' => '<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z"/></svg>'],
            'facebook' => ['url' => '#', 'icon' => '<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M22.675 0h-21.35c-.732 0-1.325.593-1.325 1.325v21.351c0 .731.593 1.324 1.325 1.324h11.495v-9.294h-3.128v-3.622h3.128v-2.671c0-3.1 1.893-4.788 4.659-4.788 1.325 0 2.463.099 2.795.143v3.24l-1.918.001c-1.504 0-1.795.715-1.795 1.763v2.313h3.587l-.467 3.622h-3.12v9.293h6.116c.73 0 1.323-.593 1.323-1.324v-21.35c0-.732-.593-1.325-1.323-1.325z"/></svg>']
          ];
          foreach($socials as $name => $s): ?>
          <a href="<?= $s['url'] ?>" class="w-10 h-10 rounded-full bg-navy-900 border border-white/5 flex items-center justify-center hover:border-orange-500 hover:text-orange-500 transition-all duration-300 transform-gpu hover:rotate-[360deg]">
            <?= $s['icon'] ?>
          </a>
          <?php endforeach; ?>
        </div>
      </div>

      <!-- Column 2: Supply Chain -->
      <div class="lg:col-span-2 footer-column-dynamic">
        <h4 class="text-xs font-black uppercase tracking-[0.2em] text-white mb-8 border-l-2 border-orange-600 pl-4">Range Matrix</h4>
        <nav class="capsule-menu">
          <a href="/shop.php?category=api-flanges" class="capsule-link"><span>⚙️</span> API Flanges</a>
          <a href="/shop.php?category=valves" class="capsule-link"><span>🔩</span> 6A/6D Valves</a>
          <a href="/shop.php?category=pipes-fittings" class="capsule-link"><span>🏗️</span> Pipe Spares</a>
          <a href="/shop.php?category=rtj-rings-gaskets" class="capsule-link"><span>⭕</span> RTJ Rings</a>
          <a href="/shop.php?category=mining-spares" class="capsule-link"><span>⛏️</span> Mining Spares</a>
          <a href="/shop.php?category=earthmoving-spares" class="capsule-link"><span>🚜</span> Earthmoving</a>
        </nav>
      </div>

      <!-- Column 3: Corporate -->
      <div class="lg:col-span-2 footer-column-dynamic">
        <h4 class="text-xs font-black uppercase tracking-[0.2em] text-white mb-8 border-l-2 border-orange-600 pl-4">Company Node</h4>
        <nav class="capsule-menu">
          <a href="/about.php" class="capsule-link"><span>🏢</span> About Bio</a>
          <a href="/services.php" class="capsule-link"><span>🔧</span> Services</a>
          <a href="/certifications.php" class="capsule-link"><span>📜</span> Certificates</a>
          <a href="/verify-certificate.php" class="capsule-link"><span>🛡️</span> Verify Cert</a>
          <a href="/projects.php" class="capsule-link"><span>📁</span> Projects</a>
          <a href="/track-order.php" class="capsule-link"><span>🚛</span> Live Tracker</a>
          <a href="/blog.php" class="capsule-link"><span>📰</span> Blog</a>
          <a href="/careers.php" class="capsule-link"><span>🤝</span> Careers</a>
        </nav>
      </div>

      <!-- Column 4: Support -->
      <div class="lg:col-span-4 footer-column-dynamic">
        <h4 class="text-xs font-black uppercase tracking-[0.2em] text-white mb-8 border-l-2 border-orange-600 pl-4">Technical HQ</h4>
        <div class="tech-hq-capsule p-6">
          <ul class="space-y-6 text-xs font-bold">
            <li class="flex gap-4">
              <span class="text-orange-500 text-lg">📍</span>
              <span class="leading-relaxed"><?= e(setting('address')) ?></span>
            </li>
            <li>
              <a href="tel:<?= e(setting('phone')) ?>" class="flex items-center gap-4 hover:text-white transition-all group">
                <span class="w-8 h-8 rounded-full bg-orange-600/10 text-orange-500 flex items-center justify-center group-hover:bg-orange-600 group-hover:text-white transition-all ring-2 ring-orange-500/20">📞</span>
                <?= e(setting('phone')) ?>
              </a>
            </li>
            <li>
              <a href="mailto:<?= e(setting('email')) ?>" class="flex items-center gap-4 hover:text-white transition-all group">
                <span class="w-8 h-8 rounded-full bg-orange-600/10 text-orange-500 flex items-center justify-center group-hover:bg-orange-600 group-hover:text-white transition-all ring-2 ring-orange-500/20">✉️</span>
                <?= e(setting('email')) ?>
              </a>
            </li>
          </ul>
        </div>
      </div>
    </div>

    <!-- Standards Cluster -->
    <div class="mt-20 pt-12 border-t border-white/5 flex flex-wrap justify-center md:justify-start gap-12 items-center opacity-40 hover:opacity-100 transition-opacity duration-700">
      <span class="text-[10px] font-black uppercase tracking-widest text-gray-500">Standards Matrix:</span>
      <?php foreach(['API 6A', 'API 6D', 'ASME B16.5', 'ASME B16.34', 'NACE MR0175', 'ISO 9001'] as $s): ?>
      <span class="text-[9px] font-black text-gray-400 border border-white/10 px-3 py-1 rounded-full capsule-link transition-all"><?= $s ?></span>
      <?php endforeach; ?>
    </div>
  </div>

  <div class="bg-black/40 py-10 px-4">
    <div class="max-w-7xl mx-auto flex flex-col md:flex-row justify-between items-center gap-6">
      <div class="flex items-center gap-3 text-[9px] font-black uppercase tracking-[0.2em] text-gray-500">
        <span class="w-1.5 h-1.5 rounded-full bg-orange-600 animate-pulse"></span>
        © <?= date('Y') ?> Rig N Dig Industrial Solutions. All Rights Reserved.
      </div>
      <div class="flex flex-wrap justify-center gap-8 text-[9px] font-black uppercase tracking-widest text-gray-600">
        <a href="/privacy.php" class="hover:text-orange-500 transition-colors">Privacy</a>
        <a href="/terms.php" class="hover:text-orange-500 transition-colors">Terms</a>
        <a href="/admin/login.php" class="text-orange-600 hover:text-orange-400 transition-colors">Admin Access</a>
      </div>
    </div>
  </div>
</footer>

<!-- AI Support Hub -->
<?php include __DIR__ . '/chatbot.php'; ?>

<!-- Scripts Connector -->
<script src="<?= SITE_URL ? rtrim(SITE_URL, '/') . '/' : '' ?>assets/js/main.js?v=<?= time() ?>"></script>
<script src="<?= SITE_URL ? rtrim(SITE_URL, '/') . '/' : '' ?>assets/js/ai-helper.js?v=<?= time() ?>"></script>

</body>
</html>
