<?php if (empty($apks) && !empty($_GET['search'])): ?>
    <div class="text-center py-5">
        <i class="bi bi-search display-1 text-muted opacity-25 mb-4"></i>
        <h3 class="fw-bold"><?php echo __('no_apks_found', 'No APKs found'); ?></h3>
        <p class="text-muted"><?php echo __('try_another_search', 'Try another search term or browse categories.'); ?></p>
        <a href="/" class="btn btn-outline-success rounded-pill px-4 mt-2"><?php echo __('view_all_apks', 'View All APKs'); ?></a>
    </div>
<?php else: ?>
    <div class="row g-3 g-md-4">
        <?php foreach ($apks as $apk): ?>
            <div class="col-4 col-md-4">
                <div class="card h-100 border-0 shadow-sm rounded-4 hover-lift">
                    <div class="card-body p-2 p-md-4 text-center text-md-start">
                        <div class="d-md-flex align-items-center mb-2 mb-md-3">
                            <?php 
                                $icon = !empty($apk['icon_path']) ? '/'.$apk['icon_path'] : $apk['image_url'];
                            ?>
                            <div class="mx-auto mx-md-0 mb-2 mb-md-0" style="width: 50px; height: 50px;">
                                <img src="<?php echo $icon; ?>" class="rounded-3" width="50" height="50" alt="<?php echo $apk['title']; ?>" style="object-fit: cover; width: 50px; height: 50px;">
                            </div>
                            <div class="ms-md-3 flex-grow-1 overflow-hidden">
                                <h6 class="card-title fw-bold mb-0 text-truncate"><?php echo $apk['title']; ?></h6>
                                <span class="badge bg-light text-dark fw-normal d-none d-md-inline-block">v<?php echo $apk['version']; ?></span>
                            </div>
                        </div>
                        <p class="card-text text-muted small mb-3 line-clamp-2 d-none d-md-block"><?php echo $apk['description']; ?></p>
                        <div class="d-flex flex-column flex-md-row justify-content-between align-items-center gap-2">
                            <span class="text-muted small d-none d-md-inline-block"><i class="fas fa-download me-1"></i> <?php echo number_format($apk['total_downloads']); ?></span>
                            <a href="/apk/<?php echo $apk['slug']; ?>" class="btn btn-success rounded-pill px-3 btn-sm fw-medium w-100 w-md-auto"><?php echo __('details'); ?></a>
                        </div>
                    </div>
                </div>
            </div>
        <?php endforeach; ?>
    </div>
<?php endif; ?>
