<?php
 
 
$vc = count($videos);
?>

<div class="user-page__header" style="display:flex;align-items:center;justify-content:space-between;">
    <div>
        <h1 class="user-page__title"><?php echo __('watch_history'); ?></h1>
        <?php if (!empty($videos)): ?>
        <p class="user-page__subtitle"><?php echo $vc !== 1 ? __('videos_watched_plural', [':count' => Format::number($vc)]) : __('videos_watched', [':count' => Format::number($vc)]); ?></p>
        <?php endif; ?>
    </div>
    <?php if (!empty($videos)): ?>
        <form action="<?php echo url('/history/clear'); ?>" method="POST" onsubmit="return confirm('<?php echo __('clear_history_confirm'); ?>');">
            <?php echo Router::csrfField(); ?>
            <button type="submit" class="btn btn-danger btn-sm"><?php echo __('clear_history'); ?></button>
        </form>
    <?php endif; ?>
</div>

<?php if (!empty($videos)): ?>
    <div class="video-grid">
        <?php foreach ($videos as $video): ?>
            <?php echo hentaiVideoCard($video); ?>
        <?php endforeach; ?>
    </div>

    <?php echo hentaiPagination($pagination); ?>
<?php else: ?>
    <div class="empty-state">
        <div class="empty-state__icon"><i class="fa-light fa-clock-rotate-left"></i></div>
        <p class="empty-state__text"><?php echo __('history_empty'); ?></p>
        <p style="margin-top:12px;"><a href="<?php echo url('/'); ?>" class="btn btn-primary"><?php echo __('discover_videos'); ?></a></p>
    </div>
<?php endif; ?>
