@extends('layouts.app')

@section('title', __('events.my_events.title'))

@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">{{ __('events.my_events.title') }}</h1>
        <a href="{{ route('events.index') }}" class="btn-arena btn-sm btn-ghost">Browse Events</a>
    </div>

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

    <div class="tabs-arena mb-4 d-flex gap-2">
        <a href="{{ route('my-events.index', ['tab' => 'upcoming']) }}" class="btn-arena btn-sm {{ $tab === 'upcoming' ? 'btn-primary' : 'btn-ghost' }}">{{ __('events.my_events.upcoming') }}</a>
        <a href="{{ route('my-events.index', ['tab' => 'past']) }}" class="btn-arena btn-sm {{ $tab === 'past' ? 'btn-primary' : 'btn-ghost' }}">{{ __('events.my_events.past') }}</a>
    </div>

    <div class="row g-3">
        @forelse($registrations as $registration)
            <div class="col-md-6 col-lg-4">
                <div class="card-arena p-4 h-100">
                    <h3 class="text-white fs-6 mb-1">{{ $registration->event->title }}</h3>
                    <p class="text-muted fs-sm mb-2">{{ $registration->event->game->name }}</p>
                    <span class="badge-arena badge-muted">{{ $registration->status->label() }}</span>
                    @if($registration->payment_status)
                        <span class="badge-arena badge-muted ms-1">{{ $registration->payment_status->label() }}</span>
                    @endif
                    <div class="d-flex flex-wrap gap-2 mt-3">
                        <a href="{{ route('registrations.show', $registration) }}" class="btn-arena btn-sm btn-outline-light">{{ __('events.my_events.view_registration') }}</a>
                        @if(in_array($registration->status, [\App\Enums\RegistrationStatus::PendingPayment, \App\Enums\RegistrationStatus::PaymentReview], true))
                            <a href="{{ route('registrations.payment-proof.create', $registration) }}" class="btn-arena btn-sm btn-primary">{{ __('events.my_events.complete_payment') }}</a>
                        @endif
                    </div>
                </div>
            </div>
        @empty
            <div class="col-12">
                <div class="card-arena p-4 text-muted">{{ __('events.my_events.no_events') }}</div>
            </div>
        @endforelse
    </div>

    <div class="mt-3">{{ $registrations->appends(['tab' => $tab])->links() }}</div>
</div>
@endsection
