@extends('layouts.guru')

@section('title', 'Kelas ' . $kelas->nama_kelas . ' - SIPENA Guru')
@section('page_title', 'Detail Kelas')

@section('content')
<div style="margin-bottom: 20px;">
    <a href="{{ route('guru.kelas.index') }}" style="display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: #475569; font-weight: 600; font-size: 0.92rem;">
        <i class="fa-solid fa-arrow-left"></i> Kembali ke Daftar Kelas
    </a>
</div>

<div class="class-detail-header">
    <div>
        <h1>Kelas {{ $kelas->nama_kelas }}</h1>
        <div class="class-meta">
            <span><i class="fa-solid fa-users"></i> {{ $siswaCount }} Siswa</span>
            <span><i class="fa-solid fa-calendar-days"></i> {{ $scheduleCount }} Jadwal</span>
            <span><i class="fa-solid fa-book"></i> {{ $subjectList->count() }} Mata Pelajaran</span>
        </div>
    </div>
    <i class="fa-solid fa-school"></i>
</div>

<div class="section-title">
    <h2>Pilih Mata Pelajaran</h2>
    <p>Pilih mata pelajaran terlebih dahulu sebelum mengelola materi, tugas, nilai, atau data kelas.</p>
</div>

<div class="subject-grid">
    @forelse($subjectSchedules as $item)
        @php
            $mapel = $item['mapel'];
            $hariText = $item['hari']->implode(', ');
        @endphp
        <a href="{{ route('guru.kelas.mapel', [$kelas->id, $mapel->id]) }}" class="subject-card">
            <div class="subject-icon">
                <i class="fa-solid fa-book-open-reader"></i>
            </div>
            <div class="subject-content">
                <h3>{{ $mapel->nama_mapel }}</h3>
                <div class="subject-meta">
                    <span><i class="fa-solid fa-calendar-day"></i> {{ $hariText ?: '-' }}</span>
                    <span><i class="fa-solid fa-clock"></i> {{ $item['schedule_count'] }} Jadwal</span>
                </div>
            </div>
            <i class="fa-solid fa-arrow-right subject-arrow"></i>
        </a>
    @empty
        <div class="empty-subject">
            <i class="fa-solid fa-book-circle-xmark"></i>
            <h3>Belum ada mata pelajaran</h3>
            <p>Jadwal mata pelajaran untuk kelas ini belum tersedia.</p>
        </div>
    @endforelse
</div>

<div class="class-actions">
    <a href="{{ route('guru.kelas.anggota', $kelas->id) }}" class="secondary-action">
        <i class="fa-solid fa-users-line"></i> Lihat Anggota Kelas
    </a>
    <a href="{{ route('guru.kelas.absensi', $kelas->id) }}" class="secondary-action">
        <i class="fa-solid fa-user-check"></i> Absensi Kelas
    </a>
</div>

<style>
    .class-detail-header {
        background: linear-gradient(135deg, #1e3a8a, #2563eb);
        border-radius: 12px;
        padding: 26px 32px;
        color: #fff;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 18px;
        margin-bottom: 24px;
    }

    .class-detail-header h1 {
        margin: 0;
        font-size: 2rem;
        line-height: 1.2;
        font-weight: 800;
    }

    .class-detail-header > i {
        font-size: 3rem;
        opacity: 0.25;
    }

    .class-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        margin-top: 10px;
        font-size: 0.95rem;
        opacity: 0.92;
    }

    .class-meta span,
    .subject-meta span {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .section-title {
        margin-bottom: 16px;
    }

    .section-title h2 {
        margin: 0 0 4px 0;
        color: #0f172a;
        font-size: 1.25rem;
        font-weight: 800;
    }

    .section-title p {
        margin: 0;
        color: #64748b;
        font-size: 0.94rem;
    }

    .subject-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 18px;
    }

    .subject-card {
        background: #fff;
        border: 1px solid #cbd5e1;
        border-radius: 10px;
        padding: 18px;
        display: flex;
        align-items: center;
        gap: 14px;
        text-decoration: none;
        color: inherit;
        transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    }

    .subject-card:hover {
        transform: translateY(-2px);
        border-color: #2563eb;
        box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
    }

    .subject-icon {
        width: 46px;
        height: 46px;
        border-radius: 10px;
        background: #eff6ff;
        color: #2563eb;
        display: grid;
        place-items: center;
        font-size: 1.25rem;
        flex: 0 0 auto;
    }

    .subject-content {
        min-width: 0;
        flex: 1;
    }

    .subject-content h3 {
        margin: 0 0 8px 0;
        color: #0f172a;
        font-size: 1.05rem;
        font-weight: 800;
    }

    .subject-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        color: #64748b;
        font-size: 0.84rem;
    }

    .subject-arrow {
        color: #94a3b8;
        flex: 0 0 auto;
    }

    .class-actions {
        margin-top: 22px;
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
    }

    .secondary-action {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        background: #fff;
        color: #475569;
        text-decoration: none;
        font-weight: 700;
        font-size: 0.9rem;
    }

    .secondary-action:hover {
        color: #2563eb;
        border-color: #93c5fd;
    }

    .empty-subject {
        grid-column: 1 / -1;
        text-align: center;
        background: #fff;
        border: 2px dashed #cbd5e1;
        border-radius: 12px;
        padding: 38px 18px;
        color: #64748b;
    }

    .empty-subject i {
        font-size: 2.5rem;
        color: #94a3b8;
        margin-bottom: 12px;
    }

    .empty-subject h3 {
        margin: 0 0 6px 0;
        color: #0f172a;
    }
</style>
@endsection
