<form class="search-page__form" action="<?php echo url('/search'); ?>" method="GET">
    <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
        <circle cx="11" cy="11" r="8"></circle>
        <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
    </svg>
    <input type="text" name="q" class="search-page__input" placeholder="<?php echo __('search_videos'); ?>" value="<?php echo htmlspecialchars($query); ?>" autofocus>
</form>

<?php if (!empty($videos)): ?>
    <p class="search-results__count">
        <?php echo $total !== 1 ? __('search_results_for_plural', [':count' => Format::number($total)]) : __('search_results_for', [':count' => Format::number($total)]); ?> &laquo;<?php echo htmlspecialchars($query); ?>&raquo;
    </p>
    <div class="video-grid">
        <?php foreach ($videos as $video): ?>
            <?php echo hentaiVideoCard($video); ?>
            <?php Ads::betweenGrid('listing_between', 10); ?>
        <?php endforeach; ?>
    </div>

    <?php echo hentaiPagination($pagination, url('/search')); ?>
<?php endif; ?>

<?php if (!empty($albums)): ?>
    <p class="search-results__count" style="<?php echo !empty($videos) ? 'margin-top:2rem;' : ''; ?>">
        <?php echo __('albums'); ?> <span style="color:var(--text-muted);font-weight:500">(<?php echo Format::number(count($albums)); ?><?php if (($albumTotal ?? 0) > count($albums)): ?>+<?php endif; ?>)</span>
    </p>
    <div class="album-grid">
        <?php foreach ($albums as $album): ?>
            <?php echo hentaiAlbumCard($album); ?>
        <?php endforeach; ?>
    </div>
<?php endif; ?>

<?php if (empty($videos) && empty($albums) && !empty($query)): ?>
    <div class="empty-state">
        <div class="empty-state__icon"><i class="fa-light fa-magnifying-glass"></i></div>
        <p class="empty-state__text"><?php echo __('no_results_for'); ?> &laquo;<?php echo htmlspecialchars($query); ?>&raquo;. <?php echo __('no_results_try'); ?></p>
    </div>
<?php endif; ?>
