<?php if (isset($component)) { $__componentOriginal91fdd17964e43374ae18c674f95cdaa3 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal91fdd17964e43374ae18c674f95cdaa3 = $attributes; } ?>
<?php $component = App\View\Components\AdminLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin-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\AdminLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <!-- Hid header content to let the definition below take precedence visually -->
     <?php $__env->endSlot(); ?>

    <!-- Main Outer Container -->
    <div class="p-0 font-sans bg-slate-50 min-h-screen">

        <!-- SINGLE WHITE CARD CONTAINER -->
        <div class="bg-white border-none shadow-none md:rounded-none p-4 md:p-6 relative min-h-screen">

            <div class="mb-6 flex items-center justify-between border-b border-gray-100 pb-4">
                <div>
                    <h5 class="text-[14px] font-bold text-gray-700 uppercase tracking-wide">
                        Rapports & Statistiques
                    </h5>
                    <p class="text-[11px] text-gray-500 mt-1 uppercase tracking-wider">Analyse financière et rapports détaillés</p>
                </div>
            </div>

            <!-- New Professional Filter Section -->
            <div class="mb-6 p-4 bg-gray-50/50 border border-gray-200 rounded-sm">
                <form method="GET" action="<?php echo e(route('admin.reports.index')); ?>">
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3 mb-6">
                        <!-- Management Year Filter -->
                        <div>
                            <select name="management_year_id" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px] cursor-pointer">
                                <option value="">Toutes les années</option>
                                <?php $__currentLoopData = $years; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($year->id); ?>" <?php echo e(request('management_year_id') == $year->id ? 'selected' : ''); ?>>
                                        Gestion <?php echo e($year->year); ?> <?php echo e(isset($year->status) && $year->status === 'active' ? '(ACTUELLE)' : ''); ?>

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

                        <!-- Account Filter -->
                        <div>
                            <select name="account_id" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px] cursor-pointer">
                                <option value="">Tous les comptes</option>
                                <?php $__currentLoopData = $accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($account->id); ?>" <?php echo e(request('account_id') == $account->id ? 'selected' : ''); ?>>
                                        <?php echo e($account->name); ?>

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

                        <!-- Project Filter -->
                        <div>
                            <select name="project_id" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px] cursor-pointer">
                                <option value="">Tous les projets</option>
                                <?php $__currentLoopData = $projects; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $project): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($project->id); ?>" <?php echo e(request('project_id') == $project->id ? 'selected' : ''); ?>>
                                        <?php echo e($project->name); ?>

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

                        <!-- Member Filter -->
                        <div>
                            <select name="user_id" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px] cursor-pointer">
                                <option value="">Tous les membres</option>
                                <?php $__currentLoopData = $members; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $member): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($member->id); ?>" <?php echo e(request('user_id') == $member->id ? 'selected' : ''); ?>>
                                        <?php echo e($member->name ?? ($member->first_name . ' ' . $member->last_name)); ?>

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

                        <!-- Status Filter -->
                        <div>
                            <select name="status" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px] cursor-pointer">
                                <option value="">Tous les statuts</option>
                                <option value="paye" <?php echo e(request('status') === 'paye' ? 'selected' : ''); ?>>Payé</option>
                                <option value="non_paye" <?php echo e(request('status') === 'non_paye' ? 'selected' : ''); ?>>Non payé</option>
                            </select>
                        </div>

                        <!-- Date Start Filter -->
                        <div>
                            <input type="date" name="start_date" value="<?php echo e(request('start_date')); ?>" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px]">
                        </div>

                        <!-- Date End Filter -->
                        <div>
                            <input type="date" name="end_date" value="<?php echo e(request('end_date')); ?>" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px]">
                        </div>

                        <!-- Action Buttons -->
                        <div class="flex items-end gap-2">
                            <button type="submit" 
                                class="inline-flex items-center px-4 py-2 border border-emerald-600 text-white text-[13px] font-bold rounded-sm hover:opacity-90 h-[38px] transition-all group"
                                style="background-color: #10b981 !important;">
                                <svg class="w-4 h-4 mr-2 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" />
                                </svg>
                                Filtrer
                            </button>
                            <a href="<?php echo e(route('admin.reports.index')); ?>"
                                class="inline-flex items-center px-4 py-2 border border-red-600 text-white text-[13px] font-bold rounded-sm hover:opacity-90 h-[38px] transition-all group text-center flex justify-center"
                                style="background-color: #e01e22 !important; text-decoration: none !important;">
                                Effacer
                            </a>
                        </div>
                    </div>

                    <!-- Statistics Summary Bar -->
                    <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4 pt-4 border-t border-gray-200">
                        <div class="bg-emerald-50 border border-emerald-200 p-3 rounded-sm">
                            <p class="text-[11px] font-black text-emerald-600 uppercase tracking-widest mb-1">Cotisations Perçues</p>
                            <p class="text-[16px] font-black text-emerald-700"><?php echo e(number_format($totalContributions, 0, ',', ' ')); ?> <?php echo e($currency); ?></p>
                        </div>
                        
                        <div class="bg-amber-50 border border-amber-200 p-3 rounded-sm">
                            <p class="text-[11px] font-black text-amber-600 uppercase tracking-widest mb-1">En Attente</p>
                            <p class="text-[16px] font-black text-amber-700"><?php echo e(number_format($totalPending, 0, ',', ' ')); ?> <?php echo e($currency); ?></p>
                        </div>

                        <div class="bg-blue-50 border border-blue-200 p-3 rounded-sm">
                            <p class="text-[11px] font-black text-blue-600 uppercase tracking-widest mb-1">Total Crédits</p>
                            <p class="text-[16px] font-black text-blue-700"><?php echo e(number_format($totalCredits, 0, ',', ' ')); ?> <?php echo e($currency); ?></p>
                        </div>

                        <div class="bg-red-50 border border-red-200 p-3 rounded-sm">
                            <p class="text-[11px] font-black text-red-600 uppercase tracking-widest mb-1">Total Débits</p>
                            <p class="text-[16px] font-black text-red-700"><?php echo e(number_format($totalDebits, 0, ',', ' ')); ?> <?php echo e($currency); ?></p>
                        </div>

                        <div class="bg-indigo-50 border border-indigo-200 p-3 rounded-sm">
                            <p class="text-[11px] font-black text-indigo-600 uppercase tracking-widest mb-1">Solde de Tous les Comptes</p>
                            <p class="text-[16px] font-black text-indigo-700"><?php echo e(number_format($totalAccountBalance, 0, ',', ' ')); ?> <?php echo e($currency); ?></p>
                        </div>
                    </div>
                </form>
            </div>

            <style>
                .custom-scrollbar::-webkit-scrollbar {
                    height: 6px;
                    width: 6px;
                }
                .custom-scrollbar::-webkit-scrollbar-track {
                    background: #f8fafc;
                }
                .custom-scrollbar::-webkit-scrollbar-thumb {
                    background: #cbd5e1;
                    border-radius: 10px;
                }
                .custom-scrollbar::-webkit-scrollbar-thumb:hover {
                    background: #94a3b8;
                }
                .custom-v-lines th, .custom-v-lines td { border-right: 1px solid #d1d5db !important; }
                .custom-v-lines th:last-child, .custom-v-lines td:last-child { border-right: none !important; }
            </style>

            <!-- SECTIONS TABS/NAVIGATION -->
            <div x-data="{ tab: 'contributions' }">
                <div class="flex flex-col lg:flex-row lg:items-center justify-between mb-6 gap-4 border-b border-gray-100 pb-4">
                    <div class="flex items-center gap-2">
                        <button @click="tab = 'contributions'" 
                            :style="tab === 'contributions' ? 'background-color: #facc15 !important; color: black !important; border-color: #facc15 !important; font-weight: 900 !important;' : 'background-color: #f3f4f6 !important; color: #64748b !important; border-color: #e2e8f0 !important; font-weight: 700 !important;'"
                            class="inline-flex items-center justify-center px-4 py-2 border shadow-sm text-[12px] uppercase tracking-widest rounded-sm hover:opacity-90 h-[38px] transition-all">
                            Détail des Cotisations
                        </button>
                        <button @click="tab = 'transactions'" 
                            :style="tab === 'transactions' ? 'background-color: #facc15 !important; color: black !important; border-color: #facc15 !important; font-weight: 900 !important;' : 'background-color: #f3f4f6 !important; color: #64748b !important; border-color: #e2e8f0 !important; font-weight: 700 !important;'"
                            class="inline-flex items-center justify-center px-4 py-2 border shadow-sm text-[12px] uppercase tracking-widest rounded-sm hover:opacity-90 h-[38px] transition-all">
                            Détail des Opérations
                        </button>
                    </div>
                    
                    <div class="flex items-center gap-2">
                        <a href="<?php echo e(route('admin.reports.export.pdf', request()->all())); ?>" target="_blank"
                            class="inline-flex items-center justify-center px-4 py-2 text-white text-[13px] font-bold rounded-sm shadow-sm h-[38px] hover:opacity-90 transition-all whitespace-nowrap"
                            style="background-color: #5867dd !important; text-decoration: none !important;">
                            <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
                            </svg>
                            Exporter le Rapport
                        </a>
                    </div>
                </div>

                <!-- TABLES CONTAINER -->
                <div class="w-full">
                    <!-- Contributions Table -->
                    <div x-show="tab === 'contributions'" class="overflow-x-auto border border-gray-200 rounded-sm shadow-sm custom-scrollbar">
                        <table class="min-w-full divide-y divide-gray-200 text-[13px] custom-v-lines">
                            <thead>
                                <tr class="bg-gray-50/80">
                                    <th class="px-4 py-3.5 text-left text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200 whitespace-nowrap">Date</th>
                                    <th class="px-4 py-3.5 text-left text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200">Membre</th>
                                    <th class="px-4 py-3.5 text-left text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200">Projet</th>
                                    <th class="px-4 py-3.5 text-left text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200">Compte</th>
                                    <th class="px-4 py-3.5 text-right text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200 whitespace-nowrap">Montant</th>
                                    <th class="px-4 py-3.5 text-center text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200 whitespace-nowrap">Statut</th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-200 text-slate-700 bg-white">
                                <?php $__empty_1 = true; $__currentLoopData = $contributions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $contribution): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr class="hover:bg-gray-50/50 transition-colors">
                                        <td class="px-4 py-3.5 whitespace-nowrap font-bold text-gray-600"><?php echo e($contribution->payment_date ? $contribution->payment_date->format('d/m/Y') : '-'); ?></td>
                                        <td class="px-4 py-3.5 font-black uppercase text-slate-900"><?php echo e($contribution->user->name ?? ($contribution->user->first_name . ' ' . $contribution->user->last_name)); ?></td>
                                        <td class="px-4 py-3.5 font-bold text-slate-700 uppercase"><?php echo e($contribution->project->name ?? '-'); ?></td>
                                        <td class="px-4 py-3.5 font-bold text-slate-600 uppercase"><?php echo e($contribution->account->name ?? '-'); ?></td>
                                        <td class="px-4 py-3.5 whitespace-nowrap text-right font-black text-slate-900"><?php echo e(number_format($contribution->amount, 0, ',', ' ')); ?> <?php echo e($currency); ?></td>
                                        <td class="px-4 py-3.5 whitespace-nowrap text-center">
                                            <?php if($contribution->status === 'paye'): ?>
                                                <span class="inline-flex items-center px-3 py-1 rounded-full bg-emerald-100 text-emerald-800 border border-emerald-600 text-[10px] font-black uppercase tracking-widest">Payé</span>
                                            <?php else: ?>
                                                <span class="inline-flex items-center px-3 py-1 rounded-full bg-amber-100 text-amber-800 border border-amber-600 text-[10px] font-black uppercase tracking-widest">En attente</span>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="6" class="px-6 py-12 text-center text-gray-400 text-sm italic">Aucune cotisation trouvée.</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>

                    <!-- Transactions Table -->
                    <div x-show="tab === 'transactions'" class="overflow-x-auto border border-gray-200 rounded-sm shadow-sm custom-scrollbar" style="display: none;">
                        <table class="min-w-full divide-y divide-gray-200 text-[13px] custom-v-lines">
                            <thead>
                                <tr class="bg-gray-50/80">
                                    <th class="px-4 py-3.5 text-left text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200 whitespace-nowrap">Date</th>
                                    <th class="px-4 py-3.5 text-left text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200 whitespace-nowrap">Type</th>
                                    <th class="px-4 py-3.5 text-left text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200">Description</th>
                                    <th class="px-4 py-3.5 text-left text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200">Compte</th>
                                    <th class="px-4 py-3.5 text-right text-[11px] font-black text-slate-900 uppercase tracking-widest border-b border-gray-200 whitespace-nowrap">Montant</th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-200 text-slate-700 bg-white">
                                <?php $__empty_1 = true; $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transaction): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr class="hover:bg-gray-50/50 transition-colors">
                                        <td class="px-4 py-3.5 whitespace-nowrap font-bold text-gray-600"><?php echo e($transaction->date ? $transaction->date->format('d/m/Y') : '-'); ?></td>
                                        <td class="px-4 py-3.5 whitespace-nowrap">
                                            <?php if($transaction->type === 'credit'): ?>
                                                <span class="inline-flex items-center px-3 py-1 rounded-full bg-blue-100 text-blue-800 border border-blue-600 text-[10px] font-black uppercase tracking-widest">Crédit</span>
                                            <?php else: ?>
                                                <span class="inline-flex items-center px-3 py-1 rounded-full bg-red-100 text-red-800 border border-red-600 text-[10px] font-black uppercase tracking-widest">Débit</span>
                                            <?php endif; ?>
                                        </td>
                                        <td class="px-4 py-3.5 font-bold text-slate-700 uppercase"><?php echo e($transaction->description); ?></td>
                                        <td class="px-4 py-3.5 font-bold text-slate-600 uppercase"><?php echo e($transaction->account->name ?? '-'); ?></td>
                                        <td class="px-4 py-3.5 whitespace-nowrap text-right font-black <?php echo e($transaction->type === 'credit' ? 'text-blue-700' : 'text-red-700'); ?>">
                                            <?php echo e($transaction->type === 'credit' ? '+' : '-'); ?> <?php echo e(number_format($transaction->amount, 0, ',', ' ')); ?> <?php echo e($currency); ?>

                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="5" class="px-6 py-12 text-center text-gray-400 text-sm italic">Aucune opération financière trouvée.</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

        </div> <!-- End of SINGLE WHITE CARD CONTAINER -->
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal91fdd17964e43374ae18c674f95cdaa3)): ?>
<?php $attributes = $__attributesOriginal91fdd17964e43374ae18c674f95cdaa3; ?>
<?php unset($__attributesOriginal91fdd17964e43374ae18c674f95cdaa3); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal91fdd17964e43374ae18c674f95cdaa3)): ?>
<?php $component = $__componentOriginal91fdd17964e43374ae18c674f95cdaa3; ?>
<?php unset($__componentOriginal91fdd17964e43374ae18c674f95cdaa3); ?>
<?php endif; ?>
<?php /**PATH /home/fonix-sa/Bureau/Fonix projects/GASOS/resources/views/admin/reports/index.blade.php ENDPATH**/ ?>