@extends('layouts.app')
@section('title','Admin Dashboard - Movex HR')
@section('page_title','HR Admin Dashboard')
@section('page_subtitle','Control staff records, leave, payroll, attendance, recruitment and HR support.')
@section('content')
<div class="grid grid-4">
    <div class="stat"><span class="muted">Total Employees</span><strong>{{ $totalEmployees }}</strong></div>
    <div class="stat"><span class="muted">Active Employees</span><strong>{{ $activeEmployees }}</strong></div>
    <div class="stat"><span class="muted">Pending Leaves</span><strong>{{ $pendingLeaves }}</strong></div>
    <div class="stat"><span class="muted">Monthly Payroll</span><strong>₦{{ number_format($monthlyPayroll,2) }}</strong></div>
</div>
<div class="grid grid-2">
    <div class="card">
        <div class="section-title"><h3>Recent Leave Requests</h3><a class="btn secondary" href="{{ route('admin.leaves') }}">Open</a></div>
        <div class="table-wrap"><table class="table"><tr><th>Employee</th><th>Type</th><th>Days</th><th>Status</th></tr>
            @forelse($recentLeaves as $leave)<tr><td>{{ $leave->user?->name }}</td><td>{{ $leave->leaveType?->name }}</td><td>{{ $leave->total_days }}</td><td><span class="badge {{ $leave->status === 'approved' ? 'green' : ($leave->status === 'rejected' ? 'red' : 'yellow') }}">{{ ucfirst($leave->status) }}</span></td></tr>@empty<tr><td colspan="4"><div class="empty">No leave requests yet.</div></td></tr>@endforelse
        </table></div>
    </div>
    <div class="card">
        <div class="section-title"><h3>Open HR Tickets</h3><a class="btn secondary" href="{{ route('admin.tickets') }}">Open</a></div>
        <div class="table-wrap"><table class="table"><tr><th>Employee</th><th>Subject</th><th>Priority</th><th>Status</th></tr>
            @forelse($recentTickets as $ticket)<tr><td>{{ $ticket->user?->name }}</td><td>{{ $ticket->subject }}</td><td>{{ ucfirst($ticket->priority) }}</td><td><span class="badge yellow">{{ ucfirst(str_replace('_',' ', $ticket->status)) }}</span></td></tr>@empty<tr><td colspan="4"><div class="empty">No tickets yet.</div></td></tr>@endforelse
        </table></div>
    </div>
</div>
<div class="card">
    <h3>Admin HR Coverage</h3>
    <p class="muted">This first version includes employee records, departments, designations, attendance, leave, payroll, documents, performance reviews, recruitment, trainings, tickets, discipline and announcements. Quite a lot for a “plain Laravel app,” because apparently plain apps now need to grow up fast.</p>
</div>
@endsection
