<?php
 
 
 

$perfTabs = [
    'alphabetical' => __('alphabetical'),
    'popularity'   => __('popularity'),
];
$perfTabs = HookSystem::applyFilter('front.performer_sort_tabs', $perfTabs);
?>

<div class="section-title-row">
    <h1 class="section-title" style="text-transform:uppercase;"><?php echo __('page_title_pornstars'); ?></h1>
    <div class="section-title-row__search">
        <i class="fa-solid fa-magnifying-glass listing-search__icon"></i>
        <input type="text" class="listing-search__input" id="listingSearchInput" placeholder="<?php echo __('search_pornstars'); ?>" autocomplete="off">
    </div>
    <?php if (!empty($performers)): ?>
        <?php echo hentaiSortDropdown($sort, '/pornstars', $perfTabs); ?>
    <?php endif; ?>
</div>


<div class="empty-state" id="listingNoResults" style="display:none;">
    <div class="empty-state__icon"><i class="fa-light fa-magnifying-glass"></i></div>
    <p class="empty-state__text"><?php echo __('no_results_for'); ?> "<span id="listingNoResultsQuery"></span>"</p>
</div>

<?php if (!empty($performers)): ?>
<div class="performer-grid" id="listing-grid">
    <?php foreach ($performers as $performer): ?>
        <?php echo hentaiPerformerCard($performer); ?>
    <?php endforeach; ?>
</div>
<?php else: ?>
    <div class="empty-state">
        <div class="empty-state__icon"><i class="fa-light fa-user-group"></i></div>
        <p class="empty-state__text"><?php echo __('no_pornstars'); ?></p>
    </div>
<?php endif; ?>

<?php echo hentaiPagination($pagination); ?>

<?php if (!empty($performers)): ?>
<script>
(function(){
    var input=document.getElementById('listingSearchInput'),grid=document.getElementById('listing-grid'),
        noRes=document.getElementById('listingNoResults'),noResQ=document.getElementById('listingNoResultsQuery');
    if(!input||!grid)return;
    input.addEventListener('input',function(){
        var q=this.value.trim().toLowerCase(),items=grid.querySelectorAll('[data-name]'),vis=0;
        items.forEach(function(el){var n=el.getAttribute('data-name');if(!q||n.indexOf(q)!==-1){el.style.display='';vis++}else{el.style.display='none'}});
        if(q&&!vis){noResQ.textContent=this.value.trim();noRes.style.display=''}else{noRes.style.display='none'}
    });
})();
</script>
<?php endif; ?>
