@csrf
<div class="row g-3">
    <div class="col-md-6">
        <label class="form-label">Service/Event Name</label>
        <input type="text" name="name" value="{{ old('name', $service->name) }}" class="form-control" required>
    </div>
    <div class="col-md-6">
        <label class="form-label">Service Type</label>
        <select name="service_type_id" class="form-select">
            <option value="">Select type</option>
            @foreach ($serviceTypes as $type)
                <option value="{{ $type->id }}" @selected((string) old('service_type_id', $service->service_type_id) === (string) $type->id)>{{ $type->name }}</option>
            @endforeach
        </select>
    </div>
    <div class="col-md-4">
        <label class="form-label">Date</label>
        <input type="date" name="service_date" value="{{ old('service_date', optional($service->service_date)->format('Y-m-d') ?? now()->toDateString()) }}" class="form-control" required>
    </div>
    <div class="col-md-4">
        <label class="form-label">Start Time</label>
        <input type="time" name="start_time" value="{{ old('start_time', $service->start_time ? substr($service->start_time, 0, 5) : '') }}" class="form-control">
    </div>
    <div class="col-md-4">
        <label class="form-label">End Time</label>
        <input type="time" name="end_time" value="{{ old('end_time', $service->end_time ? substr($service->end_time, 0, 5) : '') }}" class="form-control">
    </div>
    <div class="col-md-8">
        <label class="form-label">Location</label>
        <input type="text" name="location" value="{{ old('location', $service->location ?: 'Anglican Church St Peter and Paul Mwenge Kijitonyama') }}" class="form-control" required>
    </div>
    <div class="col-md-4">
        <label class="form-label">Status</label>
        <select name="status" class="form-select" required>
            @foreach (['open' => 'Open', 'closed' => 'Closed'] as $value => $label)
                <option value="{{ $value }}" @selected(old('status', $service->status ?: 'open') === $value)>{{ $label }}</option>
            @endforeach
        </select>
    </div>
    <div class="col-12">
        <label class="form-label">Description</label>
        <textarea name="description" rows="3" class="form-control">{{ old('description', $service->description) }}</textarea>
    </div>
</div>
<div class="{{ ($modal ?? false) ? 'modal-footer px-0 pb-0' : 'mt-4 d-flex gap-2' }}">
    @if ($modal ?? false)
        <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal"><i data-lucide="x"></i><span>Cancel</span></button>
    @else
        <a href="{{ route('services.index') }}" class="btn btn-outline-secondary"><i data-lucide="x"></i><span>Cancel</span></a>
    @endif
    <button class="btn btn-primary"><i data-lucide="save"></i><span>Save Service</span></button>
</div>
