@extends('layouts.teacher')
@section('title', 'Student Leadership')
@section('content')
    <x-page-head title="Student Leadership" subtitle="Assign roles to your students" />
    <x-panel>
        @if ($students->isEmpty())
            <x-empty-state title="No students" message="You can assign leadership roles to students in your classes." />
        @else
            <div class="table-wrap"><table><thead><tr><th>Student</th><th>Current Role</th><th>Assign Role</th></tr></thead><tbody>
                @foreach ($students as $student)
                    <tr>
                        <td>{{ $student->full_name }}</td>
                        <td>{{ $leadershipRoles[$student->leadership_role] ?? ($student->leadership_role ? ucfirst($student->leadership_role) : '—') }}</td>
                        <td>
                            <form method="POST" action="{{ route('teacher.leadership.update', $student) }}" style="display:flex; gap:8px; align-items:center;">
                                @csrf @method('PUT')
                                <select class="input" name="leadership_role" style="min-width:180px;">
                                    <option value="">— None —</option>
                                    @foreach ($leadershipRoles as $key => $label)
                                        <option value="{{ $key }}" @selected($student->leadership_role === $key)>{{ $label }}</option>
                                    @endforeach
                                </select>
                                <button type="submit" class="btn btn-primary btn-sm">Save</button>
                            </form>
                        </td>
                    </tr>
                @endforeach
            </tbody></table></div>
        @endif
    </x-panel>
@endsection
