@extends('layouts.admin')

@section('title', $user->display_name ?? $user->name)

@section('content')
<div class="row g-4">
    <div class="col-lg-8">
        <div class="card-arena p-4 mb-4">
            <h2 class="card-title fs-5 mb-3">{{ __('admin.users.view_profile') }}</h2>
            <dl class="row mb-0">
                <dt class="col-sm-4 text-muted">Username</dt><dd class="col-sm-8">{{ $user->username }}</dd>
                <dt class="col-sm-4 text-muted">Email</dt><dd class="col-sm-8">{{ $user->email }}</dd>
                <dt class="col-sm-4 text-muted">Role</dt><dd class="col-sm-8">{{ $user->role->label() }}</dd>
                <dt class="col-sm-4 text-muted">Status</dt><dd class="col-sm-8">{{ $user->status->label() }}</dd>
                <dt class="col-sm-4 text-muted">Phone</dt><dd class="col-sm-8">{{ $user->phone_e164 ?? '—' }}</dd>
                <dt class="col-sm-4 text-muted">Joined</dt><dd class="col-sm-8">{{ $user->created_at->format('M j, Y') }}</dd>
            </dl>
        </div>

        @if($user->eventRegistrations->isNotEmpty())
            <div class="card-arena p-4">
                <h2 class="card-title fs-5 mb-3">{{ __('admin.nav.registrations') }}</h2>
                <ul class="list-unstyled mb-0">
                    @foreach($user->eventRegistrations as $registration)
                        <li class="py-2 border-bottom border-secondary-subtle">
                            {{ $registration->event->title }}
                            <span class="badge bg-secondary ms-2">{{ $registration->status->label() }}</span>
                        </li>
                    @endforeach
                </ul>
            </div>
        @endif
    </div>

    <div class="col-lg-4">
        <div class="card-arena p-4">
            <h2 class="card-title fs-5 mb-3">{{ __('admin.actions.suspend') }}</h2>
            @if($user->status === \App\Enums\UserStatus::Active)
                <form method="POST" action="{{ route('admin.users.suspend', $user) }}" onsubmit="return confirm(@json(__('admin.confirm.suspend')))">
                    @csrf
                    <button type="submit" class="btn-arena btn-danger w-100">{{ __('admin.actions.suspend') }}</button>
                </form>
            @else
                <form method="POST" action="{{ route('admin.users.reactivate', $user) }}">
                    @csrf
                    <button type="submit" class="btn-arena btn-primary w-100">{{ __('admin.actions.reactivate') }}</button>
                </form>
            @endif
        </div>
    </div>
</div>
@endsection
