@extends('layouts.app')

@section('title', 'Holiday Calendar')
@section('heading', 'Holiday Calendar')

@section('content')
@include('settings.partials.back-to-home')
    <x-card>
        <div class="mb-4 flex justify-between items-center">
            <p class="text-slate-600">Company holidays and calendar.</p>
            @if(auth()->user()->isTenantAdmin() || auth()->user()->isCompanyAccountAdmin())
            <a href="{{ route('holidays.create') }}" class="inline-flex items-center rounded-lg bg-slate-800 px-4 py-2 text-sm font-medium text-white hover:bg-slate-700"><i class="bi bi-plus-lg me-1"></i>Add Holiday</a>
            @endif
        </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">Date</th>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Type</th>
                </tr>
            </x-slot>
            @forelse($holidays as $h)
                <tr>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-900">{{ $h->name }}</td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600">{{ $h->date?->format('M d, Y') }}</td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600">{{ $h->type ?? 'public' }}</td>
                </tr>
            @empty
                <tr><td colspan="3" class="px-4 py-8 text-center text-sm text-slate-500">No holidays yet.</td></tr>
            @endforelse
        </x-table>
        @if($holidays->hasPages())<div class="mt-4">{{ $holidays->links() }}</div>@endif
    </x-card>
@endsection
