@extends('layouts.app')
@section('title', 'Edit Student')
@section('page-title', 'Edit Student')
@section('sidebar-nav')
<div class="nav-item"><a href="{{ route('admin.dashboard') }}"><i class="bi bi-grid"></i> Dashboard</a></div>
<div class="nav-item"><a href="{{ route('admin.students.index') }}"><i class="bi bi-people"></i> Students</a></div>
@endsection

@section('content')
<div class="page-header">
    <div><h1>Edit: {{ $student->user->name }}</h1></div>
    <a href="{{ route('admin.students.show', $student) }}" class="btn btn-secondary"><i class="bi bi-arrow-left"></i> Back</a>
</div>

<div class="card" style="max-width:600px;">
    <div class="card-body">
        <form method="POST" action="{{ route('admin.students.update', $student) }}">
            @csrf @method('PUT')
            <div class="grid grid-2">
                <div class="form-group">
                    <label>Full Name *</label>
                    <input type="text" name="name" value="{{ old('name', $student->user->name) }}" required>
                </div>
                <div class="form-group">
                    <label>Phone</label>
                    <input type="text" name="phone" value="{{ old('phone', $student->user->phone) }}">
                </div>
                <div class="form-group">
                    <label>Stream *</label>
                    <select name="stream_id" required>
                        @foreach($streams as $stream)
                            <option value="{{ $stream->id }}" {{ $student->stream_id == $stream->id ? 'selected' : '' }}>
                                {{ $stream->schoolClass->name }} {{ $stream->name }}
                            </option>
                        @endforeach
                    </select>
                </div>
                <div class="form-group">
                    <label>Gender *</label>
                    <select name="gender" required>
                        <option value="male" {{ $student->gender == 'male' ? 'selected' : '' }}>Male</option>
                        <option value="female" {{ $student->gender == 'female' ? 'selected' : '' }}>Female</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>Status *</label>
                    <select name="status" required>
                        @foreach(['active','transferred','graduated','suspended'] as $s)
                            <option value="{{ $s }}" {{ $student->status == $s ? 'selected' : '' }}>{{ ucfirst($s) }}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <button type="submit" class="btn btn-primary"><i class="bi bi-save"></i> Update Student</button>
        </form>
    </div>
</div>
@endsection
