@extends('layouts.app')

@section('title', 'Request Attendance Regularization')
@section('heading', 'Request Attendance Regularization')

@section('content')
    @include('attendance.top-submenu')
    <x-card>
        <p class="mb-4 text-slate-600">Submit a request to correct or add attendance for a date.</p>
        <form action="{{ route('attendance-regularizations.store') }}" method="POST" class="max-w-xl space-y-4">
            @csrf
            <div>
                <label class="block text-sm font-medium text-slate-700">Date</label>
                <input type="date" name="date" value="{{ old('date', $prefillDate ?? '') }}" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2" required max="{{ now()->format('Y-m-d') }}">
                @error('date')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
            </div>
            <div class="grid gap-4 sm:grid-cols-2">
                <div>
                    <label class="block text-sm font-medium text-slate-700">Requested clock-in (time)</label>
                    <input type="time" name="requested_clock_in_time" step="60" value="{{ old('requested_clock_in_time') }}" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2">
                    @error('requested_clock_in_time')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700">Requested clock-out (time)</label>
                    <input type="time" name="requested_clock_out_time" step="60" value="{{ old('requested_clock_out_time') }}" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2">
                    @error('requested_clock_out_time')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
                </div>
            </div>
            <div>
                <label class="block text-sm font-medium text-slate-700">Reason</label>
                <textarea name="reason" rows="3" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2" required placeholder="Why is this correction needed?">{{ old('reason') }}</textarea>
                @error('reason')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
            </div>
            <div class="flex gap-2">
                <button type="submit" class="rounded-lg bg-primary px-4 py-2 text-sm font-medium text-white">Submit Request</button>
                <a href="{{ route('attendance-regularizations.index') }}" class="rounded-lg bg-slate-100 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-200">Cancel</a>
            </div>
        </form>
    </x-card>
@endsection
