<?php
if (file_exists(__DIR__ . '/../../app/helpers/settings.php')) {
    require_once __DIR__ . '/../../app/helpers/settings.php';
}

$siteName = function_exists('get_setting') ? get_setting('site_name', APP_NAME) : APP_NAME;

$footerText = function_exists('get_setting')
    ? get_setting('footer_text', 'Natural self-care essentials made with love for soft, simple, everyday rituals.')
    : 'Natural self-care essentials made with love for soft, simple, everyday rituals.';

$contactEmail = 'loveuessentials@gmail.com';

$instagramHandle = '@loveuessentials';
$facebookHandle = '@loveuessentials';

$instagramUrl = 'https://www.instagram.com/loveuessentials';
$facebookUrl = 'https://www.facebook.com/loveuessentials';
?>

<footer class="site-footer lue-footer">
    <div class="container">
        <div class="lue-footer-newsletter">
            <div class="lue-footer-newsletter-copy">
                <span class="lue-footer-kicker">LOVE-U List</span>
                <h2>Soft self-care updates, new drops & first-order treats.</h2>
                <p>
                    Join the LOVE-U Essentials mailing list for product news, gentle self-care inspiration,
                    and exclusive offers created for our little self-care community.
                </p>
            </div>

            <form method="POST" action="<?= e(BASE_URL); ?>/public/newsletter-submit.php" class="lue-newsletter-form">
                <?= csrf_field(); ?>

                <input
                    type="text"
                    name="newsletter_first_name"
                    placeholder="First name"
                >

                <input
                    type="email"
                    name="newsletter_email"
                    placeholder="Email address"
                    required
                >

                <input type="hidden" name="newsletter_source" value="footer_form">

                <button type="submit">Join the List</button>
            </form>
        </div>

        <div class="lue-footer-main">
            <div class="lue-footer-brand">
                <a href="<?= e(BASE_URL); ?>/public/index.php" class="lue-footer-logo">
                    <img src="<?= e(BASE_URL); ?>/uploads/products/loveu-logo.png" alt="<?= e($siteName); ?>">
                </a>

                <p><?= nl2br(e($footerText)); ?></p>

                <div class="lue-footer-socials" aria-label="LOVE-U Essentials social links">
                    <a href="<?= e($instagramUrl); ?>" target="_blank" rel="noopener" aria-label="Instagram">
                        <span class="lue-social-icon">
                            <svg viewBox="0 0 24 24" aria-hidden="true">
                                <rect x="4" y="4" width="16" height="16" rx="5"></rect>
                                <circle cx="12" cy="12" r="3.4"></circle>
                                <circle cx="17.2" cy="6.8" r="0.9"></circle>
                            </svg>
                        </span>
                        <span><?= e($instagramHandle); ?></span>
                    </a>

                    <a href="<?= e($facebookUrl); ?>" target="_blank" rel="noopener" aria-label="Facebook">
                        <span class="lue-social-icon">
                            <svg viewBox="0 0 24 24" aria-hidden="true">
                                <path d="M14.2 8.2H16V5.3c-.3 0-1.3-.1-2.5-.1-2.5 0-4.2 1.5-4.2 4.4v2.5H6.6v3.2h2.7v8.1h3.3v-8.1h2.7l.4-3.2h-3.1V9.9c0-.9.3-1.7 1.6-1.7Z"></path>
                            </svg>
                        </span>
                        <span><?= e($facebookHandle); ?></span>
                    </a>

                    <a href="mailto:<?= e($contactEmail); ?>" aria-label="Email">
                        <span class="lue-social-icon">
                            <svg viewBox="0 0 24 24" aria-hidden="true">
                                <path d="M4.5 6.5h15v11h-15v-11Z"></path>
                                <path d="m5.2 7.3 6.8 5.2 6.8-5.2"></path>
                            </svg>
                        </span>
                        <span><?= e($contactEmail); ?></span>
                    </a>
                </div>
            </div>

            <div class="lue-footer-column">
                <h3>Shop</h3>
                <a href="<?= e(BASE_URL); ?>/public/shop.php">All Products</a>
                <a href="<?= e(BASE_URL); ?>/public/shop.php?filter=best-sellers">Best Sellers</a>
                <a href="<?= e(BASE_URL); ?>/public/shop.php?filter=new-arrivals">New Arrivals</a>
                <a href="<?= e(BASE_URL); ?>/public/cart.php">Cart</a>
            </div>

            <div class="lue-footer-column">
                <h3>Support</h3>
                <a href="<?= e(BASE_URL); ?>/public/contact.php">Contact</a>
                <a href="<?= e(BASE_URL); ?>/public/faq.php">FAQ</a>
                <a href="<?= e(BASE_URL); ?>/public/order-tracking.php">Track Order</a>
                <a href="<?= e(BASE_URL); ?>/public/account.php">My Account</a>
            </div>

            <div class="lue-footer-column">
                <h3>Information</h3>
                <a href="<?= e(BASE_URL); ?>/public/privacy-policy.php">Privacy Policy</a>
                <a href="<?= e(BASE_URL); ?>/public/terms-and-conditions.php">Terms & Conditions</a>
                <a href="<?= e(BASE_URL); ?>/public/shipping-policy.php">Shipping Policy</a>
                <a href="<?= e(BASE_URL); ?>/public/return-policy.php">Return Policy</a>
            </div>
        </div>

        <div class="lue-footer-bottom">
            <span>© <?= date('Y'); ?> <?= e($siteName); ?>. All rights reserved.</span>
            <span>Made for soft rituals · Secure checkout · Gift-ready orders</span>
        </div>
    </div>
</footer>

<script src="<?= e(BASE_URL); ?>/public/assets/js/main.js"></script>
</body>
</html>