<x-layouts.app :title="__('winners.title')"><x-customer-shell>
 <div class="tp-page-heading"><div><h1>{{ __('winners.title') }}</h1><p>{{ __('winners.description') }}</p></div></div>
 <section class="tp-panel mb-3"><form method="get" action="{{ route('reports.winners') }}" class="tp-winners-filters">
  <label>{{ __('winners.search') }}<input class="form-control" name="q" value="{{ request('q') }}"></label>
  <label>{{ __('winners.project') }}<select class="form-select" name="project"><option value="">{{ __('winners.all_projects') }}</option>@foreach($projects as $project)<option value="{{ $project->ulid }}" @selected(request('project')===$project->ulid)>{{ $project->name }}</option>@endforeach</select></label>
  <label>{{ __('visibility.period') }}<select class="form-select" name="range">@foreach(['7d'=>'last7','30d'=>'last30','90d'=>'last90','this_month'=>'this_month','last_month'=>'last_month','custom'=>'custom'] as $range=>$label)<option value="{{ $range }}" @selected(request('range','30d')===$range)>{{ __('visibility.'.$label) }}</option>@endforeach</select></label>
  <label>{{ __('visibility.country') }}<select class="form-select" name="country"><option value="">—</option>@foreach($countries as $code=>$name)<option value="{{ $code }}" @selected(request('country')===$code)>{{ $name }}</option>@endforeach</select></label>
  <label>{{ __('visibility.language') }}<select class="form-select" name="language"><option value="">—</option>@foreach($languages as $code=>$name)<option value="{{ $code }}" @selected(request('language')===$code)>{{ $name }}</option>@endforeach</select></label>
  <label>{{ __('winners.min_gained') }}<input class="form-control" type="number" min="1" max="100" name="min_gained" value="{{ request('min_gained') }}"></label>
  <label>{{ __('visibility.from_date') }}<input class="form-control" type="date" name="from" value="{{ request('from') }}"></label><label>{{ __('visibility.to_date') }}<input class="form-control" type="date" name="to" value="{{ request('to') }}"></label>
  <div class="d-flex align-items-end"><button class="btn btn-primary w-100">{{ __('winners.filter') }}</button></div>
 </form></section>
 <div class="tp-metric-grid tp-winners-metrics mb-3"><x-metric-card :label="__('winners.ranking_winners')" :value="$summary['winners']" icon="↗"/><x-metric-card :label="__('winners.total_gained')" :value="$summary['gained']" icon="+"/><x-metric-card :label="__('winners.top3')" :value="$summary['top3']" icon="3"/><x-metric-card :label="__('winners.top10')" :value="$summary['top10']" icon="10"/><x-metric-card :label="__('winners.new_entries')" :value="$summary['new_entries']" icon="★"/><x-metric-card :label="__('winners.contribution')" :value="$summary['contribution']===null?null:number_format($summary['contribution'],2).'%'" :description="$summary['contribution']===null?__('winners.no_comparison'):null" icon="%"/></div>
 <section class="tp-panel mb-3"><div class="table-responsive"><table class="table tp-data-table"><thead><tr><th>{{ __('winners.keyword') }}</th><th>{{ __('winners.project') }}</th><th>{{ __('winners.previous') }}</th><th>{{ __('winners.current') }}</th><th>{{ __('winners.gained') }}</th><th>{{ __('winners.visibility') }}</th><th>{{ __('winners.last_check') }}</th></tr></thead><tbody>@forelse($rows as $row)<tr><td><a href="{{ route('rankings.keywords.show',$row['keyword']->ulid) }}">{{ $row['keyword']->phrase }}</a><br><small class="text-body-secondary">{{ __('winners.categories.'.$row['category']) }}</small></td><td><a href="{{ route('projects.show',$row['project']->ulid) }}">{{ $row['project']->name }}</a></td><td>{{ $row['previous']??'—' }}</td><td>{{ $row['current']??'—' }}</td><td class="tp-winner">{{ $row['new_entry']?__('winners.categories.new_entry'):'+'.$row['gained'] }}</td><td>{{ number_format($row['contribution'],2) }}%</td><td>{{ $row['checked_at']->format('d.m.Y H:i') }}</td></tr>@empty<tr><td colspan="7" class="text-center text-body-secondary py-4">{{ __('winners.empty') }}</td></tr>@endforelse</tbody></table></div>{{ $rows->links() }}</section>
 <section class="tp-panel"><h2 class="h5">{{ __('winners.distribution') }}</h2><div class="tp-distribution">@foreach($distribution as $key=>$count)<div><span>{{ __('winners.ranges.'.$key) }}</span><i style="--count:{{ $count }}"></i><strong>{{ $count }}</strong></div>@endforeach</div></section>
</x-customer-shell></x-layouts.app>
