</main> <!-- /.page-container -->

<footer class="main-footer">
    <div class="footer-top">
        <div class="container footer-grid">
            <div class="footer-col about-col">
                <h3>Çözüm Merkezi</h3>
                <p><?php echo htmlspecialchars(\App\Models\Settings::get('store_description', 'Yazıcı reset programları, toner dolum çözümleri ve hata kodları rehberi.')); ?></p>
                <div class="footer-contact">
                    <p><i class="fa fa-phone"></i> <?php echo htmlspecialchars(\App\Models\Settings::get('telephone')); ?></p>
                    <p><i class="fa fa-whatsapp" style="color: #25D366;"></i> <?php echo htmlspecialchars(\App\Models\Settings::get('mobile')); ?></p>
                    <p><i class="fa fa-envelope"></i> <?php echo htmlspecialchars(\App\Models\Settings::get('email')); ?></p>
                    <p><i class="fa fa-map-marker"></i> <?php echo htmlspecialchars(\App\Models\Settings::get('address')); ?></p>
                </div>
            </div>
            
            <div class="footer-col links-col">
                <h3>Popüler Linkler</h3>
                <ul>
                    <?php
                    $allArts = \App\Models\Article::all();
                    usort($allArts, function($a, $b) {
                        return (int)$b->view_count - (int)$a->view_count;
                    });
                    $topLinks = array_slice($allArts, 0, 4);
                    foreach($topLinks as $link):
                    ?>
                    <li><a href="<?php echo $baseUrl; ?>/<?php echo $link->slug; ?>"><?php echo htmlspecialchars($link->title); ?></a></li>
                    <?php endforeach; ?>
                </ul>
            </div>

            <div class="footer-col brands-col">
                <h3>Yazıcı Markaları</h3>
                <div class="footer-brands-grid">
                    <?php
                    $footerBrands = \App\Models\Brand::all();
                    foreach (array_slice($footerBrands, 0, 12) as $fb):
                    ?>
                    <a href="<?php echo $baseUrl; ?>/<?php echo $fb->slug; ?>"><?php echo htmlspecialchars($fb->name); ?></a>
                    <?php endforeach; ?>
                </div>
            </div>
        </div>
    </div>
    <div class="footer-bottom">
        <div class="container bottom-content">
            <p>&copy; <?php echo date('Y'); ?> Çözüm Merkezi. Tüm Hakları Saklıdır.</p>
            <p class="service-text">Bodrum Büro &amp; Yazıcı Servisi Altyapısıyla</p>
        </div>
    </div>
</footer>

<!-- ═══════════════════════════════════════════════════════
     PREMIUM MOBILE BOTTOM NAV
═══════════════════════════════════════════════════════ -->
<nav class="premium-bottom-nav">
    <div class="nav-items-container">
        <!-- Left Items -->
        <a href="https://services.everestburo.com/" class="mob-nav-item">
            <i class="fa fa-wrench"></i>
            <span>Servis</span>
        </a>
        <button class="mob-nav-item" onclick="focusMobileSearch()">
            <i class="fa fa-search"></i>
            <span>Arama</span>
        </button>
        
        <!-- Center FAB (Categories Menu) -->
        <div class="nav-item-center">
            <button class="nav-fab" onclick="openBottomSheet('menu-sheet')">
                <i class="fa fa-th-large"></i>
            </button>
        </div>

        <!-- Right Items -->
        <a href="<?php echo $baseUrl; ?>/contact" class="mob-nav-item">
            <i class="fa fa-envelope"></i>
            <span>İletişim</span>
        </a>
        <?php $everestRoot = rtrim(str_replace('/cozummerkezi', '', $baseUrl), '/'); if(empty($everestRoot)) $everestRoot = '/'; ?>
        <a href="<?php echo $everestRoot; ?>" class="mob-nav-item">
            <i class="fa fa-home"></i>
            <span>Everest</span>
        </a>
    </div>
</nav>

<!-- ═══════════════════════════════════════════════════════
     BOTTOM SHEETS
═══════════════════════════════════════════════════════ -->
<div class="sheet-backdrop" id="sheetBackdrop" onclick="closeAllBottomSheets()"></div>

<!-- Menu Sheet -->
<div class="bottom-sheet" id="menu-sheet">
    <div class="sheet-header">
        <h3>Kategoriler</h3>
        <button class="close-sheet" onclick="closeAllBottomSheets()"><i class="fa fa-times"></i></button>
    </div>
    <div class="sheet-body">
        <?php 
        // Fetch all categories (assumed flat or main)
        $mobileCategories = \App\Models\Category::all(['parent_slug' => null]); 
        if (!empty($mobileCategories)): 
        ?>
            <div class="sheet-menu-grid">
                <?php foreach ($mobileCategories as $cat): 
                    // Check if has subcategories (placeholder logic for future proofing)
                    $subCats = \App\Models\Category::all(['parent_slug' => $cat->slug]);
                ?>
                <div class="sheet-menu-item-wrapper">
                    <?php if(!empty($subCats)): ?>
                        <button class="sheet-menu-item" onclick="toggleSubmenu(this)">
                            <div><i class="fa fa-folder-o cat-icon"></i> <?php echo htmlspecialchars($cat->name); ?></div>
                            <i class="fa fa-chevron-down submenu-toggle-icon"></i>
                        </button>
                        <div class="sheet-submenu">
                            <?php foreach($subCats as $sub): ?>
                            <a href="<?php echo $baseUrl; ?>/<?php echo $sub->slug; ?>"><?php echo htmlspecialchars($sub->name); ?></a>
                            <?php endforeach; ?>
                        </div>
                    <?php else: ?>
                        <a href="<?php echo $baseUrl; ?>/<?php echo $cat->slug; ?>" class="sheet-menu-item">
                            <div><i class="fa fa-folder-o cat-icon"></i> <?php echo htmlspecialchars($cat->name); ?></div>
                        </a>
                    <?php endif; ?>
                </div>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
    </div>
</div>

<script>
function toggleMobileMenu() {
    const nav = document.getElementById('mainNavigation');
    nav.classList.toggle('active');
}

// ════════════════════════════════════════════════
// PREMIUM BOTTOM NAV SCRIPTS
// ════════════════════════════════════════════════
function openBottomSheet(sheetId) {
    document.getElementById('sheetBackdrop').classList.add('show');
    document.getElementById(sheetId).classList.add('show');
    document.body.style.overflow = 'hidden'; // Prevent background scrolling
}

function closeAllBottomSheets() {
    document.getElementById('sheetBackdrop').classList.remove('show');
    const sheets = document.querySelectorAll('.bottom-sheet');
    sheets.forEach(sheet => sheet.classList.remove('show'));
    document.body.style.overflow = '';
}

function focusMobileSearch() {
    closeAllBottomSheets();
    const searchInput = document.querySelector('.header-search-form input');
    if(searchInput) {
        window.scrollTo({ top: 0, behavior: 'smooth' });
        setTimeout(() => searchInput.focus(), 300);
    }
}

function toggleSubmenu(button) {
    const submenu = button.nextElementSibling;
    const allSubmenus = document.querySelectorAll('.sheet-submenu');
    const allButtons = document.querySelectorAll('.sheet-menu-item');
    
    // If it's already open, close it
    if (submenu.classList.contains('open')) {
        submenu.classList.remove('open');
        button.classList.remove('open');
    } else {
        // Close others
        allSubmenus.forEach(sub => sub.classList.remove('open'));
        allButtons.forEach(btn => btn.classList.remove('open'));
        // Open this one
        submenu.classList.add('open');
        button.classList.add('open');
    }
}
</script>
<script src="<?php echo $baseUrl; ?>/assets/js/live-search.js?v=1"></script>
</body>
</html>
