
<?php $__env->startSection('title', 'Operadores e Clubes'); ?>
<?php $__env->startSection('content'); ?>
 
<div class="stats">
    <div class="stat">
        <div class="stat-num"><?php echo e(number_format($totalOps)); ?></div>
        <div class="stat-lbl">Operadores</div>
    </div>
    <div class="stat green">
        <div class="stat-num"><?php echo e(number_format($totalClubes)); ?></div>
        <div class="stat-lbl">Clubes</div>
    </div>
</div>
 
<div class="card">
    <form method="GET" action="<?php echo e(route('public.resultados.clubes')); ?>" class="search-bar">
        <input type="text" name="q" value="<?php echo e($busca); ?>"
               placeholder="Buscar clube ou callsign...">
        <select name="grupo" onchange="this.form.submit()"
                style="padding:.45rem .8rem;border:1px solid #ddd;border-radius:5px;font-size:.88rem">
            <option value="">— Todos os grupos —</option>
            <?php $__currentLoopData = ['LABREs','BRAZIL','OUTROS']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $g): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($g); ?>" <?php echo e($grupo===$g ? 'selected':''); ?>><?php echo e($g); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
        <button type="submit">🔍 Filtrar</button>
        <?php if($busca || $grupo): ?>
            <a href="<?php echo e(route('public.resultados.clubes')); ?>"
               style="padding:.45rem .8rem;color:#666;text-decoration:none;font-size:.88rem">✕ Limpar</a>
        <?php endif; ?>
    </form>
 
    <?php
        $cores = [
            'LABREs' => ['bg'=>'#EBF5FB','titulo'=>'#1B4F8C','badge'=>'#AED6F1'],
            'BRAZIL' => ['bg'=>'#EAFAF1','titulo'=>'#1E8449','badge'=>'#A9DFBF'],
            'OUTROS' => ['bg'=>'#FEFCE8','titulo'=>'#7D6608','badge'=>'#F9E79F'],
        ];
    ?>
 
    <?php $__empty_1 = true; $__currentLoopData = $dados; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $groupName => $clubes): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
        <?php $cor = $cores[$groupName] ?? ['bg'=>'#f9f9f9','titulo'=>'#555','badge'=>'#ddd']; ?>
 
        <div style="margin-bottom:2rem">
            
            <div style="background:<?php echo e($cor['titulo']); ?>;color:#fff;padding:.55rem 1rem;
                        border-radius:6px 6px 0 0;font-weight:bold;font-size:.95rem;
                        display:flex;align-items:center;gap:.75rem">
                <?php echo e($groupName); ?>

                <span style="background:rgba(255,255,255,.2);border-radius:20px;
                             padding:.1rem .6rem;font-size:.78rem">
                    <?php echo e(count($clubes)); ?> clube(s)
                </span>
            </div>
 
            <?php $__currentLoopData = $clubes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $clubNome => $info): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php
                    if (strtoupper($groupName)==='BRAZIL' &&
                        strtoupper(substr(trim($clubNome),0,5))==='LABRE') continue;
                ?>
 
                <div style="border:1px solid #e0e0e0;border-top:none;margin-bottom:.4rem">
                    
                    <div style="background:<?php echo e($cor['bg']); ?>;padding:.45rem 1rem;
                                display:flex;justify-content:space-between;align-items:center">
                        <span style="font-weight:600;font-size:.88rem"><?php echo e($clubNome); ?></span>
                        <span style="background:<?php echo e($cor['badge']); ?>;border-radius:4px;
                                     padding:.15rem .5rem;font-size:.8rem;font-weight:bold">
                            Total: <?php echo e(number_format($info['club_total'])); ?>

                        </span>
                    </div>
 
                    <table>
                        <thead>
                            <tr>
                                <th>Callsign</th>
                                <th style="text-align:right">Pontos</th>
                                <th style="text-align:right">M1 (DXCC)</th>
                                <th style="text-align:right">M2 (UF)</th>
                                <th style="text-align:right">M3 (HQ)</th>
                                <th style="text-align:right">Final Score</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $totP=$totM1=$totM2=$totM3=$totF=0; ?>
                            <?php $__currentLoopData = $info['calls']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $op): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php
                                    $totP  += $op->total_pontos;
                                    $totM1 += $op->total_m1;
                                    $totM2 += $op->total_m2;
                                    $totM3 += $op->total_m3;
                                    $totF  += $op->final_score;
                                ?>
                                <tr>
                                    <td class="call">
                                        <a href="<?php echo e(route('public.resultados.callsign', ['callsign' => $op->call_sent])); ?>"
                                           style="color:#1B4F8C;text-decoration:none">
                                            <?php echo e($op->call_sent); ?>

                                        </a>
                                    </td>
                                    <td style="text-align:right"><?php echo e(number_format($op->total_pontos)); ?></td>
                                    <td style="text-align:right"><?php echo e($op->total_m1); ?></td>
                                    <td style="text-align:right"><?php echo e($op->total_m2); ?></td>
                                    <td style="text-align:right"><?php echo e($op->total_m3); ?></td>
                                    <td class="score"><?php echo e(number_format($op->final_score)); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            
                            <tr style="background:#f0f0f0;font-weight:bold;font-size:.8rem">
                                <td>TOTAL</td>
                                <td style="text-align:right"><?php echo e(number_format($totP)); ?></td>
                                <td style="text-align:right"><?php echo e($totM1); ?></td>
                                <td style="text-align:right"><?php echo e($totM2); ?></td>
                                <td style="text-align:right"><?php echo e($totM3); ?></td>
                                <td style="text-align:right;color:#1B4F8C"><?php echo e(number_format($totF)); ?></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
        <p style="color:#888;text-align:center;padding:2rem">Nenhum dado encontrado.</p>
    <?php endif; ?>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('public.resultados.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\projetos\labre-contest\resources\views/public/resultados/clubes.blade.php ENDPATH**/ ?>