<?php $__env->startSection('title', 'Dashboard'); ?>

<?php $__env->startSection('content'); ?>
<div class="glass-card mb-4" style="animation: fadeInUp 0.6s ease-out;">
    <div class="d-flex align-items-center">
        <div class="me-3">
            <i class="fas fa-user-circle fa-3x text-gradient"></i>
        </div>
        <div class="flex-grow-1">
            <h4 class="mb-1 text-gradient">Selamat Datang, <?php echo e(Auth::user()->name); ?>!</h4>
            <p class="mb-0 text-charcoal-600">
                <span class="badge bg-gradient-to-r from-cream-400 to-cream-500 text-charcoal-900 me-2"><?php echo e(ucfirst(Auth::user()->role)); ?></span>
                <span class="text-charcoal-500"><?php echo e(Auth::user()->email); ?></span>
            </p>
        </div>
    </div>
</div>

<?php if(Auth::user()->isCustomer()): ?>
    <!-- Customer Dashboard -->
    <div class="stats-flow mb-5">
        <div class="stat-bubble" style="animation: fadeInUp 0.8s ease-out; animation-delay: 0.1s;">
            <div class="bubble-content">
                <div class="bubble-icon">
                    <i class="fas fa-calendar"></i>
                </div>
                <div class="bubble-info">
                    <div class="bubble-number"><?php echo e($totalBookings ?? 0); ?></div>
                    <div class="bubble-label">Total Booking</div>
                </div>
            </div>
        </div>
        
        <div class="stat-bubble" style="animation: fadeInUp 0.8s ease-out; animation-delay: 0.2s;">
            <div class="bubble-content">
                <div class="bubble-icon pending">
                    <i class="fas fa-clock"></i>
                </div>
                <div class="bubble-info">
                    <div class="bubble-number"><?php echo e($pendingBookings ?? 0); ?></div>
                    <div class="bubble-label">Pending</div>
                </div>
            </div>
        </div>
        
        <div class="stat-bubble" style="animation: fadeInUp 0.8s ease-out; animation-delay: 0.3s;">
            <div class="bubble-content">
                <div class="bubble-icon confirmed">
                    <i class="fas fa-check-circle"></i>
                </div>
                <div class="bubble-info">
                    <div class="bubble-number"><?php echo e(($totalBookings ?? 0) - ($pendingBookings ?? 0)); ?></div>
                    <div class="bubble-label">Confirmed</div>
                </div>
            </div>
        </div>
        
        <div class="stat-bubble" style="animation: fadeInUp 0.8s ease-out; animation-delay: 0.4s;">
            <div class="bubble-content">
                <div class="bubble-icon history">
                    <i class="fas fa-history"></i>
                </div>
                <div class="bubble-info">
                    <div class="bubble-number"><?php echo e(($totalBookings ?? 0) - ($pendingBookings ?? 0)); ?></div>
                    <div class="bubble-label">Riwayat</div>
                </div>
            </div>
        </div>
    </div>
    
    <div class="flow-card" style="animation: fadeInUp 1s ease-out;">
        <div class="flow-header">
            <div class="flow-title">
                <div class="title-icon">
                    <i class="fas fa-calendar"></i>
                </div>
                <h3>Booking Terbaru</h3>
            </div>
            <a href="<?php echo e(route('bookings.create')); ?>" class="flow-btn">
                <i class="fas fa-plus"></i>
                <span>Buat Booking</span>
            </a>
        </div>
        <div class="flow-content">
            <?php if(isset($bookings) && $bookings->count() > 0): ?>
                <div class="flow-table">
                    <?php $__currentLoopData = $bookings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $booking): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="flow-row" style="animation: slideInLeft 0.5s ease-out; animation-delay: <?php echo e($loop->index * 0.1); ?>s;">
                            <div class="row-code">
                                <span class="code-badge">BK<?php echo e(str_pad($booking->id, 3, '0', STR_PAD_LEFT)); ?></span>
                            </div>
                            <div class="row-field">
                                <div class="field-info">
                                    <i class="fas fa-map-marker-alt"></i>
                                    <span><?php echo e($booking->lapangan->nama ?? '-'); ?></span>
                                </div>
                            </div>
                            <div class="row-date">
                                <div class="date-info">
                                    <i class="fas fa-calendar-day"></i>
                                    <span><?php echo e($booking->tanggal->format('Y-m-d')); ?></span>
                                </div>
                            </div>
                            <div class="row-time">
                                <div class="time-info">
                                    <i class="fas fa-clock"></i>
                                    <span><?php echo e(\Carbon\Carbon::parse($booking->jam_mulai)->format('H:i')); ?> - <?php echo e(\Carbon\Carbon::parse($booking->jam_selesai)->format('H:i')); ?></span>
                                </div>
                            </div>
                            <div class="row-price">
                                <div class="price-info">
                                    <i class="fas fa-tag"></i>
                                    <span><?php echo e(formatRupiah($booking->total_harga)); ?></span>
                                </div>
                            </div>
                            <div class="row-status">
                                <?php echo getStatusBadge($booking->status); ?>

                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            <?php else: ?>
                <div class="empty-state" style="animation: fadeInUp 1.2s ease-out;">
                    <div class="empty-icon">
                        <i class="fas fa-calendar"></i>
                    </div>
                    <h3>Belum ada booking</h3>
                    <p>Mulai buat booking pertama Anda sekarang</p>
                    <a href="<?php echo e(route('bookings.create')); ?>" class="flow-btn primary">
                        <i class="fas fa-plus"></i>
                        <span>Buat Booking Pertama</span>
                    </a>
                </div>
            <?php endif; ?>
        </div>
    </div>

<?php elseif(Auth::user()->isManager()): ?>
    <!-- Manager Dashboard -->
    <div class="row mb-4">
        <div class="col-md-3">
            <div class="card bg-warning text-white">
                <div class="card-body">
                    <h5><i class="fas fa-clock me-2"></i>Pending</h5>
                    <h3><?php echo e($pendingCount ?? 0); ?></h3>
                    <small>Menunggu Konfirmasi</small>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card bg-success text-white">
                <div class="card-body">
                    <h5><i class="fas fa-check-circle me-2"></i>Confirmed</h5>
                    <h3><?php echo e(($todayCount ?? 0) - ($pendingCount ?? 0)); ?></h3>
                    <small>Dikonfirmasi</small>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card bg-info text-white">
                <div class="card-body">
                    <h5><i class="fas fa-calendar-check me-2"></i>Today</h5>
                    <h3><?php echo e($todayCount ?? 0); ?></h3>
                    <small>Booking Hari Ini</small>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card bg-primary text-white">
                <div class="card-body">
                    <h5><i class="fas fa-money-bill-wave me-2"></i>Revenue</h5>
                    <h3><?php echo e(formatRupiah(0)); ?></h3>
                    <small>Total Pendapatan</small>
                </div>
            </div>
        </div>
    </div>
    
    <div class="card">
        <div class="card-header">
            <h5><i class="fas fa-calendar-check me-2"></i>Booking Terbaru</h5>
        </div>
        <div class="card-body">
            <?php if(isset($bookings) && $bookings->count() > 0): ?>
                <div class="table-responsive">
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>Kode</th>
                                <th>Customer</th>
                                <th>Lapangan</th>
                                <th>Tanggal</th>
                                <th>Status</th>
                                <th>Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $bookings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $booking): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><span class="badge bg-primary">BK<?php echo e(str_pad($booking->id, 3, '0', STR_PAD_LEFT)); ?></span></td>
                                    <td><?php echo e($booking->user->name ?? '-'); ?></td>
                                    <td><?php echo e($booking->lapangan->nama ?? '-'); ?></td>
                                    <td><?php echo e($booking->tanggal->format('Y-m-d')); ?></td>
                                    <td><?php echo getStatusBadge($booking->status); ?></td>
                                    <td>
                                        <a href="<?php echo e(route('bookings.index')); ?>" class="btn btn-sm btn-info">
                                            <i class="fas fa-eye"></i>
                                        </a>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            <?php else: ?>
                <div class="text-center py-5">
                    <i class="fas fa-calendar fa-3x text-muted mb-3"></i>
                    <h5 class="text-muted">Belum ada booking</h5>
                </div>
            <?php endif; ?>
        </div>
    </div>

<?php elseif(Auth::user()->isAdmin() || Auth::user()->isSuperAdmin()): ?>
    <!-- Admin/SuperAdmin Dashboard -->
    <div class="row mb-4">
        <div class="col-md-3">
            <div class="card bg-primary text-white">
                <div class="card-body">
                    <h5><i class="fas fa-users me-2"></i>Users</h5>
                    <h3><?php echo e($totalUsers ?? 0); ?></h3>
                    <small>Total Users</small>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card bg-success text-white">
                <div class="card-body">
                    <h5><i class="fas fa-map me-2"></i>Lapangan</h5>
                    <h3><?php echo e($totalLapangans ?? 0); ?></h3>
                    <small>Total Lapangan</small>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card bg-warning text-white">
                <div class="card-body">
                    <h5><i class="fas fa-calendar me-2"></i>Bookings</h5>
                    <h3><?php echo e($totalBookings ?? 0); ?></h3>
                    <small>Total Booking</small>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card bg-info text-white">
                <div class="card-body">
                    <h5><i class="fas fa-money-bill-wave me-2"></i>Revenue</h5>
                    <h3><?php echo e(formatRupiah($totalIncome ?? 0)); ?></h3>
                    <small>Total Pendapatan</small>
                </div>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h5><i class="fas fa-exclamation-circle me-2"></i>Booking Pending</h5>
                </div>
                <div class="card-body">
                    <h3 class="text-warning"><?php echo e($pendingBookings ?? 0); ?></h3>
                    <p class="text-muted">Menunggu konfirmasi</p>
                    <a href="<?php echo e(route('bookings.index')); ?>?status=pending" class="btn btn-warning">
                        <i class="fas fa-eye me-2"></i>Lihat Semua
                    </a>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h5><i class="fas fa-calendar me-2"></i>Booking Terbaru</h5>
                </div>
                <div class="card-body">
                    <?php if(isset($recentBookings) && $recentBookings->count() > 0): ?>
                        <div class="list-group">
                            <?php $__currentLoopData = $recentBookings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $booking): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="list-group-item">
                                    <div class="d-flex justify-content-between align-items-center">
                                        <div>
                                            <strong>BK<?php echo e(str_pad($booking->id, 3, '0', STR_PAD_LEFT)); ?></strong>
                                            <br>
                                            <small><?php echo e($booking->user->name ?? '-'); ?> - <?php echo e($booking->lapangan->nama ?? '-'); ?></small>
                                        </div>
                                        <span class="badge bg-<?php echo e($booking->status === 'confirmed' ? 'success' : ($booking->status === 'pending' ? 'warning' : 'danger')); ?>">
                                            <?php echo e(ucfirst($booking->status)); ?>

                                        </span>
                                    </div>
                                </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                    <?php else: ?>
                        <p class="text-muted">Belum ada booking</p>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
    
    <div class="row mt-4">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <h5><i class="fas fa-bolt me-2"></i>Quick Actions</h5>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-3">
                            <a href="<?php echo e(route('users.index')); ?>" class="btn btn-primary w-100 mb-2">
                                <i class="fas fa-users me-2"></i>Kelola User
                            </a>
                        </div>
                        <div class="col-md-3">
                            <a href="<?php echo e(route('lapangans.index')); ?>" class="btn btn-success w-100 mb-2">
                                <i class="fas fa-map me-2"></i>Kelola Lapangan
                            </a>
                        </div>
                        <div class="col-md-3">
                            <a href="<?php echo e(route('bookings.index')); ?>" class="btn btn-warning w-100 mb-2">
                                <i class="fas fa-calendar me-2"></i>Semua Booking
                            </a>
                        </div>
                        <div class="col-md-3">
                            <a href="<?php echo e(route('keuangan.index')); ?>" class="btn btn-info w-100 mb-2">
                                <i class="fas fa-money-bill-wave me-2"></i>Keuangan
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php endif; ?>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\yukig\Downloads\Manfutsal\resources\views/dashboard.blade.php ENDPATH**/ ?>