@extends('layouts.app')
@section('title','Editar Record')
@section('content')
 
<div style="display:flex;align-items:center;gap:1rem;margin-bottom:1.5rem">
    <h2 style="margin:0">✏️ Editar Record Anterior</h2>
    <a href="{{ route('tabelas.records.index') }}" class="btn btn-secondary">← Voltar</a>
</div>
 
<div style="background:#e8eef7;border-radius:var(--radius);padding:.75rem 1rem;
            margin-bottom:1.25rem;max-width:560px;font-size:.85rem">
    <strong>Categoria:</strong> {{ $record->category }}
    <p style="margin:.3rem 0 0;color:#555;font-size:.8rem">
        Preencha os dados do vencedor de 2024 nos campos abaixo.<br>
        Os campos ATU (atual) são preenchidos automaticamente pela Etapa 10.
    </p>
</div>
 
<form method="POST" action="{{ route('tabelas.records.update', $record->id) }}"
      style="max-width:480px;background:#fff;border-radius:var(--radius);
             box-shadow:0 2px 8px rgba(0,0,0,.06);padding:1.5rem 1.75rem">
    @csrf
    @method('PUT')
 
    @if($errors->any())
    <div class="alert alert-danger" style="margin-bottom:1rem">
        <ul style="margin:0;padding-left:1.2rem">
            @foreach($errors->all() as $e)<li>{{ $e }}</li>@endforeach
        </ul>
    </div>
    @endif
 
    {{-- Campos ANT --}}
    <p style="font-weight:bold;color:var(--blue);margin:0 0 1rem;font-size:.9rem">
        📅 Record Anterior (2024)
    </p>
 
    <div style="margin-bottom:1rem">
        <label style="font-weight:600;display:block;margin-bottom:.3rem;font-size:.88rem">
            Callsign Anterior
        </label>
        <input type="text" name="callsign_ant"
               value="{{ old('callsign_ant', $record->callsign_ant) }}"
               placeholder="Ex: PY6MV"
               style="width:100%;padding:.5rem .75rem;border:1px solid #ddd;
                      border-radius:var(--radius);font-size:.9rem;text-transform:uppercase"
               oninput="this.value=this.value.toUpperCase()">
    </div>
 
    <div style="margin-bottom:1rem">
        <label style="font-weight:600;display:block;margin-bottom:.3rem;font-size:.88rem">
            Nome Anterior
        </label>
        <input type="text" name="name_ant"
               value="{{ old('name_ant', $record->name_ant) }}"
               placeholder="Nome completo"
               style="width:100%;padding:.5rem .75rem;border:1px solid #ddd;
                      border-radius:var(--radius);font-size:.9rem;text-transform:uppercase"
               oninput="this.value=this.value.toUpperCase()">
    </div>
 
    <div style="margin-bottom:1.5rem">
        <label style="font-weight:600;display:block;margin-bottom:.3rem;font-size:.88rem">
            Final Score Anterior
        </label>
        <input type="number" name="final_score_ant" min="0"
               value="{{ old('final_score_ant', $record->final_score_ant) }}"
               placeholder="0"
               style="width:100%;padding:.5rem .75rem;border:1px solid #ddd;
                      border-radius:var(--radius);font-size:.9rem">
    </div>
 
    {{-- Campos ATU (somente leitura) --}}
    @if($record->callsign_atu)
    <div style="background:#f8f9fa;border-radius:var(--radius);padding:.75rem 1rem;
                margin-bottom:1.25rem;font-size:.82rem;color:#555">
        <strong>Record Atual (preenchido pela Etapa 10):</strong><br>
        Callsign: {{ $record->callsign_atu }}
        &nbsp;|&nbsp; Score: {{ number_format($record->final_score_atu) }}
    </div>
    @endif
 
    <div style="display:flex;gap:.75rem">
        <button type="submit" class="btn btn-primary">💾 Salvar</button>
        <a href="{{ route('tabelas.records.index') }}" class="btn btn-secondary">Cancelar</a>
    </div>
</form>
@endsection