@extends('layouts.app')

@section('content')
<div class="container-xxl flex-grow-1 container-p-y">
  <div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
      <div>
        <h5 class="mb-0">Submission #{{ $submission->id }}</h5>
        <small class="text-muted">
          Assignment: {{ $submission->assignment->title ?? '-' }} •
          Student: {{ $submission->student->name ?? '-' }} (ID: {{ $submission->student_id }})
        </small>
      </div>
      <div class="d-flex gap-2">
        @can('update assignment submissions')
          <a href="{{ route('assignment-submissions.edit', $submission) }}" class="btn btn-outline-warning btn-sm">Edit</a>
        @endcan
        <a href="{{ route('assignment-submissions.index') }}" class="btn btn-outline-secondary btn-sm">Back</a>
      </div>
    </div>
    <hr class="mb-0"/>

    <div class="card-body">
      @if(session('success')) <div class="alert alert-success">{{ session('success') }}</div> @endif

      <div class="border rounded p-3">
        <div class="mb-2"><strong>Submitted At:</strong> {{ optional($submission->submitted_at)->format('Y-m-d H:i') }}</div>
        <div class="mb-2"><strong>Grade:</strong> {{ $submission->grade ?? '-' }}</div>
        <div class="mb-2"><strong>File:</strong>
          @if($submission->file_path)
            <a href="{{ asset($submission->file_path) }}" target="_blank">View / Download</a>
          @else
            -
          @endif
        </div>
      </div>
    </div>
  </div>
</div>
@endsection