<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Detail Daily — <?php echo e($namaBulan[$bulan]); ?> <?php echo e($tahun); ?></title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet">
    <style>
        :root {
            --ink:       #0f172a;
            --ink-2:     #334155;
            --ink-3:     #64748b;
            --surface:   #ffffff;
            --surface-2: #f8fafc;
            --surface-3: #f1f5f9;
            --border:    #e2e8f0;
            --r:         10px;
            --mono:      'JetBrains Mono', monospace;
        }
        * { box-sizing: border-box; }
        body { background: var(--surface-3); font-family: 'Inter', sans-serif; font-size: 11px; color: var(--ink); }

        /* ── FILTER CARD ── */
        .filter-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--r);
            padding: 16px 20px;
            margin-bottom: 16px;
        }

        /* ── FILTER FORM ELEMENTS ── */
        .form-select-custom {
            border: 1.5px solid var(--border);
            border-radius: 7px;
            padding: 5px 10px;
            font-size: 11.5px;
            font-family: 'Inter', sans-serif;
            color: var(--ink);
            background: var(--surface);
            outline: none;
            transition: border-color .15s;
        }
        .form-select-custom:focus { border-color: #1d4ed8; }

        .check-pill {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            background: var(--surface-2);
            border: 1.5px solid var(--border);
            border-radius: 20px;
            padding: 3px 9px;
            cursor: pointer;
            font-size: 11px;
            font-weight: 500;
            transition: all .15s;
            user-select: none;
        }
        .check-pill input { accent-color: #1d4ed8; }
        .check-pill:has(input:checked) { background: #eff6ff; border-color: #1d4ed8; color: #1d4ed8; font-weight: 600; }

        .btn-filter {
            background: var(--ink);
            color: #fff;
            border: none;
            padding: 6px 16px;
            border-radius: 7px;
            font-size: 12px;
            font-weight: 600;
            font-family: 'Inter', sans-serif;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 5px;
            transition: opacity .15s;
        }
        .btn-filter:hover { opacity: .85; }
        .btn-secondary-link {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 6px 14px;
            border-radius: 7px;
            font-size: 12px;
            font-weight: 500;
            border: 1px solid var(--border);
            background: var(--surface);
            color: var(--ink-2);
            text-decoration: none;
            transition: background .15s;
        }
        .btn-secondary-link:hover { background: var(--surface-3); color: var(--ink); }

        /* ── ACTIVE DAY CHIPS ── */
        .day-chip {
            font-size: 10px;
            background: #eff6ff;
            color: #1d4ed8;
            border: 1px solid #bfdbfe;
            border-radius: 20px;
            padding: 2px 10px;
            font-weight: 600;
        }

        /* ── DAY CARD ── */
        .day-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--r);
            overflow: hidden;
            margin-bottom: 20px;
        }
        .day-header {
            background: var(--ink);
            color: #fff;
            padding: 10px 18px;
            display: flex;
            align-items: center;
            gap: 14px;
        }
        .day-badge {
            background: #f59e0b;
            color: var(--ink);
            font-weight: 700;
            font-size: 20px;
            width: 44px;
            height: 44px;
            border-radius: 9px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            font-family: var(--mono);
        }
        .day-title { font-size: 14px; font-weight: 700; line-height: 1.2; }
        .day-meta { font-size: 10px; color: #94a3b8; margin-top: 2px; }
        .day-body { padding: 16px; }

        /* ── SECTIONS WRAP ── */
        .sections-wrap { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
        .section-box { flex: 1; min-width: 200px; }
        .section-title {
            font-size: 10px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: .06em;
            color: var(--ink-3);
            margin-bottom: 8px;
            padding-bottom: 5px;
            border-bottom: 2px solid var(--border);
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .section-title i { font-size: 14px; }

        /* ── MINI TABLE ── */
        .mini-tbl { border-collapse: collapse; width: 100%; font-size: 11px; }
        .mini-tbl th {
            background: var(--surface-2);
            font-size: 10px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: .03em;
            padding: 5px 8px;
            text-align: center;
            border: 1px solid var(--border);
            color: var(--ink-3);
        }
        .mini-tbl td { padding: 5px 8px; border: 1px solid var(--surface-3); white-space: nowrap; vertical-align: middle; }
        .mini-tbl .td-r  { text-align: right; font-weight: 600; color: #dc2626; font-family: var(--mono); }
        .mini-tbl .td-c  { text-align: center; font-family: var(--mono); }
        .mini-tbl .td-ch { font-weight: 600; color: #1d4ed8; }
        .mini-tbl .tr-sub td  { background: #fef3c7; font-weight: 700; border-top: 2px solid #fbbf24; }
        .mini-tbl .tr-sub-g td { background: #d1fae5; font-weight: 700; border-top: 2px solid #6ee7b7; }

        /* ── TIPE BADGE ── */
        .tipe-badge { font-size: 9px; padding: 2px 7px; border-radius: 12px; font-weight: 700; }
        .tipe-NL  { background: #d1fae5; color: #065f46; }
        .tipe-CS  { background: #dbeafe; color: #1e40af; }
        .tipe-RC  { background: #ede9fe; color: #5b21b6; }
        .tipe-RS  { background: #fef3c7; color: #92400e; }

        /* ── NO DATA ── */
        .no-data { text-align: center; color: var(--ink-3); font-size: 11px; padding: 14px; }

        /* ── GRAND BOX ── */
        .grand-box {
            background: var(--surface);
            border: 1px solid var(--border);
            border-left: 4px solid #f59e0b;
            border-radius: 9px;
            padding: 10px 16px;
        }
    </style>
</head>
<body>

<?php echo $__env->make('layouts.navbar', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

<div class="container-fluid px-4 pb-5">

    
    <div class="d-flex justify-content-between align-items-center mb-4 pt-3 flex-wrap gap-2">
        <div>
            <h4 style="font-size:17px;font-weight:700;margin:0;color:var(--ink)">Detail Daily</h4>
            <div style="font-size:11px;color:var(--ink-3)">Rekap harian — <?php echo e($namaBulan[$bulan]); ?> <?php echo e($tahun); ?></div>
        </div>
        <div class="grand-box">
            <div style="font-size:9px;text-transform:uppercase;font-weight:700;color:var(--ink-3)">Total Hari Ditampilkan</div>
            <div style="font-size:20px;font-weight:700;color:#d97706;font-family:var(--mono)"><?php echo e(count($hariDipilih)); ?> hari</div>
        </div>
    </div>

    
    <div class="filter-card">
        <form method="GET" action="<?php echo e(route('laporan.daily')); ?>" class="d-flex flex-wrap gap-3 align-items-end">
            <div>
                <div style="font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--ink-3);margin-bottom:5px">📅 Tahun</div>
            <select name="tahun" class="form-select-custom" style="min-width:90px;font-weight:600">
                <?php for($y = date('Y') + 3; $y >= date('Y'); $y--): ?>
                  <option value="<?php echo e($y); ?>" <?php if($y == $tahun): echo 'selected'; endif; ?>><?php echo e($y); ?></option>
                <?php endfor; ?>
</select>
            </div>
            <div>
                <div style="font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--ink-3);margin-bottom:5px">📆 Bulan</div>
                <select name="bulan" class="form-select-custom" style="min-width:130px">
                    <?php $__currentLoopData = $bulanTersedia; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $b): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($b); ?>" <?php if($b == $bulan): echo 'selected'; endif; ?>><?php echo e($namaBulan[$b]); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div>
                <div style="font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--ink-3);margin-bottom:5px">Hari</div>
                <div class="d-flex flex-wrap gap-1" style="max-width:500px">
                    <?php $__currentLoopData = $hariTersedia; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $h): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <label class="check-pill">
                        <input type="checkbox" name="hari[]" value="<?php echo e($h); ?>" <?php if(in_array($h, $hariDipilih)): echo 'checked'; endif; ?>>
                        <?php echo e($h); ?>

                    </label>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
            <div class="d-flex gap-2">
                <button type="submit" class="btn-filter">
                    <i class="ti ti-filter" style="font-size:13px"></i> Tampilkan
                </button>
            </div>
        </form>
    </div>

    
    <?php $__empty_1 = true; $__currentLoopData = $dataHarian; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $hari => $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
    <div class="day-card">

        
        <div class="day-header">
            <div class="day-badge"><?php echo e($hari); ?></div>
            <div>
                <div class="day-title"><?php echo e($hari); ?> <?php echo e($namaBulan[$bulan]); ?> <?php echo e($tahun); ?></div>
                <div class="day-meta">
                    GMV: Rp <?php echo e(number_format($data['gmvChannel']->sum('total_gmv'), 0, ',', '.')); ?>

                    &nbsp;·&nbsp;
                    <?php echo e($data['gmvChannel']->count()); ?> channel aktif
                    &nbsp;·&nbsp;
                    <?php echo e($data['gmvIndividu']->count()); ?> CS aktif
                </div>
            </div>
        </div>

        <div class="day-body">

            
            <div class="sections-wrap">

                
                <div class="section-box">
                    <div class="section-title" style="border-color:#fca5a5;color:#9d174d">
                        <i class="ti ti-package"></i> GMV Channel
                    </div>
                    <?php if($data['gmvChannel']->isEmpty()): ?>
                        <div class="no-data">Tidak ada data</div>
                    <?php else: ?>
                    <table class="mini-tbl">
                        <thead><tr><th style="text-align:left">Channel</th><th>Nominal GMV</th></tr></thead>
                        <tbody>
                            <?php $__currentLoopData = $data['gmvChannel']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td class="td-ch"><?php echo e($row->channel->nama_channel ?? '-'); ?></td>
                                <td class="td-r">Rp <?php echo e(number_format($row->total_gmv, 0, ',', '.')); ?></td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                        <tfoot>
                            <tr class="tr-sub">
                                <td>Grand Total</td>
                                <td class="td-r">Rp <?php echo e(number_format($data['gmvChannel']->sum('total_gmv'), 0, ',', '.')); ?></td>
                            </tr>
                        </tfoot>
                    </table>
                    <?php endif; ?>
                </div>

                
                <div class="section-box">
                    <div class="section-title" style="border-color:#86efac;color:#166534">
                        <i class="ti ti-user"></i> GMV Individu
                    </div>
                    <?php if($data['gmvIndividu']->isEmpty()): ?>
                        <div class="no-data">Tidak ada data</div>
                    <?php else: ?>
                    <table class="mini-tbl">
                        <thead><tr><th style="text-align:left">CS/Admin</th><th>Nominal GMV</th></tr></thead>
                        <tbody>
                            <?php $__currentLoopData = $data['gmvIndividu']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $idx => $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td style="font-weight:600">
                                    <?php if($idx == 0): ?> 🥇 <?php elseif($idx == 1): ?> 🥈 <?php elseif($idx == 2): ?> 🥉 <?php endif; ?>
                                    <?php echo e($row->nama_cs); ?>

                                </td>
                                <td class="td-r">Rp <?php echo e(number_format($row->total_gmv, 0, ',', '.')); ?></td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                        <tfoot>
                            <tr class="tr-sub-g">
                                <td>Grand Total</td>
                                <td class="td-r">Rp <?php echo e(number_format($data['gmvIndividu']->sum('total_gmv'), 0, ',', '.')); ?></td>
                            </tr>
                        </tfoot>
                    </table>
                    <?php endif; ?>
                </div>

                
                <div class="section-box" style="min-width:320px">
                    <div class="section-title" style="border-color:#93c5fd;color:#1e40af">
                        <i class="ti ti-chart-bar"></i> Toples, Mini, Pouch — Channel
                    </div>
                    <?php if($data['qtyChannel']->isEmpty()): ?>
                        <div class="no-data">Tidak ada data</div>
                    <?php else: ?>
                    <table class="mini-tbl">
                        <thead>
                            <tr>
                                <th style="text-align:left">Channel</th>
                                <th>KK</th><th>CK</th>
                                <th>Top</th><th>Mini</th><th>Pouch</th><th>Total</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $gk=$gc=$gt=$gm=$gp=$ga=0; ?>
                            <?php $__currentLoopData = $data['qtyChannel']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td class="td-ch"><?php echo e($row->channel->nama_channel ?? '-'); ?></td>
                                <td class="td-c"><?php echo e(number_format($row->s_kue)); ?></td>
                                <td class="td-c"><?php echo e(number_format($row->s_cookies)); ?></td>
                                <td class="td-c" style="font-weight:700"><?php echo e(number_format($row->s_toples)); ?></td>
                                <td class="td-c"><?php echo e(number_format($row->s_mini)); ?></td>
                                <td class="td-c"><?php echo e(number_format($row->s_pouch)); ?></td>
                                <td class="td-c" style="font-weight:700;color:#1d4ed8"><?php echo e(number_format($row->s_total)); ?></td>
                            </tr>
                            <?php $gk+=$row->s_kue; $gc+=$row->s_cookies; $gt+=$row->s_toples; $gm+=$row->s_mini; $gp+=$row->s_pouch; $ga+=$row->s_total; ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                        <tfoot>
                            <tr class="tr-sub">
                                <td>Total</td>
                                <td class="td-c"><?php echo e(number_format($gk)); ?></td>
                                <td class="td-c"><?php echo e(number_format($gc)); ?></td>
                                <td class="td-c"><?php echo e(number_format($gt)); ?></td>
                                <td class="td-c"><?php echo e(number_format($gm)); ?></td>
                                <td class="td-c"><?php echo e(number_format($gp)); ?></td>
                                <td class="td-c"><?php echo e(number_format($ga)); ?></td>
                            </tr>
                        </tfoot>
                    </table>
                    <?php endif; ?>
                </div>

            </div>

            
            <div class="sections-wrap">

                
                <div class="section-box" style="min-width:360px">
                    <div class="section-title" style="border-color:#fca5a5;color:#9d174d">
                        <i class="ti ti-package"></i> Toples, Mini, Pouch — CS & Channel
                    </div>
                    <?php if($data['qtyCs']->isEmpty()): ?>
                        <div class="no-data">Tidak ada data</div>
                    <?php else: ?>
                    <table class="mini-tbl">
                        <thead>
                            <tr>
                                <th style="text-align:left">CS/Admin</th>
                                <th style="text-align:left">Channel</th>
                                <th>KK</th><th>CK</th>
                                <th>Top</th><th>Mini</th><th>Pouch</th><th>Total</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $data['qtyCs']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td style="font-weight:600"><?php echo e($row->nama_cs ?? '-'); ?></td>
                                <td class="td-ch"><?php echo e($row->channel->nama_channel ?? '-'); ?></td>
                                <td class="td-c"><?php echo e(number_format($row->s_kue)); ?></td>
                                <td class="td-c"><?php echo e(number_format($row->s_cookies)); ?></td>
                                <td class="td-c" style="font-weight:700"><?php echo e(number_format($row->s_toples)); ?></td>
                                <td class="td-c"><?php echo e(number_format($row->s_mini)); ?></td>
                                <td class="td-c"><?php echo e(number_format($row->s_pouch)); ?></td>
                                <td class="td-c" style="font-weight:700;color:#1d4ed8"><?php echo e(number_format($row->s_total)); ?></td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                    <?php endif; ?>
                </div>

                
                <div class="section-box">
                    <div class="section-title" style="border-color:#94a3b8;color:var(--ink)">
                        <i class="ti ti-robot"></i> BOT — Type Category
                    </div>
                    <?php if($data['botType']->isEmpty()): ?>
                        <div class="no-data">Tidak ada data Qontak/BOT</div>
                    <?php else: ?>
                    <table class="mini-tbl">
                        <thead><tr><th style="text-align:left">CS/Admin</th><th>Tipe</th><th>Nominal</th><th>Trx</th></tr></thead>
                        <tbody>
                            <?php $__currentLoopData = $data['botType']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td style="font-weight:600"><?php echo e($row->nama_cs ?? '-'); ?></td>
                                <td class="td-c">
                                    <span class="tipe-badge tipe-<?php echo e($row->tipe_pembelian); ?>"><?php echo e($row->tipe_pembelian ?? '-'); ?></span>
                                </td>
                                <td class="td-r">Rp <?php echo e(number_format($row->total_gmv, 0, ',', '.')); ?></td>
                                <td class="td-c"><?php echo e($row->total_trx); ?></td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                        <tfoot>
                            <tr class="tr-sub">
                                <td colspan="2">Total</td>
                                <td class="td-r">Rp <?php echo e(number_format($data['botType']->sum('total_gmv'), 0, ',', '.')); ?></td>
                                <td class="td-c"><?php echo e($data['botType']->sum('total_trx')); ?></td>
                            </tr>
                        </tfoot>
                    </table>
                    <?php endif; ?>
                </div>

                
                <div class="section-box">
                    <div class="section-title" style="border-color:#fbbf24;color:#92400e">
                        <i class="ti ti-store"></i> Reseller — Type Category
                    </div>
                    <?php if($data['resellerType']->isEmpty()): ?>
                        <div class="no-data">Tidak ada data Reseller</div>
                    <?php else: ?>
                    <table class="mini-tbl">
                        <thead><tr><th style="text-align:left">CS/Admin</th><th>Tipe</th><th>Nominal</th><th>Trx</th></tr></thead>
                        <tbody>
                            <?php $__currentLoopData = $data['resellerType']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td style="font-weight:600"><?php echo e($row->nama_cs ?? '-'); ?></td>
                                <td class="td-c">
                                    <span class="tipe-badge tipe-<?php echo e($row->tipe_pembelian); ?>"><?php echo e($row->tipe_pembelian ?? '-'); ?></span>
                                </td>
                                <td class="td-r">Rp <?php echo e(number_format($row->total_gmv, 0, ',', '.')); ?></td>
                                <td class="td-c"><?php echo e($row->total_trx); ?></td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                        <tfoot>
                            <tr class="tr-sub-g">
                                <td colspan="2">Total</td>
                                <td class="td-r">Rp <?php echo e(number_format($data['resellerType']->sum('total_gmv'), 0, ',', '.')); ?></td>
                                <td class="td-c"><?php echo e($data['resellerType']->sum('total_trx')); ?></td>
                            </tr>
                        </tfoot>
                    </table>
                    <?php endif; ?>
                </div>

            </div>
        </div>
    </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
    <div class="text-center py-5" style="color:var(--ink-3)">
        <i class="ti ti-calendar-off" style="font-size:32px;display:block;margin-bottom:8px;opacity:.35"></i>
        Tidak ada data untuk periode ini.
    </div>
    <?php endif; ?>

</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<?php /**PATH C:\laragon\www\laporanpenjualan\resources\views/laporan_daily.blade.php ENDPATH**/ ?>