<?php if (isset($component)) { $__componentOriginal166a02a7c5ef5a9331faf66fa665c256 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal166a02a7c5ef5a9331faf66fa665c256 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'filament-panels::components.page.index','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('filament-panels::page'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>

    
    <div class="flex flex-wrap items-end gap-3 mb-6">

        
        <div class="flex gap-1 mr-4">
            <button wire:click="setTab('account')"
                class="px-4 py-1.5 rounded-lg text-sm font-semibold transition-colors
                    <?php echo e($activeTab === 'account'
                        ? 'bg-primary-600 text-white'
                        : 'bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 hover:bg-gray-50'); ?>">
                Account Manager
            </button>
            <button wire:click="setTab('vendedor')"
                class="px-4 py-1.5 rounded-lg text-sm font-semibold transition-colors
                    <?php echo e($activeTab === 'vendedor'
                        ? 'bg-primary-600 text-white'
                        : 'bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 hover:bg-gray-50'); ?>">
                Vendedor
            </button>
        </div>

        
        <div class="flex gap-1">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = ['month' => 'Este mes', 'lastmonth' => 'Mes pasado', 'months3' => 'Últ. 3 meses', 'year' => 'Este año']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <button wire:click="setPreset('<?php echo e($key); ?>')"
                    class="px-3 py-1.5 rounded-lg text-sm font-medium transition-colors
                        <?php echo e($preset === $key
                            ? 'bg-gray-700 text-white'
                            : 'bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 border border-gray-300 dark:border-gray-600 hover:bg-gray-50'); ?>">
                    <?php echo e($label); ?>

                </button>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>

        
        <div class="flex items-center gap-2">
            <input type="date" wire:model.live="desde"
                class="rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white text-sm px-3 py-1.5 focus:ring-primary-500 focus:border-primary-500">
            <span class="text-gray-400 text-sm">—</span>
            <input type="date" wire:model.live="hasta"
                class="rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white text-sm px-3 py-1.5 focus:ring-primary-500 focus:border-primary-500">
        </div>
    </div>

    
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($activeTab === 'account'): ?>
        <?php $d = $this->getAccountReportData(); ?>

        
        <div class="grid grid-cols-1 sm:grid-cols-3 gap-4 mb-6">

            <div class="rounded-xl bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 p-4 shadow-sm">
                <p class="text-xs font-semibold text-gray-400 uppercase tracking-wide">Account Manager</p>
                <p class="text-xl font-bold text-gray-900 dark:text-white mt-1">
                    <?php echo e($d['account_manager']?->name ?? 'Sin asignar'); ?>

                </p>
                <p class="text-xs text-gray-400 mt-0.5">
                    Comisión <?php echo e(number_format($d['pct'], 2)); ?>% sobre cobrado
                </p>
            </div>

            <div class="rounded-xl bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 p-4 shadow-sm">
                <p class="text-xs font-semibold text-gray-400 uppercase tracking-wide">Proyectos cobrados</p>
                <p class="text-2xl font-bold text-gray-900 dark:text-white mt-1"><?php echo e($d['rows']->count()); ?></p>
                <p class="text-xs text-gray-400 mt-0.5">
                    <?php echo e(\Carbon\Carbon::parse($d['desde'])->format('d/m/Y')); ?> —
                    <?php echo e(\Carbon\Carbon::parse($d['hasta'])->format('d/m/Y')); ?>

                </p>
            </div>

            <div class="rounded-xl bg-primary-50 dark:bg-primary-900/30 border border-primary-200 dark:border-primary-700 p-4 shadow-sm">
                <p class="text-xs font-semibold text-primary-500 uppercase tracking-wide">Comisión Total</p>
                <p class="text-2xl font-bold text-primary-600 dark:text-primary-400 mt-1">
                    Bs. <?php echo e(number_format($d['total_comision_bs'], 2)); ?>

                </p>
                <p class="text-xs text-primary-400 mt-0.5">TC: <?php echo e(number_format($d['rate'], 2)); ?> BOB/USD</p>
            </div>
        </div>

        
        <div class="rounded-xl bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm">
            <table class="min-w-full text-sm">
                <thead class="bg-gray-50 dark:bg-gray-700">
                    <tr>
                        <th class="px-4 py-3 text-left font-semibold text-gray-600 dark:text-gray-300">Cliente</th>
                        <th class="px-4 py-3 text-left font-semibold text-gray-600 dark:text-gray-300">Proyecto</th>
                        <th class="px-4 py-3 text-right font-semibold text-gray-600 dark:text-gray-300">Cobrado USD</th>
                        <th class="px-4 py-3 text-right font-semibold text-gray-600 dark:text-gray-300">Cobrado BOB</th>
                        <th class="px-4 py-3 text-right font-semibold text-gray-600 dark:text-gray-300">Total Bs.</th>
                        <th class="px-4 py-3 text-right font-semibold text-gray-600 dark:text-gray-300"><?php echo e(number_format($d['pct'], 0)); ?>% Comisión</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-100 dark:divide-gray-700">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $d['rows']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr class="hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors">
                            <td class="px-4 py-3 font-medium text-gray-900 dark:text-white"><?php echo e($row['client']); ?></td>
                            <td class="px-4 py-3 text-gray-600 dark:text-gray-300"><?php echo e($row['title']); ?></td>
                            <td class="px-4 py-3 text-right text-gray-700 dark:text-gray-300">
                                <?php echo e($row['cobrado_usd'] > 0 ? '$' . number_format($row['cobrado_usd'], 2) : '—'); ?>

                            </td>
                            <td class="px-4 py-3 text-right text-gray-700 dark:text-gray-300">
                                <?php echo e($row['cobrado_bob'] > 0 ? 'Bs. ' . number_format($row['cobrado_bob'], 2) : '—'); ?>

                            </td>
                            <td class="px-4 py-3 text-right font-medium text-gray-800 dark:text-gray-200">
                                Bs. <?php echo e(number_format($row['cobrado_bs'], 2)); ?>

                            </td>
                            <td class="px-4 py-3 text-right font-bold text-primary-600 dark:text-primary-400">
                                Bs. <?php echo e(number_format($row['comision_bs'], 2)); ?>

                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="6" class="px-4 py-8 text-center text-gray-400">
                                Sin proyectos cobrados en el período seleccionado.
                            </td>
                        </tr>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </tbody>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($d['rows']->isNotEmpty()): ?>
                    <tfoot class="bg-gray-50 dark:bg-gray-700 border-t-2 border-gray-200 dark:border-gray-600">
                        <tr>
                            <td colspan="5" class="px-4 py-3 text-right font-bold text-gray-700 dark:text-gray-200">
                                TOTAL COMISIÓN
                            </td>
                            <td class="px-4 py-3 text-right font-bold text-primary-600 dark:text-primary-400 text-base">
                                Bs. <?php echo e(number_format($d['total_comision_bs'], 2)); ?>

                            </td>
                        </tr>
                    </tfoot>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </table>
        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($activeTab === 'vendedor'): ?>
        <?php $d = $this->getSalesRepReportData(); ?>

        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(empty($d['sellers_data'])): ?>
            <div class="rounded-xl bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 p-8 text-center shadow-sm">
                <p class="text-gray-400">No hay vendedores registrados o ninguno tiene ventas asignadas en este período.</p>
            </div>
        <?php else: ?>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $d['sellers_data']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sellerData): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                
                <div class="flex flex-wrap items-center justify-between gap-4 mb-3 mt-6 first:mt-0">
                    <div>
                        <h3 class="text-lg font-bold text-gray-900 dark:text-white">
                            <?php echo e($sellerData['seller']->name); ?>

                        </h3>
                        <p class="text-sm text-gray-500 dark:text-gray-400">
                            <?php echo e($sellerData['total_count']); ?> venta(s) •
                            <?php echo e($sellerData['cobrados_count']); ?> cobrada(s)
                        </p>
                    </div>

                    
                    <div class="flex gap-3">
                        <div class="rounded-lg bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 px-4 py-2 text-center shadow-sm">
                            <p class="text-xs text-gray-400 uppercase tracking-wide">Bruto total</p>
                            <p class="font-bold text-gray-800 dark:text-gray-200">
                                Bs. <?php echo e(number_format($sellerData['total_gross_bs'], 2)); ?>

                            </p>
                        </div>
                        <div class="rounded-lg bg-primary-50 dark:bg-primary-900/30 border border-primary-200 dark:border-primary-700 px-4 py-2 text-center shadow-sm">
                            <p class="text-xs text-primary-500 uppercase tracking-wide">Comisión</p>
                            <p class="font-bold text-primary-600 dark:text-primary-400">
                                Bs. <?php echo e(number_format($sellerData['total_comision_bs'], 2)); ?>

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

                
                <div class="rounded-xl bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 overflow-hidden shadow-sm mb-6">
                    <table class="min-w-full text-sm">
                        <thead class="bg-gray-50 dark:bg-gray-700">
                            <tr>
                                <th class="px-4 py-3 text-left font-semibold text-gray-600 dark:text-gray-300">Cliente</th>
                                <th class="px-4 py-3 text-left font-semibold text-gray-600 dark:text-gray-300">Proyecto</th>
                                <th class="px-4 py-3 text-left font-semibold text-gray-600 dark:text-gray-300">Fecha</th>
                                <th class="px-4 py-3 text-right font-semibold text-gray-600 dark:text-gray-300">Monto</th>
                                <th class="px-4 py-3 text-right font-semibold text-gray-600 dark:text-gray-300">En Bs.</th>
                                <th class="px-4 py-3 text-center font-semibold text-gray-600 dark:text-gray-300">Estado pago</th>
                                <th class="px-4 py-3 text-right font-semibold text-gray-600 dark:text-gray-300">% Com.</th>
                                <th class="px-4 py-3 text-right font-semibold text-gray-600 dark:text-gray-300">Comisión Bs.</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-100 dark:divide-gray-700">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $sellerData['rows']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr class="hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors">
                                    <td class="px-4 py-3 font-medium text-gray-900 dark:text-white"><?php echo e($row['client']); ?></td>
                                    <td class="px-4 py-3 text-gray-600 dark:text-gray-300 max-w-xs truncate"><?php echo e($row['title']); ?></td>
                                    <td class="px-4 py-3 text-gray-500 dark:text-gray-400 whitespace-nowrap"><?php echo e($row['sale_date']); ?></td>
                                    <td class="px-4 py-3 text-right text-gray-700 dark:text-gray-300 whitespace-nowrap">
                                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($row['gross_usd']): ?>
                                            $<?php echo e(number_format($row['gross_usd'], 2)); ?>

                                        <?php else: ?>
                                            Bs. <?php echo e(number_format($row['gross_bob'], 2)); ?>

                                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                    </td>
                                    <td class="px-4 py-3 text-right text-gray-700 dark:text-gray-300">
                                        Bs. <?php echo e(number_format($row['gross_bs'], 2)); ?>

                                    </td>
                                    <td class="px-4 py-3 text-center">
                                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($row['pagado']): ?>
                                            <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-400">
                                                Pagado
                                            </span>
                                        <?php elseif($row['parcial']): ?>
                                            <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-400">
                                                Parcial
                                            </span>
                                        <?php else: ?>
                                            <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400">
                                                Pendiente
                                            </span>
                                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                    </td>
                                    <td class="px-4 py-3 text-right text-gray-500 dark:text-gray-400">
                                        <?php echo e(number_format($row['pct'], 0)); ?>%
                                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($row['pct'] != $d['default_pct']): ?>
                                            <span class="text-xs text-amber-500" title="Personalizado">*</span>
                                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                    </td>
                                    <td class="px-4 py-3 text-right font-bold text-primary-600 dark:text-primary-400">
                                        Bs. <?php echo e(number_format($row['comision_bs'], 2)); ?>

                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="8" class="px-4 py-6 text-center text-gray-400">
                                        Sin ventas asignadas en el período.
                                    </td>
                                </tr>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </tbody>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($sellerData['rows']->isNotEmpty()): ?>
                            <tfoot class="bg-gray-50 dark:bg-gray-700 border-t-2 border-gray-200 dark:border-gray-600">
                                <tr>
                                    <td colspan="7" class="px-4 py-3 text-right font-bold text-gray-700 dark:text-gray-200">
                                        TOTAL
                                    </td>
                                    <td class="px-4 py-3 text-right font-bold text-primary-600 dark:text-primary-400 text-base">
                                        Bs. <?php echo e(number_format($sellerData['total_comision_bs'], 2)); ?>

                                    </td>
                                </tr>
                            </tfoot>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </table>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

            <p class="text-xs text-gray-400 mt-2">
                * = Porcentaje personalizado por venta. Por defecto: <?php echo e(number_format($d['default_pct'], 0)); ?>%.
                TC: <?php echo e(number_format($d['rate'], 2)); ?> BOB/USD.
            </p>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal166a02a7c5ef5a9331faf66fa665c256)): ?>
<?php $attributes = $__attributesOriginal166a02a7c5ef5a9331faf66fa665c256; ?>
<?php unset($__attributesOriginal166a02a7c5ef5a9331faf66fa665c256); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal166a02a7c5ef5a9331faf66fa665c256)): ?>
<?php $component = $__componentOriginal166a02a7c5ef5a9331faf66fa665c256; ?>
<?php unset($__componentOriginal166a02a7c5ef5a9331faf66fa665c256); ?>
<?php endif; ?>
<?php /**PATH /home/ninatech/ventas.nuna.tech/resources/views/filament/pages/commissions-report-page.blade.php ENDPATH**/ ?>