<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <style>
            .dash-wrap * {
                font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            }

            .dash-header-title {
                font-weight: 600;
                font-size: 1.5rem;
                letter-spacing: -0.01em;
                color: #0f0f0f;
            }

            .dash-date-pill {
                font-size: 0.7rem;
                font-weight: 500;
                letter-spacing: 0.02em;
                color: #888;
                border: 1px solid #e0e0e0;
                padding: 6px 14px;
                border-radius: 100px;
                background: #fafafa;
            }
        </style>
        <div class="flex items-center justify-between">
            <h2 class="dash-header-title">Dashboard</h2>
            <span class="dash-date-pill"><?php echo e(now()->format('l, d F Y')); ?></span>
        </div>
     <?php $__env->endSlot(); ?>

    <style>
        .dash-wrap {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            color: #1a1a1a;
        }

        /* ── STAT CARDS ── */
        .stat-card {
            background: #fff;
            border: 1px solid #ebebeb;
            border-radius: 12px;
            padding: 24px 20px 20px;
            position: relative;
            overflow: hidden;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        .stat-card::before {
            content: '';
            position: absolute;
            top: 0; left: 0; right: 0;
            height: 3px;
            background: #0f0f0f;
            transform: scaleX(0);
            transform-origin: left;
            transition: transform 0.3s ease;
        }

        .stat-card:hover::before { transform: scaleX(1); }
        .stat-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 32px rgba(0,0,0,0.07);
        }

        .stat-label {
            font-size: 0.7rem;
            font-weight: 500;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            color: #999;
            margin-bottom: 8px;
        }

        .stat-value {
            font-size: 2rem;
            font-weight: 600;
            line-height: 1.2;
            color: #0f0f0f;
            letter-spacing: -0.02em;
        }

        .stat-value-sm {
            font-size: 1.6rem;
            font-weight: 600;
            line-height: 1.2;
            color: #0f0f0f;
        }

        .stat-card.danger { border-color: #f0dada; }
        .stat-card.danger::before { background: #c0392b; }
        .stat-card.danger .stat-value { color: #c0392b; }

        /* ── SECTION HEADER ── */
        .section-eyebrow {
            font-size: 0.65rem;
            font-weight: 500;
            letter-spacing: 0.1em;
            text-transform: uppercase;
            color: #bbb;
            margin-bottom: 4px;
        }

        .section-title {
            font-size: 1.3rem;
            font-weight: 600;
            color: #0f0f0f;
            letter-spacing: -0.01em;
        }

        .section-link {
            font-size: 0.7rem;
            font-weight: 500;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            color: #888;
            text-decoration: none;
            border-bottom: 1px solid transparent;
            transition: color 0.2s, border-color 0.2s;
            padding-bottom: 2px;
        }

        .section-link:hover { color: #0f0f0f; border-bottom-color: #0f0f0f; }

        /* ── KURIR MINI CARDS ── */
        .kurir-mini {
            background: #fff;
            border: 1px solid #ebebeb;
            border-radius: 12px;
            padding: 18px 20px;
            transition: box-shadow 0.2s;
        }

        .kurir-mini:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.06); }

        .kurir-mini-label {
            font-size: 0.65rem;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            color: #aaa;
            margin-top: 6px;
            font-weight: 500;
        }

        .kurir-mini-value {
            font-size: 1.8rem;
            font-weight: 600;
            color: #0f0f0f;
            line-height: 1.2;
        }

        .kurir-mini-sub {
            font-size: 0.7rem;
            color: #aaa;
            margin-top: 4px;
        }

        /* ── TABLE ── */
        .dash-table-wrap {
            background: #fff;
            border: 1px solid #ebebeb;
            border-radius: 12px;
            overflow: hidden;
        }

        .dash-table-header {
            padding: 16px 24px;
            border-bottom: 1px solid #f0f0f0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: #fafafa;
        }

        .dash-table-header-title {
            font-size: 0.7rem;
            font-weight: 600;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            color: #888;
        }

        .dash-table-header-badge {
            font-size: 0.65rem;
            letter-spacing: 0.02em;
            color: #bbb;
            background: #f0f0f0;
            padding: 3px 10px;
            border-radius: 100px;
        }

        table.dash-table { width: 100%; border-collapse: collapse; }

        table.dash-table thead th {
            font-size: 0.65rem;
            font-weight: 600;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            color: #999;
            padding: 12px 24px;
            text-align: left;
            background: #fafafa;
            border-bottom: 1px solid #f0f0f0;
        }

        table.dash-table thead th.center { text-align: center; }
        table.dash-table thead th.right { text-align: right; }

        table.dash-table tbody tr {
            border-bottom: 1px solid #f5f5f5;
            transition: background 0.15s;
        }

        table.dash-table tbody tr:last-child { border-bottom: none; }
        table.dash-table tbody tr:hover { background: #fafafa; }

        table.dash-table td {
            padding: 16px 24px;
            font-size: 0.85rem;
            color: #444;
        }

        table.dash-table td.center { text-align: center; }
        table.dash-table td.right { text-align: right; }

        /* ── AVATAR ── */
        .dash-avatar {
            width: 32px; height: 32px;
            border-radius: 50%;
            background: #0f0f0f;
            color: #fff;
            display: flex; align-items: center; justify-content: center;
            font-size: 0.75rem;
            font-weight: 500;
            flex-shrink: 0;
        }

        /* ── BADGES ── */
        .badge {
            display: inline-flex; align-items: center; gap: 6px;
            padding: 4px 10px;
            font-size: 0.65rem;
            font-weight: 500;
            text-transform: uppercase;
            border-radius: 30px;
        }

        .badge-dot {
            width: 6px; height: 6px;
            border-radius: 50%;
            display: inline-block;
        }

        .badge-green { background: #e8f5e9; color: #2e7d32; }
        .badge-green .badge-dot { background: #2e7d32; }
        .badge-gray { background: #f5f5f5; color: #999; }
        .badge-gray .badge-dot { background: #bbb; }
        .badge-yellow { background: #fff8e1; color: #f57f17; }
        .badge-red { background: #ffebee; color: #c62828; }
        .badge-blue { background: #e3f2fd; color: #1565c0; }

        /* ── COUNT BUBBLES ── */
        .count-bubble {
            display: inline-flex; align-items: center; justify-content: center;
            width: 28px; height: 28px;
            border-radius: 50%;
            font-size: 0.75rem;
            font-weight: 600;
        }

        .bubble-orange { background: #fff3e0; color: #e65100; }
        .bubble-blue { background: #e3f2fd; color: #1565c0; }
        .bubble-green { background: #e8f5e9; color: #2e7d32; }

        /* ── ORDER ID ── */
        .order-id {
            font-family: 'SF Mono', 'Courier New', monospace;
            font-size: 0.75rem;
            background: #f5f5f5;
            padding: 4px 8px;
            border-radius: 6px;
            color: #444;
            letter-spacing: 0.01em;
        }

        /* ── LOW STOCK ── */
        .low-stock-card {
            background: #fff;
            border-radius: 12px;
            border: 1px solid #ebebeb;
            border-left: 3px solid #c62828;
            overflow: hidden;
            transition: box-shadow 0.2s;
        }

        .low-stock-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.06); }

        .variant-pill {
            display: inline-flex; align-items: center; gap: 4px;
            font-size: 0.6rem;
            font-weight: 500;
            text-transform: uppercase;
            padding: 3px 8px;
            border-radius: 30px;
        }

        .variant-zero { background: #ffebee; color: #c62828; }
        .variant-low { background: #fff8e1; color: #f57f17; }

        /* ── DIVIDER LINE ── */
        .section-divider {
            height: 1px;
            background: linear-gradient(to right, #e0e0e0, transparent);
            margin-bottom: 32px;
        }

        /* ── EMPTY STATE ── */
        .empty-state {
            padding: 64px 28px;
            text-align: center;
        }

        .empty-state-title {
            font-size: 0.9rem;
            font-weight: 400;
            color: #bbb;
            margin-bottom: 16px;
        }

        .empty-state-link {
            display: inline-block;
            padding: 10px 24px;
            background: #0f0f0f;
            color: #fff;
            font-size: 0.7rem;
            font-weight: 500;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            border-radius: 30px;
            text-decoration: none;
            transition: background 0.2s;
        }

        .empty-state-link:hover { background: #333; }

        /* ── DETAIL LINK ── */
        .detail-link {
            font-size: 0.7rem;
            font-weight: 500;
            letter-spacing: 0.02em;
            color: #bbb;
            text-decoration: none;
            transition: color 0.2s;
        }

        .detail-link:hover { color: #0f0f0f; }

        /* ── KURIR TABLE EMPTY ── */
        .kurir-empty {
            background: #fafafa;
            border: 1px dashed #ddd;
            border-radius: 12px;
            padding: 64px 28px;
            text-align: center;
        }
    </style>

    <div class="py-10 dash-wrap">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">

            
            <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4 mb-12">

                <div class="stat-card">
                    <div class="stat-label">Total Pesanan</div>
                    <div class="stat-value"><?php echo e(number_format($stats['total_orders'] ?? 0)); ?></div>
                </div>

                <div class="stat-card">
                    <div class="stat-label">Pendapatan</div>
                    <div class="stat-value-sm">Rp <?php echo e(number_format(($stats['total_revenue'] ?? 0)/1000, 1, ',', '.')); ?>rb</div>
                </div>

                <div class="stat-card">
                    <div class="stat-label">Produk Aktif</div>
                    <div class="stat-value"><?php echo e(number_format($stats['total_products'] ?? 0)); ?></div>
                </div>

                <div class="stat-card">
                    <div class="stat-label">Pelanggan</div>
                    <div class="stat-value"><?php echo e(number_format($stats['total_customers'] ?? 0)); ?></div>
                </div>

                <div class="stat-card <?php echo e(($stats['low_stock_count'] ?? 0) > 0 ? 'danger' : ''); ?>">
                    <div class="stat-label">Stok Menipis</div>
                    <div class="stat-value"><?php echo e(number_format($stats['low_stock_count'] ?? 0)); ?></div>
                </div>

            </div>

            
            <div class="mb-12">
                <div class="flex items-end justify-between mb-6">
                    <div>
                        <div class="section-eyebrow">Real-time</div>
                        <div class="section-title">Monitoring Kurir</div>
                    </div>
                    <a href="<?php echo e(route('admin.users.index', ['role'=>'kurir'])); ?>" class="section-link">Kelola Kurir</a>
                </div>

                <div class="grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
                    <div class="kurir-mini">
                        <div class="kurir-mini-value"><?php echo e($stats['total_couriers'] ?? 0); ?></div>
                        <div class="kurir-mini-label">Total Kurir</div>
                        <div class="kurir-mini-sub"><?php echo e($stats['active_couriers'] ?? 0); ?> aktif</div>
                    </div>

                    <div class="kurir-mini">
                        <div class="kurir-mini-value">
                            <?php echo e(\App\Models\Order::whereNotNull('courier_id')->where('courier_task_status','assigned')->count()); ?>

                        </div>
                        <div class="kurir-mini-label">Menunggu Pickup</div>
                    </div>

                    <div class="kurir-mini">
                        <div class="kurir-mini-value">
                            <?php echo e(\App\Models\Order::whereNotNull('courier_id')->where('courier_task_status','picked_up')->count()); ?>

                        </div>
                        <div class="kurir-mini-label">Dalam Pengiriman</div>
                    </div>

                    <div class="kurir-mini">
                        <div class="kurir-mini-value" style="color: #2e7d32;"><?php echo e($stats['orders_delivered_today'] ?? 0); ?></div>
                        <div class="kurir-mini-label">Terkirim Hari Ini</div>
                    </div>
                </div>

                <?php if(isset($couriers) && $couriers->isNotEmpty()): ?>
                <div class="dash-table-wrap">
                    <div class="dash-table-header">
                        <span class="dash-table-header-title">Daftar Kurir &amp; Aktivitas</span>
                    </div>
                    <div class="overflow-x-auto">
                        <table class="dash-table">
                            <thead>
                                <tr>
                                    <th>Kurir</th>
                                    <th class="center">Status</th>
                                    <th class="center">Pickup</th>
                                    <th class="center">Delivery</th>
                                    <th class="center">Hari Ini</th>
                                    <th class="center">Total</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $couriers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $courier): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td>
                                        <div style="display:flex; align-items:center; gap:12px;">
                                            <div class="dash-avatar"><?php echo e(strtoupper(substr($courier->name, 0, 1))); ?></div>
                                            <div>
                                                <div style="font-weight:600; color:#1a1a1a; font-size:0.875rem;"><?php echo e($courier->name); ?></div>
                                                <div style="font-size:0.7rem; color:#bbb; margin-top:2px;"><?php echo e($courier->email); ?></div>
                                            </div>
                                        </div>
                                    </td>
                                    <td class="center">
                                        <?php if($courier->is_active ?? true): ?>
                                            <span class="badge badge-green"><span class="badge-dot"></span>Aktif</span>
                                        <?php else: ?>
                                            <span class="badge badge-gray"><span class="badge-dot"></span>Nonaktif</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="center">
                                        <?php if($courier->assigned_count > 0): ?>
                                            <span class="count-bubble bubble-orange"><?php echo e($courier->assigned_count); ?></span>
                                        <?php else: ?>
                                            <span style="color:#ddd;">—</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="center">
                                        <?php if($courier->picked_up_count > 0): ?>
                                            <span class="count-bubble bubble-blue"><?php echo e($courier->picked_up_count); ?></span>
                                        <?php else: ?>
                                            <span style="color:#ddd;">—</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="center">
                                        <?php if($courier->delivered_today > 0): ?>
                                            <span class="count-bubble bubble-green"><?php echo e($courier->delivered_today); ?></span>
                                        <?php else: ?>
                                            <span style="color:#ddd;">—</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="center">
                                        <span style="font-weight:600; color:#1a1a1a; font-size:0.9rem;"><?php echo e($courier->total_delivered); ?></span>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <?php else: ?>
                <div class="kurir-empty">
                    <p class="empty-state-title">Belum ada kurir terdaftar</p>
                    <a href="<?php echo e(route('admin.users.index', ['role'=>'kurir'])); ?>" class="empty-state-link">+ Tambah Kurir</a>
                </div>
                <?php endif; ?>
            </div>

            
            <?php if(($lowStockProducts ?? collect())->isNotEmpty()): ?>
            <div class="mb-12">
                <div class="flex items-end justify-between mb-6">
                    <div>
                        <div class="section-eyebrow" style="color:#c62828;">Perlu Perhatian</div>
                        <div class="section-title">Peringatan Stok Kritis</div>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
                    <?php $__currentLoopData = $lowStockProducts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="low-stock-card">
                        <div style="padding: 16px 18px;">
                            <div style="display:flex; align-items:flex-start; gap:14px;">
                                <?php $img = $product->images->firstWhere('is_primary', true) ?? $product->images->first(); ?>
                                <?php if($img): ?>
                                    <img src="<?php echo e(\Storage::url($img->image_path)); ?>" style="width:48px; height:48px; border-radius:8px; object-fit:cover; border:1px solid #f0f0f0; flex-shrink:0;">
                                <?php else: ?>
                                    <div style="width:48px; height:48px; border-radius:8px; background:#f5f5f5; display:flex; align-items:center; justify-content:center; font-size:1.2rem; flex-shrink:0;">📦</div>
                                <?php endif; ?>
                                <div style="flex:1; min-width:0;">
                                    <div style="font-size:0.85rem; font-weight:600; color:#1a1a1a; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-bottom:8px;"><?php echo e($product->name); ?></div>
                                    <div style="display:flex; flex-wrap:wrap; gap:6px;">
                                        <?php $__currentLoopData = $product->low_variants; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $variant): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <span class="variant-pill <?php echo e($variant->stock == 0 ? 'variant-zero' : 'variant-low'); ?>">
                                            <?php echo e(strtoupper($variant->size ?? '-')); ?>/<?php echo e(ucfirst($variant->color ?? '-')); ?>: <strong><?php echo e($variant->stock); ?></strong>
                                        </span>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </div>
                                </div>
                                <a href="<?php echo e(route('admin.stock-logs.index', $product->id)); ?>" class="detail-link" style="white-space:nowrap;">Restock</a>
                            </div>
                        </div>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
            <?php endif; ?>

            
            <div class="dash-table-wrap">
                <div class="dash-table-header">
                    <div style="display:flex; align-items:center; gap:10px;">
                        <span class="dash-table-header-title">Pesanan Terbaru</span>
                        <span class="dash-table-header-badge">5 terakhir</span>
                    </div>
                    <a href="<?php echo e(route('admin.orders.index')); ?>" class="section-link">Lihat Semua</a>
                </div>
                <div class="overflow-x-auto">
                    <table class="dash-table">
                        <thead>
                            <tr>
                                <th>Order ID</th>
                                <th>Tanggal</th>
                                <th>Pelanggan</th>
                                <th>Total</th>
                                <th class="center">Status</th>
                                <th class="right">Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $recentOrders ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td>
                                    <span class="order-id">#<?php echo e($order->order_number); ?></span>
                                </td>
                                <td style="color:#aaa; font-size:0.75rem;"><?php echo e($order->created_at->format('d/m/Y H:i')); ?></td>
                                <td>
                                    <div style="display:flex; align-items:center; gap:10px;">
                                        <div class="dash-avatar" style="width:28px; height:28px; background:#e8e8e8; color:#666; font-size:0.65rem;">
                                            <?php echo e(substr($order->user->name ?? 'G', 0, 1)); ?>

                                        </div>
                                        <div>
                                            <div style="font-size:0.85rem; font-weight:500; color:#1a1a1a;"><?php echo e($order->user->name ?? 'Guest'); ?></div>
                                            <div style="font-size:0.65rem; color:#bbb;"><?php echo e(substr($order->user->email ?? '-', 0, 22)); ?></div>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <span style="font-weight:600; font-size:0.9rem; color:#1a1a1a;">Rp <?php echo e(number_format($order->total, 0, ',', '.')); ?></span>
                                </td>
                                <td class="center">
                                    <?php
                                        $badgeClass = match($order->status) {
                                            'paid','completed' => 'badge-green',
                                            'pending' => 'badge-yellow',
                                            'cancelled','failed' => 'badge-red',
                                            'shipped','shipping' => 'badge-blue',
                                            default => 'badge-gray',
                                        };
                                    ?>
                                    <span class="badge <?php echo e($badgeClass); ?>"><?php echo e(ucfirst($order->status)); ?></span>
                                </td>
                                <td class="right">
                                    <a href="<?php echo e(route('admin.orders.show', $order->id)); ?>" class="detail-link">Detail</a>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="6">
                                    <div class="empty-state">
                                        <div class="empty-state-title">Belum ada data pesanan</div>
                                    </div>
                                </td>
                            </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>

        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?><?php /**PATH C:\laragon\www\toko_app\resources\views/admin/dashboard.blade.php ENDPATH**/ ?>