@extends('layouts.app')

@section('title', 'Record Expense | Institution Axis')

@section('sidebar-menu')
    @include('schooladmin.partials.sidebar')
@endsection

@section('sidebar-footer')
    <p>{{ auth()->user()->school?->name ?? 'Institution Axis' }}</p>
@endsection

@section('breadcrumb')
    <span><a href="{{ route('schooladmin.dashboard') }}">Home</a></span> / <span>Finance</span> / <span><a href="{{ route('schooladmin.finance.expenses.index') }}">Expenses</a></span> / <span class="active-page">Record</span>
@endsection

@section('content')
<div class="container-fluid">
    <div class="row justify-content-center">
        <div class="col-lg-7">
            <div class="card shadow border-0 rounded-4">
                <div class="card-header bg-white py-3">
                    <h5 class="fw-bold mb-0 text-dark">Record New Expense</h5>
                </div>
                <div class="card-body p-4">
                    <form action="{{ route('schooladmin.finance.expenses.store') }}" method="POST">
                        @csrf
                        <div class="row g-4">
                            <div class="col-md-12">
                                <label class="form-label fw-semibold">Expense Category</label>
                                <select name="category" class="form-select rounded-pill @error('category') is-invalid @enderror" required>
                                    <option value="">Select Category...</option>
                                    <option value="Staff Salaries">Staff Salaries</option>
                                    <option value="Utilities (Water/Electricity)">Utilities (Water/Electricity)</option>
                                    <option value="Maintenance & Repairs">Maintenance & Repairs</option>
                                    <option value="Teaching Materials">Teaching Materials</option>
                                    <option value="Food & Catering">Food & Catering</option>
                                    <option value="Transport & Fuel">Transport & Fuel</option>
                                    <option value="Stationery">Stationery</option>
                                    <option value="Other">Other</option>
                                </select>
                                @error('category') <div class="invalid-feedback">{{ $message }}</div> @enderror
                            </div>

                            <div class="col-md-6">
                                <label class="form-label fw-semibold">Amount (KES)</label>
                                <input type="number" name="amount" class="form-control rounded-pill @error('amount') is-invalid @enderror" step="0.01" placeholder="0.00" required>
                                @error('amount') <div class="invalid-feedback">{{ $message }}</div> @enderror
                            </div>

                            <div class="col-md-6">
                                <label class="form-label fw-semibold">Date Incurred</label>
                                <input type="date" name="date" class="form-control rounded-pill @error('date') is-invalid @enderror" value="{{ date('Y-m-d') }}" required>
                                @error('date') <div class="invalid-feedback">{{ $message }}</div> @enderror
                            </div>

                            <div class="col-md-12">
                                <label class="form-label fw-semibold">Description / Remarks</label>
                                <textarea name="description" class="form-control rounded-4 @error('description') is-invalid @enderror" rows="3" placeholder="Additional details..."></textarea>
                                @error('description') <div class="invalid-feedback">{{ $message }}</div> @enderror
                            </div>
                        </div>

                        <div class="mt-5 text-end">
                            <a href="{{ route('schooladmin.finance.expenses.index') }}" class="btn btn-light px-4 me-2">Cancel</a>
                            <button type="submit" class="btn btn-primary px-5 rounded-pill shadow-sm">
                                <i class="fas fa-save me-2"></i>Record Expense
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
