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

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

    <div class="mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
        <p class="text-sm text-slate-600">Acompanhe recebimentos, comissões e repasses das oportunidades.</p>
        <a href="<?php echo e(route('financial.rules.index')); ?>" class="rounded-lg border border-slate-300 px-4 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Regras de comissão</a>
    </div>

    <div class="mb-6 grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
        <?php $__currentLoopData = [
            'total_negotiated' => 'Total negociado',
            'commission_forecast' => 'Comissão prevista',
            'commission_paid' => 'Comissão paga',
            'pending_transfers' => 'Repasses pendentes',
            'period_inflow' => 'Entradas no período',
            'open_transactions' => 'Lançamentos em aberto',
            'overdue_schedules' => 'Parcelas em atraso',
            'deals_with_finance' => 'Oportunidades com financeiro',
        ]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm">
                <p class="text-xs uppercase tracking-wide text-slate-500"><?php echo e($label); ?></p>
                <p class="mt-1 text-xl font-semibold text-slate-900">
                    <?php if(str_contains($key, 'deals') || str_contains($key, 'open') || str_contains($key, 'overdue')): ?>
                        <?php echo e($dashboard[$key] ?? 0); ?>

                    <?php else: ?>
                        R$ <?php echo e(number_format((float) ($dashboard[$key] ?? 0), 2, ',', '.')); ?>

                    <?php endif; ?>
                </p>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>

    <div class="overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm">
        <table class="min-w-full divide-y divide-slate-200 text-sm">
            <thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
                <tr>
                    <th class="px-4 py-3">Oportunidade</th>
                    <th class="px-4 py-3">Tipo</th>
                    <th class="px-4 py-3">Valor</th>
                    <th class="px-4 py-3">Status</th>
                    <th class="px-4 py-3">Vencimento</th>
                    <th class="px-4 py-3"></th>
                </tr>
            </thead>
            <tbody class="divide-y divide-slate-100">
                <?php $__empty_1 = true; $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tx): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td class="px-4 py-3 font-medium"><?php echo e($tx->deal?->title ?? '—'); ?></td>
                        <td class="px-4 py-3 text-slate-600"><?php echo e($tx->type->label()); ?></td>
                        <td class="px-4 py-3">R$ <?php echo e(number_format((float) $tx->amount, 2, ',', '.')); ?></td>
                        <td class="px-4 py-3"><?php echo e($tx->status->label()); ?></td>
                        <td class="px-4 py-3 text-slate-500"><?php echo e($tx->due_at?->format('d/m/Y') ?? '—'); ?></td>
                        <td class="px-4 py-3 text-right">
                            <?php if($tx->deal_id): ?>
                                <a href="<?php echo e(route('financial.show', $tx->deal_id)); ?>" class="font-medium text-emerald-700">Extrato</a>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="6" class="px-4 py-8 text-center text-slate-500">Nenhum lançamento financeiro ainda.</td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
    <div class="mt-4"><?php echo e($transactions->links()); ?></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/backend/resources/views/financial/index.blade.php ENDPATH**/ ?>