@extends('layouts.app')
@section('title','Edit Case — '.$discipline->case_number)
@section('page-title','Discipline Management')

@section('content')
<div class="page-header">
    <div class="d-flex align-items-center gap-2">
        <a href="{{ route('discipline.show', $discipline) }}" class="btn btn-sm btn-outline-secondary"><i class="bi bi-arrow-left"></i></a>
        <div>
            <h1>Edit Case: {{ $discipline->case_number }}</h1>
            <nav aria-label="breadcrumb"><ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="{{ route('discipline.index') }}">Discipline</a></li>
                <li class="breadcrumb-item"><a href="{{ route('discipline.show', $discipline) }}">{{ $discipline->case_number }}</a></li>
                <li class="breadcrumb-item active">Edit</li>
            </ol></nav>
        </div>
    </div>
</div>

<div class="row g-3">
    <div class="col-12 col-lg-8">
        <div class="card">
            <div class="card-header"><i class="bi bi-shield-exclamation me-2" style="color:var(--ul-primary);"></i>Case Information</div>
            <div class="card-body">
                <form method="POST" action="{{ route('discipline.update', $discipline) }}">
                @csrf @method('PUT')
                <div class="row g-3">
                    <div class="col-12 col-sm-6">
                        <label class="form-label">Employee</label>
                        <input type="text" class="form-control" value="{{ $discipline->employee->full_name ?? '—' }}" disabled>
                    </div>
                    <div class="col-12 col-sm-6">
                        <label class="form-label">Infraction Type *</label>
                        <select name="infraction_type" class="form-select" required>
                            @foreach(['Attendance','Insubordination','Misconduct','Policy Violation','Harassment','Gross Negligence','Theft','Other'] as $t)
                            <option value="{{ $t }}" {{ old('infraction_type',$discipline->infraction_type)===$t?'selected':'' }}>{{ $t }}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="col-6">
                        <label class="form-label">Incident Date *</label>
                        <input type="date" name="incident_date" class="form-control" value="{{ old('incident_date', $discipline->incident_date?->format('Y-m-d')) }}" required>
                    </div>
                    <div class="col-6">
                        <label class="form-label">Location</label>
                        <input type="text" name="location" class="form-control" value="{{ old('location', $discipline->location) }}">
                    </div>
                    <div class="col-12">
                        <label class="form-label">Description *</label>
                        <textarea name="description" class="form-control" rows="4" required>{{ old('description', $discipline->description) }}</textarea>
                    </div>
                    <div class="col-12">
                        <label class="form-label">Evidence / Witnesses</label>
                        <textarea name="evidence" class="form-control" rows="3">{{ old('evidence', $discipline->evidence) }}</textarea>
                    </div>
                    <div class="col-6">
                        <label class="form-label">Status</label>
                        <select name="status" class="form-select">
                            @foreach(['open','in_progress','resolved','closed'] as $s)
                            <option value="{{ $s }}" {{ old('status',$discipline->status)===$s?'selected':'' }}>{{ ucfirst(str_replace('_',' ',$s)) }}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="col-12 d-flex gap-2">
                        <button type="submit" class="btn btn-primary"><i class="bi bi-check-lg me-1"></i>Save Changes</button>
                        <a href="{{ route('discipline.show', $discipline) }}" class="btn btn-outline-secondary">Cancel</a>
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
