@extends('layouts.app')

@section('title', 'My Records')

@section('content')
<div class="container-fluid px-4 py-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="display-md text-white mb-0">My Records</h1>
    </div>

    @if (session('status'))
        <div class="alert alert-success">{{ session('status') }}</div>
    @endif

    <div class="row g-4">
        <div class="col-lg-7">
            <div class="row g-3">
                @forelse($records as $record)
                    <div class="col-md-6">
                        <div class="card-arena p-4 h-100">
                            <div class="d-flex justify-content-between align-items-start gap-2 mb-2">
                                <h3 class="text-white fs-6 mb-0">{{ $record->title }}</h3>
                                <span class="badge-arena badge-muted">{{ $record->moderation_status->label() }}</span>
                            </div>
                            <p class="text-muted fs-sm mb-2">{{ $record->game->name }} · {{ $record->record_type->label() }}</p>
                            @if($record->media->isNotEmpty())
                                <p class="fs-xs text-muted mb-0">{{ $record->media->count() }} screenshot(s)</p>
                            @endif
                            <form method="POST" action="{{ route('profile.records.destroy', $record) }}" class="mt-3" onsubmit="return confirm('Delete this record?');">
                                @csrf
                                @method('DELETE')
                                <button type="submit" class="btn-arena btn-sm btn-outline-light">Delete</button>
                            </form>
                        </div>
                    </div>
                @empty
                    <div class="col-12">
                        <div class="card-arena p-4 text-muted">No records yet. Add your first achievement.</div>
                    </div>
                @endforelse
            </div>
            <div class="mt-3">{{ $records->links() }}</div>
        </div>

        <div class="col-lg-5">
            @include('pages.profile.records.form')
        </div>
    </div>
</div>
@endsection
