@extends('layouts.pembimbing-sekolah')

@section('title', 'Dashboard - Pembimbing Sekolah')
@section('page-title', 'Dashboard')

@section('content')

<div class="row g-3 g-md-4 mb-4">
    <div class="col-6 col-md-3">
        <div class="card text-white" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
            <div class="card-body text-center py-3">
                <i class="fas fa-users fa-lg fa-md-2x mb-2 mb-md-3"></i>
                <h4 class="h5 h3-md fw-bold">{{ $totalSiswa }}</h4>
                <p class="mb-0 small">Total Siswa Bimbingan</p>
            </div>
        </div>
    </div>
    <div class="col-6 col-md-3">
        <div class="card text-white" style="background: linear-gradient(135deg, #28a745 0%, #20c997 100%);">
            <div class="card-body text-center py-3">
                <i class="fas fa-user-check fa-lg fa-md-2x mb-2 mb-md-3"></i>
                <h4 class="h5 h3-md fw-bold">{{ $siswaAktif }}</h4>
                <p class="mb-0 small">Siswa Aktif</p>
            </div>
        </div>
    </div>
    <div class="col-6 col-md-3">
        <div class="card text-white" style="background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);">
            <div class="card-body text-center py-3">
                <i class="fas fa-book fa-lg fa-md-2x mb-2 mb-md-3"></i>
                <h4 class="h5 h3-md fw-bold">{{ $jurnalStats['total'] }}</h4>
                <p class="mb-0 small">Total Jurnal</p>
            </div>
        </div>
    </div>
    <div class="col-6 col-md-3">
        <div class="card text-white" style="background: linear-gradient(135deg, #17a2b8 0%, #6f42c1 100%);">
            <div class="card-body text-center py-3">
                <i class="fas fa-calendar-alt fa-lg fa-md-2x mb-2 mb-md-3"></i>
                <h4 class="h5 h3-md fw-bold">{{ $jurnalStats['bulan_ini'] }}</h4>
                <p class="mb-0 small">Jurnal Bulan Ini</p>
            </div>
        </div>
    </div>
</div>

<div class="row g-3 g-md-4">
    <div class="col-12 col-lg-8">
        <div class="card">
            <div class="card-header bg-primary text-white">
                <h5 class="mb-0"><i class="fas fa-book me-2"></i>Jurnal Terbaru Siswa</h5>
            </div>
            <div class="card-body p-2 p-md-3">
                @if($jurnalTerbaru->count() > 0)
                    <div class="table-responsive">
                        <table class="table table-hover mb-0 table-sm">
                            <thead class="table-light">
                                <tr>
                                    <th class="small">Tanggal</th>
                                    <th class="small">Nama Siswa</th>
                                    <th class="small d-none d-sm-table-cell">Kegiatan</th>
                                    <th class="small">Status</th>
                                    <th class="small">Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($jurnalTerbaru as $jurnal)
                                <tr>
                                    <td class="small">
                                        <strong>{{ \Carbon\Carbon::parse($jurnal->tanggal)->format('d M') }}</strong>
                                        <br><small class="text-muted d-none d-md-inline">{{ \Carbon\Carbon::parse($jurnal->tanggal)->format('Y') }}</small>
                                    </td>
                                    <td class="small">
                                        <strong>{{ $jurnal->user->siswa->nama_siswa ?? $jurnal->user->name }}</strong>
                                        @if($jurnal->user->siswa && $jurnal->user->siswa->sekolah)
                                            <br><small class="text-muted d-none d-md-inline">{{ $jurnal->user->siswa->sekolah->nama_sekolah }}</small>
                                        @endif
                                    </td>
                                    <td class="small d-none d-sm-table-cell">{{ \Str::limit($jurnal->perencanaan_kegiatan, 40) }}</td>
                                    <td>
                                        @if($jurnal->status_verifikasi == 'pending')
                                            <span class="badge bg-warning small">Pending</span>
                                        @elseif($jurnal->status_verifikasi == 'diterima')
                                            <span class="badge bg-success small">Diterima</span>
                                        @else
                                            <span class="badge bg-danger small">Ditolak</span>
                                        @endif
                                    </td>
                                    <td>
                                        <a href="{{ route('pembimbing-sekolah.jurnal', $jurnal->id) }}" 
                                           class="btn btn-info btn-sm">
                                            <i class="fas fa-eye"></i>
                                        </a>
                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                    
                @else
                    <div class="text-center text-muted py-4">
                        <i class="fas fa-book fa-2x fa-md-3x mb-3"></i>
                        <p class="small">Belum ada jurnal dari siswa</p>
                    </div>
                @endif
            </div>
        </div>
    </div>
    
    <div class="col-12 col-lg-4">
        <div class="card">
            <div class="card-header bg-success text-white">
                <h5 class="mb-0"><i class="fas fa-bolt me-2"></i>Menu Cepat</h5>
            </div>
            <div class="card-body">
                <div class="d-grid gap-2 gap-md-3">
                    <a href="{{ route('pembimbing-sekolah.siswa') }}" class="btn btn-primary">
                        <i class="fas fa-users me-2"></i>Lihat Data Siswa
                    </a>
                    <a href="{{ route('pembimbing-sekolah.jurnal') }}" class="btn btn-info">
                        <i class="fas fa-book me-2"></i>Monitor Jurnal
                    </a>
                    
                    <!-- Statistik Jurnal Card -->
                    <div class="alert alert-light mb-0 py-3">
                        <div class="row text-center">
                            <div class="col-4">
                                <div class="h6 fw-bold text-info mb-1">{{ $jurnalStats['total'] }}</div>
                                <small class="text-muted">Total</small>
                            </div>
                            <div class="col-4">
                                <div class="h6 fw-bold text-warning mb-1">{{ $jurnalStats['bulan_ini'] }}</div>
                                <small class="text-muted">Bulan Ini</small>
                            </div>
                            <div class="col-4">
                                <div class="h6 fw-bold text-success mb-1">{{ $siswaAktif }}</div>
                                <small class="text-muted">Aktif</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection