@extends('layouts.app')

@section('title', 'Performance Cycles')
@section('heading', 'Performance Cycles')

@section('content')
@include('performance.top-submenu')

<x-card>
    <div class="mb-4 flex items-center justify-between">
        <p class="text-sm text-slate-600">Launch structured review cycles for your organization.</p>
        <a href="{{ route('performance-cycles.create') }}" class="rounded-lg bg-primary px-4 py-2 text-sm font-medium text-white"><i class="bi bi-plus-lg me-1"></i>New cycle</a>
    </div>

    <x-table>
        <x-slot name="head">
            <tr>
                <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Name</th>
                <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Period</th>
                <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Status</th>
                <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Reviews</th>
                <th class="px-4 py-3 text-right text-xs font-medium uppercase text-slate-500">Actions</th>
            </tr>
        </x-slot>
        @forelse($cycles as $cycle)
            <tr>
                <td class="px-4 py-3 text-sm font-medium text-slate-900">{{ $cycle->name }}</td>
                <td class="px-4 py-3 text-sm text-slate-600">{{ $cycle->start_date?->format('M d, Y') }} – {{ $cycle->end_date?->format('M d, Y') }}</td>
                <td class="px-4 py-3 text-sm capitalize">{{ $cycle->status }}</td>
                <td class="px-4 py-3 text-sm">{{ $cycle->reviews_count }}</td>
                <td class="px-4 py-3 text-right text-sm">
                    <a href="{{ route('performance-cycles.show', $cycle) }}" class="text-primary hover:underline">Open</a>
                </td>
            </tr>
        @empty
            <tr><td colspan="5" class="px-4 py-8 text-center text-sm text-slate-500">No performance cycles yet.</td></tr>
        @endforelse
    </x-table>
    @if($cycles->hasPages())<div class="mt-4">{{ $cycles->links() }}</div>@endif
</x-card>
@endsection
