@extends('layouts.app')
@section('title','Generate Payroll')
@section('page-title','Payroll')

@section('content')
<div class="page-header">
    <div class="d-flex align-items-center gap-2">
        <a href="{{ route('payroll.index') }}" class="btn btn-sm btn-outline-secondary"><i class="bi bi-arrow-left"></i></a>
        <div>
            <h1>Generate Payroll</h1>
            <nav aria-label="breadcrumb"><ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="{{ route('payroll.index') }}">Payroll</a></li>
                <li class="breadcrumb-item active">Generate</li>
            </ol></nav>
        </div>
    </div>
</div>

<div class="row g-3">
    <div class="col-12 col-lg-7">
        <div class="card">
            <div class="card-header"><i class="bi bi-currency-dollar me-2" style="color:var(--ul-primary);"></i>Payroll Period Details</div>
            <div class="card-body">
                <form method="POST" action="{{ route('payroll.generate') }}">
                @csrf
                <div class="row g-3">
                    <div class="col-12">
                        <label class="form-label">Period Name *</label>
                        <input type="text" name="name" class="form-control" value="{{ old('name', 'Payroll — '.now()->format('F Y')) }}" required placeholder="e.g. Payroll — April 2025">
                    </div>
                    <div class="col-6">
                        <label class="form-label">Start Date *</label>
                        <input type="date" name="start_date" class="form-control" value="{{ old('start_date', now()->startOfMonth()->format('Y-m-d')) }}" required>
                    </div>
                    <div class="col-6">
                        <label class="form-label">End Date *</label>
                        <input type="date" name="end_date" class="form-control" value="{{ old('end_date', now()->endOfMonth()->format('Y-m-d')) }}" required>
                    </div>
                    <div class="col-6">
                        <label class="form-label">Payment Date *</label>
                        <input type="date" name="payment_date" class="form-control" value="{{ old('payment_date', now()->endOfMonth()->format('Y-m-d')) }}" required>
                    </div>
                    <div class="col-12 mt-2">
                        <div class="alert alert-info d-flex gap-2">
                            <i class="bi bi-info-circle-fill" style="flex-shrink:0;"></i>
                            <div style="font-size:.84rem;">Payroll will be auto-generated for all <strong>active</strong> employees based on their current salary on record. Tax (15%) and pension (5%) deductions are applied automatically.</div>
                        </div>
                    </div>
                    <div class="col-12">
                        <button type="submit" class="btn btn-primary" onclick="return confirm('Generate payroll for all active employees?')">
                            <i class="bi bi-play-circle me-2"></i>Generate Payroll
                        </button>
                        <a href="{{ route('payroll.index') }}" class="btn btn-outline-secondary ms-2">Cancel</a>
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
