<?php $__env->startSection('title', 'Meu LOG — ' . ($callsign ?: 'Consulta')); ?>
<?php $__env->startSection('content'); ?>

<div class="card">
    <form method="GET" action="<?php echo e(route('public.resultados.callsign')); ?>" class="search-bar">
        <input type="text" name="callsign" value="<?php echo e($callsign); ?>"
               placeholder="Digite seu callsign (ex: PY6MV)"
               style="text-transform:uppercase;max-width:220px"
               oninput="this.value=this.value.toUpperCase()"
               autofocus>
        <button type="submit">🔍 Consultar</button>
        <?php if($callsign): ?>
            <a href="<?php echo e(route('public.resultados.callsign')); ?>"
               style="padding:.45rem .8rem;color:#666;text-decoration:none;font-size:.88rem">✕ Limpar</a>
        <?php endif; ?>
    </form>

    <?php if($callsign && $qsos->isEmpty()): ?>
        <p style="color:#888;padding:1.5rem 0">
            Nenhum QSO encontrado para <strong><?php echo e($callsign); ?></strong> neste contest.
        </p>
    <?php endif; ?>
</div>

<?php if($callsign && !$qsos->isEmpty()): ?>

    
    <?php if($resumo): ?>
    <div class="stats">
        <div class="stat">
            <div class="stat-num"><?php echo e($resumo->rk); ?>º</div>
            <div class="stat-lbl">Posição — <?php echo e($resumo->categoria); ?></div>
        </div>
        <div class="stat green">
            <div class="stat-num"><?php echo e(number_format($resumo->total_qsos_validos)); ?></div>
            <div class="stat-lbl">QSOs Válidos</div>
        </div>
        <div class="stat gold">
            <div class="stat-num"><?php echo e(number_format($resumo->final_score)); ?></div>
            <div class="stat-lbl">Final Score</div>
        </div>
        <div class="stat">
            <div class="stat-num"><?php echo e(number_format($resumo->total_pontos)); ?></div>
            <div class="stat-lbl">Pontos</div>
        </div>
        <div class="stat">
            <div class="stat-num"><?php echo e($resumo->total_multi_um + $resumo->total_multi_dois + $resumo->total_multi_tres); ?></div>
            <div class="stat-lbl">Multiplicadores</div>
        </div>
        <?php if($resumo->percentual_reducao > 0): ?>
        <div class="stat" style="background:#c62828">
            <div class="stat-num"><?php echo e(number_format($resumo->percentual_reducao, 1)); ?>%</div>
            <div class="stat-lbl">Redução</div>
        </div>
        <?php endif; ?>
    </div>
    <?php endif; ?>

    
    <div class="card">
        <?php
            $validos   = $qsos->where('confirmado', 1)->count();
            $invalidos = $qsos->where('confirmado', 0)->count();
        ?>
        <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem;flex-wrap:wrap;gap:.5rem">
            <h3 style="color:#1B4F8C;font-size:1rem">
                QSOs de <strong><?php echo e($callsign); ?></strong>
                — <?php echo e($qsos->count()); ?> total
            </h3>
            <div style="font-size:.82rem">
                <span class="badge-val">✅ <?php echo e($validos); ?> válidos</span>
                &nbsp;
                <?php if($invalidos > 0): ?>
                    <span class="badge-inv">❌ <?php echo e($invalidos); ?> inválidos</span>
                <?php endif; ?>
            </div>
        </div>

        <table>
            <thead>
                <tr>
                    <th>Call Rcvd</th>
                    <th>Banda</th>
                    <th>Modo</th>
                    <th>Freq (kHz)</th>
                    <th>Data/Hora UTC</th>
                    <th>Exch Sent</th>
                    <th>Exch Rcvd</th>
                    <th style="text-align:center">Status</th>
                    <th>Motivo</th>
                </tr>
            </thead>
            <tbody>
                <?php $__currentLoopData = $qsos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $q): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td class="call"><?php echo e($q->call_rcvd); ?></td>
                        <td><?php echo e($q->band); ?></td>
                        <td><?php echo e($q->category_mode); ?></td>
                        <td><?php echo e(number_format($q->frequency, 1)); ?></td>
                        <td style="font-size:.78rem;white-space:nowrap">
                            <?php echo e(\Carbon\Carbon::parse($q->date_time)->format('d/m/Y H:i')); ?>

                        </td>
                        <td><?php echo e($q->exch_sent); ?></td>
                        <td><?php echo e($q->exch_rcvd); ?></td>
                        <td style="text-align:center">
                            <?php if($q->confirmado): ?>
                                <span class="badge-val">✅</span>
                            <?php else: ?>
                                <span class="badge-inv">❌</span>
                            <?php endif; ?>
                        </td>
                        <td style="font-size:.75rem;color:#c62828"><?php echo e($q->motivo); ?></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
        </table>
    </div>
<?php endif; ?>
<?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/callsign.blade.php ENDPATH**/ ?>