<?php
/**
 * Shared site footer + floating actions + scripts.
 * Requires $settings to already be set (header.php sets it) — re-fetch to be safe.
 */
$settings = $settings ?? getSettings();
$waNumber = preg_replace('/\D+/', '', $settings['whatsapp'] ?? '');
?>
<footer class="bg-gray-900 text-gray-300 pt-16 pb-8">
  <div class="max-w-7xl mx-auto px-5 lg:px-8 grid md:grid-cols-4 gap-10">
    <div>
      <a href="<?= e(basePath()) ?>/index.php" class="flex items-center mb-4">
        <img src="<?= e(assetUrl($settings['logo_path'] ?? 'assets/images/pims-logo.png')) ?>" alt="<?= e($settings['site_name'] ?? 'PIMS Nepal') ?>" width="88" height="88" class="h-[88px] w-[88px] object-contain shrink-0" />
      </a>
      <p class="text-sm text-gray-400 mb-5">Your Trusted Tally Partner in Nepal — empowering businesses through smart accounting solutions.</p>
      <div class="flex gap-3">
        <?php if (!empty($settings['facebook_url'])): ?><a href="<?= e($settings['facebook_url']) ?>" target="_blank" rel="noopener" class="w-9 h-9 rounded-full bg-white/10 flex items-center justify-center hover:bg-primary"><i class="bi bi-facebook"></i></a><?php endif; ?>
        <?php if (!empty($settings['linkedin_url'])): ?><a href="<?= e($settings['linkedin_url']) ?>" target="_blank" rel="noopener" class="w-9 h-9 rounded-full bg-white/10 flex items-center justify-center hover:bg-primary"><i class="bi bi-linkedin"></i></a><?php endif; ?>
        <?php if (!empty($settings['instagram_url'])): ?><a href="<?= e($settings['instagram_url']) ?>" target="_blank" rel="noopener" class="w-9 h-9 rounded-full bg-white/10 flex items-center justify-center hover:bg-primary"><i class="bi bi-instagram"></i></a><?php endif; ?>
        <?php if (!empty($settings['youtube_url'])): ?><a href="<?= e($settings['youtube_url']) ?>" target="_blank" rel="noopener" class="w-9 h-9 rounded-full bg-white/10 flex items-center justify-center hover:bg-primary"><i class="bi bi-youtube"></i></a><?php endif; ?>
      </div>
    </div>
    <div>
      <h4 class="text-white font-heading font-semibold mb-4">Quick Links</h4>
      <ul class="space-y-2 text-sm">
        <li><a href="index.php" class="hover:text-primary">Home</a></li>
        <li><a href="about.php" class="hover:text-primary">About</a></li>
        <li><a href="services.php" class="hover:text-primary">Services</a></li>
        <li><a href="downloads.php" class="hover:text-primary">Downloads</a></li>
        <li><a href="contact.php" class="hover:text-primary">Contact</a></li>
      </ul>
    </div>
    <div>
      <h4 class="text-white font-heading font-semibold mb-4">Services</h4>
      <ul class="space-y-2 text-sm">
        <li><a href="service-detail.php?service=tally-software-sales" class="hover:text-primary">Tally Sales</a></li>
        <li><a href="service-detail.php?service=tally-training" class="hover:text-primary">Training</a></li>
        <li><a href="service-detail.php?service=tally-customization" class="hover:text-primary">Customization</a></li>
        <li><a href="service-detail.php?service=support-services" class="hover:text-primary">Support</a></li>
      </ul>
    </div>
    <div>
      <h4 class="text-white font-heading font-semibold mb-4">Location</h4>
      <p class="text-sm text-gray-400 mb-3"><i class="bi bi-geo-alt-fill mr-1 text-primary"></i> <?= e($settings['address'] ?? '') ?></p>
      <?php if (!empty($settings['email'])): ?><p class="text-sm text-gray-400 mb-1"><i class="bi bi-envelope-fill mr-1 text-primary"></i> <?= e($settings['email']) ?></p><?php endif; ?>
      <?php if (!empty($settings['phone'])): ?><p class="text-sm text-gray-400"><i class="bi bi-telephone-fill mr-1 text-primary"></i> <?= e($settings['phone']) ?></p><?php endif; ?>
    </div>
  </div>
  <div class="max-w-7xl mx-auto px-5 lg:px-8 border-t border-white/10 mt-12 pt-6 text-sm text-gray-500 flex flex-col md:flex-row justify-between gap-2">
    <p>&copy; <span class="current-year"></span> <?= e($settings['site_name'] ?? 'PIMS Nepal Pvt. Ltd.') ?>. All rights reserved.</p>
    <p>Simplifying Accounting with Tally Solutions.</p>
  </div>
</footer>

<?php if ($waNumber): ?>
<a id="whatsapp-fab" class="fab" href="https://wa.me/<?= e($waNumber) ?>?text=<?= urlencode("Hello PIMS Nepal, I'd like to know more about TallyPrime.") ?>" target="_blank" rel="noopener"><i class="bi bi-whatsapp"></i></a>
<?php endif; ?>
<button id="backtotop-fab" class="fab"><i class="bi bi-arrow-up"></i></button>

<script>document.querySelectorAll('.current-year').forEach(function(el){ el.textContent = new Date().getFullYear(); });</script>
<?php require __DIR__ . '/data-bridge.php'; ?>
<script src="<?= e(basePath()) ?>/assets/js/main.js"></script>
</body>
</html>
