@extends('layouts.app')

@section('title', 'Detail Data Siswa')

@section('content')
<div class="container-fluid">
    <div class="row mb-3">
        <div class="col-12">
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="{{ route('students.index') }}">Data Siswa</a></li>
                    <li class="breadcrumb-item active">Detail</li>
                </ol>
            </nav>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-8">
            <div class="card shadow-sm">
                <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
                    <h5 class="mb-0">Detail Data Siswa</h5>
                    <div>
                        <a href="{{ route('students.edit', $student) }}" class="btn btn-light btn-sm">
                            <i class="bi bi-pencil me-1"></i> Edit
                        </a>
                        <a href="{{ route('students.index') }}" class="btn btn-outline-light btn-sm">
                            <i class="bi bi-arrow-left me-1"></i> Kembali
                        </a>
                    </div>
                </div>
                <div class="card-body">
                    <h6 class="border-bottom pb-2 mb-3 text-primary">
                        <i class="bi bi-building me-1"></i> Informasi Sekolah
                    </h6>
                    <div class="row mb-4">
                        <div class="col-md-6">
                            <dl class="row">
                                <dt class="col-sm-4">Nama Sekolah:</dt>
                                <dd class="col-sm-8"><strong>{{ $student->school->name }}</strong></dd>
                                
                                <dt class="col-sm-4">NPSN:</dt>
                                <dd class="col-sm-8">{{ $student->school->npsn }}</dd>
                                
                                <dt class="col-sm-4">Jenjang:</dt>
                                <dd class="col-sm-8">
                                    <span class="badge bg-info">{{ $student->school->level }}</span>
                                </dd>
                            </dl>
                        </div>
                        <div class="col-md-6">
                            <dl class="row">
                                <dt class="col-sm-4">Alamat:</dt>
                                <dd class="col-sm-8">{{ $student->school->address }}</dd>
                            </dl>
                        </div>
                    </div>

                    <h6 class="border-bottom pb-2 mb-3 text-primary">
                        <i class="bi bi-person-circle me-1"></i> Data Identitas
                    </h6>
                    <div class="row mb-4">
                        <div class="col-md-6">
                            <dl class="row">
                                <dt class="col-sm-4">Nama Lengkap:</dt>
                                <dd class="col-sm-8"><strong class="text-dark fs-5">{{ $student->nama }}</strong></dd>
                                
                                <dt class="col-sm-4">NIK:</dt>
                                <dd class="col-sm-8">{{ $student->nik }}</dd>
                                
                                <dt class="col-sm-4">NISN:</dt>
                                <dd class="col-sm-8">{{ $student->nisn }}</dd>
                                
                                <dt class="col-sm-4">NIS:</dt>
                                <dd class="col-sm-8">{{ $student->nis }}</dd>
                            </dl>
                        </div>
                        <div class="col-md-6">
                            <dl class="row">
                                <dt class="col-sm-4">Kelas:</dt>
                                <dd class="col-sm-8">
                                    <span class="badge bg-info fs-6">{{ $student->kelas }}</span>
                                </dd>
                                
                                <dt class="col-sm-4">Jenis Kelamin:</dt>
                                <dd class="col-sm-8">
                                    @if($student->jenis_kelamin)
                                        {{ $student->jenis_kelamin == 'L' ? 'Laki-laki' : 'Perempuan' }}
                                    @else
                                        <span class="text-muted">-</span>
                                    @endif
                                </dd>
                            </dl>
                        </div>
                    </div>

                    <h6 class="border-bottom pb-2 mb-3 text-primary">
                        <i class="bi bi-calendar-event me-1"></i> Tempat & Tanggal Lahir
                    </h6>
                    <div class="row mb-4">
                        <div class="col-md-6">
                            <dl class="row">
                                <dt class="col-sm-4">Tempat Lahir:</dt>
                                <dd class="col-sm-8">{{ $student->tempat_lahir }}</dd>
                                
                                <dt class="col-sm-4">Tanggal Lahir:</dt>
                                <dd class="col-sm-8">{{ $student->tanggal_lahir->format('d F Y') }}</dd>
                            </dl>
                        </div>
                        <div class="col-md-6">
                            <dl class="row">
                                <dt class="col-sm-4">Usia:</dt>
                                <dd class="col-sm-8">
                                    <strong>{{ $student->age }} tahun</strong>
                                </dd>
                            </dl>
                        </div>
                    </div>

                    <h6 class="border-bottom pb-2 mb-3 text-primary">
                        <i class="bi bi-info-circle me-1"></i> Informasi Tambahan
                    </h6>
                    <div class="row mb-4">
                        <div class="col-md-6">
                            <dl class="row">
                                <dt class="col-sm-4">Nama Ibu:</dt>
                                <dd class="col-sm-8">{{ $student->nama_ibu }}</dd>
                                
                                <dt class="col-sm-4">Jenis Ketunaan:</dt>
                                <dd class="col-sm-8">
                                    @if($student->disabilityType)
                                        <span class="badge bg-warning text-dark">{{ $student->disabilityType->code }}</span>
                                        <strong>{{ $student->disabilityType->name }}</strong>
                                        @if($student->disabilityType->description)
                                            <br><small class="text-muted">{{ $student->disabilityType->description }}</small>
                                        @endif
                                    @else
                                        <span class="text-muted">Tidak ada</span>
                                    @endif
                                </dd>
                            </dl>
                        </div>
                        <div class="col-md-6">
                            <dl class="row">
                                <dt class="col-sm-4">Alamat:</dt>
                                <dd class="col-sm-8">{{ $student->alamat ?? '-' }}</dd>
                                
                                <dt class="col-sm-4">Nomor Telepon:</dt>
                                <dd class="col-sm-8">{{ $student->phone ?? '-' }}</dd>
                            </dl>
                        </div>
                    </div>

                    <h6 class="border-bottom pb-2 mb-3 text-primary">
                        <i class="bi bi-clock-history me-1"></i> Informasi Sistem
                    </h6>
                    <div class="row">
                        <div class="col-md-6">
                            <dl class="row">
                                <dt class="col-sm-4">Dibuat Pada:</dt>
                                <dd class="col-sm-8">{{ $student->created_at->format('d F Y, H:i') }} WIB</dd>
                            </dl>
                        </div>
                        <div class="col-md-6">
                            <dl class="row">
                                <dt class="col-sm-4">Terakhir Diubah:</dt>
                                <dd class="col-sm-8">{{ $student->updated_at->format('d F Y, H:i') }} WIB</dd>
                            </dl>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-lg-4">
            <div class="card shadow-sm mb-3">
                <div class="card-header bg-success text-white">
                    <h6 class="mb-0"><i class="bi bi-card-checklist me-1"></i> Status</h6>
                </div>
                <div class="card-body">
                    <div class="d-flex align-items-center justify-content-between mb-3">
                        <span>Status Siswa:</span>
                        <span class="badge {{ $student->is_active ? 'bg-success' : 'bg-secondary' }} fs-6">
                            {{ $student->is_active ? 'Aktif' : 'Nonaktif' }}
                        </span>
                    </div>
                    
                    <hr>
                    
                    <div class="text-center">
                        <div class="mb-2">
                            <i class="bi bi-person-badge display-1 text-primary"></i>
                        </div>
                        <h5 class="mb-1">{{ $student->nama }}</h5>
                        <p class="text-muted mb-0">{{ $student->nis }}</p>
                    </div>
                </div>
            </div>

            <div class="card shadow-sm">
                <div class="card-header bg-warning">
                    <h6 class="mb-0"><i class="bi bi-tools me-1"></i> Aksi</h6>
                </div>
                <div class="card-body">
                    <div class="d-grid gap-2">
                        <a href="{{ route('students.edit', $student) }}" class="btn btn-primary">
                            <i class="bi bi-pencil me-1"></i> Edit Data
                        </a>
                        
                        <form action="{{ route('students.destroy', $student) }}" 
                              method="POST"
                              onsubmit="return confirm('Yakin ingin menghapus data siswa ini? Data yang sudah dihapus tidak dapat dikembalikan.')">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-danger w-100">
                                <i class="bi bi-trash me-1"></i> Hapus Data
                            </button>
                        </form>
                        
                        <a href="{{ route('students.index') }}" class="btn btn-secondary">
                            <i class="bi bi-arrow-left me-1"></i> Kembali ke Daftar
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
