<?php include 'header.php'; ?>

<div class="container">
    <div class="row align-items-center mb-5 mt-5">
        <div class="col-lg-7">
            <h1 class="display-4 fw-bold mb-3"><?php echo __('hero_title'); ?></h1>
            <p class="lead text-muted mb-4"><?php echo __('hero_subtitle'); ?></p>
            
            <div class="d-flex gap-2">
                <a href="#latest" class="btn btn-success btn-lg px-4 rounded-pill"><?php echo __('explore_apps'); ?></a>
                <a href="/register" class="btn btn-outline-dark btn-lg px-4 rounded-pill border-1"><?php echo __('join_referral'); ?></a>
            </div>
        </div>
        <div class="col-lg-5 d-none d-lg-block text-center">
            <div class="position-relative">
                <!-- Dynamic Hero Circle -->
                <div class="position-absolute rounded-circle" style="width: 400px; height: 400px; top: -50px; right: -50px; z-index: -1; filter: blur(60px); opacity: 0.15; animation: color-cycle 20s infinite, floating 10s infinite ease-in-out;"></div>
                <img src="https://img.icons8.com/color/512/android-os.png" class="img-fluid floating-animation" alt="Android APKs" style="max-height: 350px;">
            </div>
        </div>
    </div>

    <section id="latest" class="mb-5">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h2 class="fw-bold mb-0" id="latest-title">
                <?php if (!empty($_GET['search'])): ?>
                    <?php echo __('search_results_for', 'Search results for'); ?>: "<?php echo htmlspecialchars($_GET['search']); ?>"
                <?php else: ?>
                    <?php echo __('latest_apks'); ?>
                <?php endif; ?>
            </h2>
            <div class="dropdown">
                <button class="btn btn-white shadow-sm border rounded-pill dropdown-toggle" type="button" data-bs-toggle="dropdown" id="category-dropdown-btn">
                    <?php echo __('categories'); ?> <i class="bi bi-chevron-down ms-1 small"></i>
                </button>
                <ul class="dropdown-menu dropdown-menu-end shadow border-0" id="category-menu">
                    <li><a class="dropdown-item category-filter" href="/" data-category=""><?php echo __('all_categories'); ?></a></li>
                    <?php 
                    $db = db();
                    $categories = $db->query("SELECT * FROM categories")->fetchAll();
                    foreach ($categories as $cat): ?>
                        <li><a class="dropdown-item category-filter" href="/?category=<?php echo $cat['slug']; ?>" data-category="<?php echo $cat['slug']; ?>"><?php echo $cat['name']; ?></a></li>
                    <?php endforeach; ?>
                </ul>
            </div>
        </div>
        
        <div id="apk-grid-container">
            <?php include 'partials/apk_list.php'; ?>
        </div>
    </section>

    <div class="bg-dark text-white p-5 rounded-5 mt-5 mb-5 shadow-lg position-relative overflow-hidden">
        <!-- Subtle dark mode blob -->
        <div class="position-absolute bg-success opacity-10 rounded-circle" style="width: 300px; height: 300px; bottom: -100px; left: -100px; filter: blur(50px);"></div>
        
        <div class="row align-items-center text-center text-lg-start position-relative">
            <div class="col-lg-8">
                <h2 class="fw-bold mb-3"><?php echo __('referral_journey_title'); ?></h2>
                <p class="mb-0 text-white-50"><?php echo __('referral_journey_text'); ?></p>
            </div>
            <div class="col-lg-4 text-center text-lg-end mt-4 mt-lg-0">
                <a href="/register" class="btn btn-success btn-lg px-5 rounded-pill"><?php echo __('get_started'); ?></a>
            </div>
        </div>
    </div>
</div>

<?php include 'footer.php'; ?>