<template>
  <AppLayout title="Classroom Details">
    <div class="space-y-6">
      <!-- Header -->
      <div class="flex items-center justify-between">
        <div>
          <h1 class="text-3xl font-bold tracking-tight">{{ classroom.name }}</h1>
          <p class="text-muted-foreground">{{ classroom.academicYear?.name }}</p>
        </div>
        <div class="flex space-x-3">
          <Button variant="outline" as-child>
            <Link :href="route('classrooms.edit', classroom.id)">
              <Edit class="mr-2 h-4 w-4" />
              Edit Classroom
            </Link>
          </Button>
          <Button variant="outline" as-child>
            <Link :href="route('classrooms.index')">
              <ArrowLeft class="mr-2 h-4 w-4" />
              Back to Classrooms
            </Link>
          </Button>
        </div>
      </div>

      <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
        <Card>
          <CardHeader>
            <CardTitle>Classroom Information</CardTitle>
          </CardHeader>
          <CardContent class="space-y-4">
            <div class="grid grid-cols-1 gap-4">
              <div>
                <Label class="text-sm font-medium text-muted-foreground">Name</Label>
                <p class="text-sm">{{ classroom.name }}</p>
              </div>
              <div>
                <Label class="text-sm font-medium text-muted-foreground">Academic Year</Label>
                <p class="text-sm">{{ classroom.academicYear?.name }}</p>
              </div>
              <div>
                <Label class="text-sm font-medium text-muted-foreground">Capacity</Label>
                <p class="text-sm">{{ classroom.capacity }} students</p>
              </div>
              <div>
                <Label class="text-sm font-medium text-muted-foreground">Description</Label>
                <p class="text-sm">{{ classroom.description || 'No description provided' }}</p>
              </div>
            </div>
          </CardContent>
        </Card>

        <Card v-if="classroom.subjects?.length">
          <CardHeader>
            <CardTitle>Subjects</CardTitle>
          </CardHeader>
          <CardContent>
            <div class="space-y-2">
              <div v-for="subject in classroom.subjects" :key="subject.id" 
                   class="p-2 border rounded-lg">
                <p class="font-medium">{{ subject.name }}</p>
                <p class="text-sm text-muted-foreground">{{ subject.code }}</p>
              </div>
            </div>
          </CardContent>
        </Card>
      </div>
    </div>
  </AppLayout>
</template>

<script setup lang="ts">
import { Link } from '@inertiajs/vue3'
import AppLayout from '@/layouts/AppLayout.vue'
import { Button } from '@/components/ui/button'
import { Label } from '@/components/ui/label'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Edit, ArrowLeft } from 'lucide-vue-next'

const props = defineProps<{
  classroom: any
}>()
</script>
