<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
        font-family: 'DejaVu Sans', sans-serif;
        font-size: 9px;
        color: #1e293b;
        background: #ffffff;
    }

    /* ── Header ── */
    .header {
        background: #1e293b;
        color: #fff;
        padding: 18px 24px;
        border-radius: 10px;
        margin-bottom: 14px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .header-brand { font-size: 20px; font-weight: 900; letter-spacing: -0.5px; }
    .header-brand span { color: #f9a8d4; }
    .header-right { text-align: right; }
    .header-right .title { font-size: 13px; font-weight: 700; color: #f9a8d4; }
    .header-right .sub { font-size: 8px; color: #94a3b8; margin-top: 3px; }

    .meta { font-size: 7.5px; color: #94a3b8; margin-bottom: 14px; }
    .meta strong { color: #64748b; }

    /* ── Summary cards ── */
    .cards { width: 100%; margin-bottom: 14px; }
    .cards td { width: 25%; padding: 4px; }
    .card {
        border-radius: 8px;
        padding: 10px 12px;
    }
    .card-label { font-size: 7px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: #64748b; margin-bottom: 5px; }
    .card-value { font-size: 12px; font-weight: 900; font-style: italic; }
    .card-pink   { background: #fce7f3; }
    .card-pink   .card-value { color: #db2777; }
    .card-slate  { background: #f8fafc; }
    .card-slate  .card-value { color: #1e293b; }
    .card-amber  { background: #fef3c7; }
    .card-amber  .card-value { color: #d97706; }
    .card-green  { background: #d1fae5; }
    .card-green  .card-value { color: #059669; }

    /* ── Section title ── */
    .section-title {
        font-size: 9px;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.18em;
        color: #1e293b;
        border-left: 3px solid #db2777;
        padding-left: 8px;
        margin-bottom: 8px;
        margin-top: 14px;
    }

    /* ── Tables ── */
    .tbl { width: 100%; border-collapse: collapse; }
    .tbl thead tr { background: #1e293b; color: #fff; }
    .tbl thead th {
        padding: 7px 10px;
        text-align: left;
        font-size: 7.5px;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.1em;
    }
    .tbl tbody tr:nth-child(even) td { background: #f8fafc; }
    .tbl tbody tr:nth-child(odd) td  { background: #ffffff; }
    .tbl tbody td {
        padding: 6px 10px;
        border-bottom: 0.5px solid #f1f5f9;
        font-size: 8px;
    }
    .tbl tfoot td {
        padding: 8px 10px;
        font-weight: 900;
        font-size: 8.5px;
        background: #fce7f3;
        color: #db2777;
        border-top: 1.5px solid #f9a8d4;
    }

    /* ── Two-column ── */
    .two-col { width: 100%; margin-bottom: 0; }
    .two-col td { vertical-align: top; padding: 0 5px; }
    .two-col td:first-child { padding-left: 0; }
    .two-col td:last-child  { padding-right: 0; }

    .box {
        border: 0.5px solid #e2e8f0;
        border-radius: 8px;
        padding: 12px;
        background: #fff;
    }
    .pay-row {
        padding: 7px 10px;
        border-radius: 6px;
        margin-bottom: 5px;
        display: flex;
        justify-content: space-between;
    }
    .pay-row.midtrans { background: #eff6ff; color: #1d4ed8; }
    .pay-row.cod      { background: #d1fae5; color: #059669; }
    .pay-row.total    { background: #db2777; color: #fff; font-weight: 900; }
    .pay-label        { font-weight: 700; font-size: 8px; }
    .pay-sub          { font-size: 7px; opacity: 0.7; }
    .pay-amount       { font-weight: 900; font-size: 9px; font-style: italic; }

    .rank-row         { padding: 6px 0; border-bottom: 0.5px solid #f1f5f9; }
    .rank-row:last-child { border: none; }
    .rank-num         { display: inline-block; width: 18px; height: 18px; border-radius: 4px; background: #f1f5f9; text-align: center; line-height: 18px; font-weight: 900; font-size: 7.5px; color: #475569; margin-right: 6px; }
    .rank-num.gold    { background: #fbbf24; color: #fff; }
    .rank-name        { font-weight: 700; font-size: 8px; }
    .rank-amount      { font-weight: 900; font-size: 8px; color: #db2777; font-style: italic; }

    /* ── Status badge ── */
    .badge { padding: 2px 7px; border-radius: 20px; font-size: 7px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; }
    .badge-completed { background: #d1fae5; color: #059669; }
    .badge-cancelled { background: #fee2e2; color: #dc2626; }
    .badge-pending   { background: #fef3c7; color: #d97706; }
    .badge-shipping  { background: #fce7f3; color: #db2777; }
    .badge-packaging { background: #eff6ff; color: #2563eb; }

    /* ── Footer ── */
    .footer {
        margin-top: 18px;
        padding-top: 8px;
        border-top: 0.5px solid #f9a8d4;
        text-align: center;
        font-size: 7px;
        color: #94a3b8;
    }
</style>
</head>
<body>


<div class="header">
    <div>
        <div class="header-brand">✦ Vogue<span>3D</span></div>
        <div style="font-size:8px; color:#94a3b8; margin-top:4px;">Fashion Store &bull; Laporan Otomatis</div>
    </div>
    <div class="header-right">
        <div class="title">Laporan Keuangan Usaha</div>
        <div class="sub">
            Periode: <?php echo e($startDate->translatedFormat('d F Y')); ?> – <?php echo e($endDate->translatedFormat('d F Y')); ?>

        </div>
    </div>
</div>

<div class="meta">
    Dicetak: <strong><?php echo e(now()->translatedFormat('d F Y, H:i')); ?> WIB</strong>
    &nbsp;|&nbsp; Admin: <strong>Vogue3D Store</strong>
    &nbsp;|&nbsp; Status: <strong>Dokumen Resmi</strong>
</div>


<table class="cards">
    <tr>
        <td><div class="card card-pink">
            <div class="card-label">Total Pendapatan</div>
            <div class="card-value">Rp <?php echo e(number_format($totalRevenue, 0, ',', '.')); ?></div>
        </div></td>
        <td><div class="card card-slate">
            <div class="card-label">Penjualan Produk</div>
            <div class="card-value">Rp <?php echo e(number_format($totalProductSales, 0, ',', '.')); ?></div>
        </div></td>
        <td><div class="card card-amber">
            <div class="card-label">Total Ongkir</div>
            <div class="card-value">Rp <?php echo e(number_format($totalShippingFee, 0, ',', '.')); ?></div>
        </div></td>
        <td><div class="card card-green">
            <div class="card-label">Order Selesai / Total</div>
            <div class="card-value"><?php echo e($completedOrders->count()); ?> / <?php echo e($orders->count()); ?></div>
        </div></td>
    </tr>
</table>


<table class="two-col">
    <tr>
        
        <td style="width:50%">
            <div class="section-title">Metode Pembayaran</div>
            <div class="box">
                <div class="pay-row midtrans">
                    <div>
                        <div class="pay-label">Midtrans (Transfer)</div>
                        <div class="pay-sub"><?php echo e($midtransCount); ?> transaksi</div>
                    </div>
                    <div class="pay-amount">Rp <?php echo e(number_format($midtransRevenue, 0, ',', '.')); ?></div>
                </div>
                <div class="pay-row cod">
                    <div>
                        <div class="pay-label">COD (Tunai)</div>
                        <div class="pay-sub"><?php echo e($codCount); ?> transaksi</div>
                    </div>
                    <div class="pay-amount">Rp <?php echo e(number_format($codRevenue, 0, ',', '.')); ?></div>
                </div>
                <div class="pay-row total">
                    <div class="pay-label">Total Pendapatan</div>
                    <div class="pay-amount">Rp <?php echo e(number_format($totalRevenue, 0, ',', '.')); ?></div>
                </div>
            </div>
        </td>

        
        <td style="width:50%">
            <div class="section-title">Top 5 Produk Terlaris</div>
            <div class="box">
                <?php $__empty_1 = true; $__currentLoopData = $topProducts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $prod): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <div class="rank-row" style="display:table;width:100%">
                    <span style="display:table-cell;width:24px;vertical-align:middle">
                        <span class="rank-num <?php echo e($i === 0 ? 'gold' : ''); ?>"><?php echo e($i+1); ?></span>
                    </span>
                    <span style="display:table-cell;vertical-align:middle">
                        <span class="rank-name"><?php echo e($prod->name); ?></span>
                        <span style="font-size:7px;color:#94a3b8;margin-left:4px"><?php echo e($prod->total_qty); ?> terjual</span>
                    </span>
                    <span style="display:table-cell;text-align:right;vertical-align:middle">
                        <span class="rank-amount">Rp <?php echo e(number_format($prod->total_sales, 0, ',', '.')); ?></span>
                    </span>
                </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <div style="text-align:center;color:#94a3b8;padding:12px;font-style:italic">Belum ada data.</div>
                <?php endif; ?>
            </div>
        </td>
    </tr>
</table>


<div class="section-title">Detail Seluruh Pesanan</div>
<table class="tbl">
    <thead>
        <tr>
            <th>No. Order</th>
            <th>Pelanggan</th>
            <th>Metode</th>
            <th style="text-align:right">Ongkir</th>
            <th style="text-align:right">Total</th>
            <th>Status</th>
            <th>Tanggal</th>
        </tr>
    </thead>
    <tbody>
        <?php $__empty_1 = true; $__currentLoopData = $orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
        <tr>
            <td style="font-weight:700;font-style:italic"><?php echo e($order->order_number); ?></td>
            <td><?php echo e($order->user->name); ?></td>
            <td><?php echo e($order->payment_method === 'midtrans' ? 'Midtrans' : 'COD'); ?></td>
            <td style="text-align:right;color:#d97706;font-weight:700">Rp <?php echo e(number_format($order->shipping_fee, 0, ',', '.')); ?></td>
            <td style="text-align:right;font-weight:900;font-style:italic">Rp <?php echo e(number_format($order->total_price, 0, ',', '.')); ?></td>
            <td>
                <?php
                $badgeClass = match($order->status) {
                    'completed' => 'badge-completed',
                    'cancelled' => 'badge-cancelled',
                    'shipping'  => 'badge-shipping',
                    'packaging' => 'badge-packaging',
                    default     => 'badge-pending',
                };
                $statusLabel = match($order->status) {
                    'completed'  => 'Selesai',
                    'cancelled'  => 'Batal',
                    'shipping'   => 'Dikirim',
                    'picking_up' => 'Ambil',
                    'packaging'  => 'Dikemas',
                    'pending'    => 'Pending',
                    default      => $order->status,
                };
                ?>
                <span class="badge <?php echo e($badgeClass); ?>"><?php echo e($statusLabel); ?></span>
            </td>
            <td><?php echo e(\Carbon\Carbon::parse($order->created_at)->format('d M Y')); ?></td>
        </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
        <tr>
            <td colspan="7" style="text-align:center;font-style:italic;color:#94a3b8;padding:16px">Tidak ada data pesanan.</td>
        </tr>
        <?php endif; ?>
    </tbody>
    <?php if($orders->count()): ?>
    <tfoot>
        <tr>
            <td colspan="3" style="font-weight:900;color:#1e293b">TOTAL (<?php echo e($completedOrders->count()); ?> Selesai)</td>
            <td style="text-align:right;color:#d97706">Rp <?php echo e(number_format($totalShippingFee, 0, ',', '.')); ?></td>
            <td style="text-align:right">Rp <?php echo e(number_format($totalRevenue, 0, ',', '.')); ?></td>
            <td colspan="2"></td>
        </tr>
    </tfoot>
    <?php endif; ?>
</table>


<div class="footer">
    Dokumen ini dibuat otomatis oleh sistem Vogue3D.
    &copy; <?php echo e(date('Y')); ?> Vogue3D Store. Semua hak dilindungi.
    &nbsp;|&nbsp; Dokumen ini sah tanpa tanda tangan.
</div>

</body>
</html><?php /**PATH C:\laragon\www\SwiftCart\resources\views/admin/financial/pdf.blade.php ENDPATH**/ ?>