</main>

<section class="cta-band">
    <div class="container">
        <div class="cta-card">
            <div>
                <p class="eyebrow">Furnify help desk</p>
                <h2>Buying new, planning custom, or requesting Re-Up?</h2>
                <p>Send an inquiry for a new sofa, request a personalized custom sofa quote, or upload your old sofa photo and dimensions for a preliminary Re-Up estimate.</p>
            </div>
            <div class="d-flex flex-wrap gap-2">
                <a href="checkout.php" class="btn btn-light btn-lg">
                    <i class="bi bi-send-check" aria-hidden="true"></i>
                    Request Quote
                </a>
                <a href="custom-sofa.php" class="btn btn-outline-light btn-lg">
                    <i class="bi bi-pencil-square" aria-hidden="true"></i>
                    Custom Sofa
                </a>
                <a href="reup.php" class="btn btn-outline-light btn-lg">
                    <i class="bi bi-magic" aria-hidden="true"></i>
                    Re-Up Sofa
                </a>
            </div>
        </div>
    </div>
</section>

<footer class="site-footer">
    <div class="container">
        <div class="row g-4">
            <div class="col-lg-5">
                <div class="d-flex align-items-center gap-2 mb-3">
                    <span class="brand-mark" aria-hidden="true"></span>
                    <strong>Furnify</strong>
                </div>
                <p class="mb-0">Premium sofas, AR room preview, custom sofa quote requests, Re-Up sofa makeover requests, and live-selling-ready shopping flow.</p>
            </div>
            <div class="col-6 col-lg-2">
                <h3>Shop</h3>
                <a href="index.php#catalog">Catalog</a>
                <a href="cart.php">Cart</a>
                <a href="checkout.php">Inquiry</a>
                <a href="custom-sofa.php">Custom Sofa</a>
            </div>
            <div class="col-6 col-lg-2">
                <h3>Services</h3>
                <a href="custom-sofa.php">Personalized Sofa</a>
                <a href="reup.php">Re-Up Sofa</a>
                <a href="index.php#experience">AR Preview</a>
                <a href="index.php#live-selling">Live Selling</a>
            </div>
            <div class="col-lg-3">
                <h3>Store Promise</h3>
                <p class="small mb-0">Server recalculated totals, secure inquiry token, preliminary custom/Re-Up estimates, and admin-managed quotations.</p>
            </div>
        </div>
    </div>
</footer>

<?php
$settings = store_settings();
$chat = array_get($settings, 'chat', array());
$chatEnabled = is_array($chat) && array_get($chat, 'enabled', false) && chat_channels_configured($chat);
$messengerUrl = is_array($chat) ? trim((string) array_get($chat, 'messenger_url', '')) : '';
$whatsappNumber = is_array($chat) ? preg_replace('/[^0-9]/', '', (string) array_get($chat, 'whatsapp_number', '')) : '';
$chatEmail = is_array($chat) ? trim((string) array_get($chat, 'email', '')) : '';
$chatPhone = is_array($chat) ? trim((string) array_get($chat, 'phone', '')) : '';
?>
<?php if ($chatEnabled): ?>
    <div class="live-chat-widget" data-chat-widget>
        <button type="button" class="live-chat-toggle" data-chat-toggle aria-expanded="false" aria-controls="live-chat-panel">
            <i class="bi bi-chat-dots-fill" aria-hidden="true"></i>
            <span>Chat</span>
        </button>
        <div class="live-chat-panel" id="live-chat-panel" data-chat-panel>
            <div class="live-chat-header">
                <div>
                    <strong><?= e(array_get($chat, 'title', 'Need help?')) ?></strong>
                    <p><?= e(array_get($chat, 'subtitle', 'Send us a message.')) ?></p>
                </div>
                <button type="button" data-chat-close aria-label="Close chat options"><i class="bi bi-x-lg" aria-hidden="true"></i></button>
            </div>
            <div class="live-chat-links">
                <?php if ($messengerUrl !== ''): ?>
                    <a href="<?= e($messengerUrl) ?>" target="_blank" rel="noopener">
                        <i class="bi bi-messenger" aria-hidden="true"></i> Messenger
                    </a>
                <?php endif; ?>
                <?php if ($whatsappNumber !== ''): ?>
                    <a href="https://wa.me/<?= e($whatsappNumber) ?>" target="_blank" rel="noopener">
                        <i class="bi bi-whatsapp" aria-hidden="true"></i> WhatsApp
                    </a>
                <?php endif; ?>
                <?php if ($chatEmail !== ''): ?>
                    <a href="mailto:<?= e($chatEmail) ?>">
                        <i class="bi bi-envelope" aria-hidden="true"></i> Email
                    </a>
                <?php endif; ?>
                <?php if ($chatPhone !== ''): ?>
                    <a href="tel:<?= e(preg_replace('/[^+0-9]/', '', $chatPhone)) ?>">
                        <i class="bi bi-telephone" aria-hidden="true"></i> Call
                    </a>
                <?php endif; ?>
                <?php if (array_get($chat, 'show_inquiry_link', true)): ?>
                    <a href="checkout.php">
                        <i class="bi bi-send-check" aria-hidden="true"></i> New Sofa Inquiry
                    </a>
                    <a href="custom-sofa.php">
                        <i class="bi bi-pencil-square" aria-hidden="true"></i> Custom Sofa Quote
                    </a>
                    <a href="reup.php">
                        <i class="bi bi-magic" aria-hidden="true"></i> Re-Up Estimate
                    </a>
                <?php endif; ?>
            </div>
        </div>
    </div>
<?php endif; ?>


<div class="install-app-widget" data-install-widget hidden>
    <button type="button" class="install-app-main" data-install-action>
        <i class="bi bi-phone" aria-hidden="true"></i>
        <span>Install Furnify App</span>
    </button>
    <button type="button" class="install-app-help" data-bs-toggle="modal" data-bs-target="#installHelpModal" aria-label="How to install Furnify app">
        <i class="bi bi-question-lg" aria-hidden="true"></i>
    </button>
</div>

<div class="modal fade" id="installHelpModal" tabindex="-1" aria-labelledby="installHelpModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content install-modal">
            <div class="modal-header">
                <div>
                    <p class="eyebrow mb-1">PWA install guide</p>
                    <h2 class="modal-title fs-5" id="installHelpModalLabel">Install Furnify on your device</h2>
                </div>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <div class="install-guide-list">
                    <div>
                        <i class="bi bi-android2" aria-hidden="true"></i>
                        <div>
                            <strong>Android / Chrome</strong>
                            <ol>
                                <li>Tap <strong>Install Furnify App</strong> when it appears.</li>
                                <li>If no popup appears, open Chrome menu <strong>⋮</strong>.</li>
                                <li>Tap <strong>Install app</strong> or <strong>Add to Home screen</strong>.</li>
                            </ol>
                        </div>
                    </div>
                    <div>
                        <i class="bi bi-apple" aria-hidden="true"></i>
                        <div>
                            <strong>iPhone / iPad Safari</strong>
                            <ol>
                                <li>Open the store in <strong>Safari</strong>.</li>
                                <li>Tap the <strong>Share</strong> button.</li>
                                <li>Choose <strong>Add to Home Screen</strong>.</li>
                                <li>Tap <strong>Add</strong>.</li>
                            </ol>
                        </div>
                    </div>
                </div>
                <p class="small text-muted mb-0">The install button automatically hides after the app is installed or opened in standalone app mode.</p>
            </div>
        </div>
    </div>
</div>

<div class="toast-container position-fixed bottom-0 end-0 p-3">
    <div id="store-toast" class="toast align-items-center border-0" role="status" aria-live="polite" aria-atomic="true">
        <div class="d-flex">
            <div class="toast-body"></div>
            <button type="button" class="btn-close me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/app.js"></script>
</body>
</html>
