@extends('layouts.panel')

@section('title', 'Profile')

@section('content')
    <section class="profile-grid">
        <article class="card">
            <p class="eyebrow">Super Admin Profile</p>
            <div class="summary-list">
                <div class="summary-row"><span>Name</span><strong>{{ $user->name }}</strong></div>
                <div class="summary-row"><span>Email</span><strong>{{ $user->email }}</strong></div>
                <div class="summary-row"><span>Last Login</span><strong>{{ $user->last_login_at?->diffForHumans() ?? 'Never' }}</strong></div>
                <div class="summary-row"><span>Last Seen</span><strong>{{ $user->last_seen_at?->diffForHumans() ?? 'Never' }}</strong></div>
                <div class="summary-row"><span>Two-Factor</span><strong>{{ $user->two_factor_secret ? 'Configured' : 'Ready to configure' }}</strong></div>
                <div class="summary-row"><span>Active Sessions</span><strong>{{ $activeSessionCount }}</strong></div>
            </div>

            <form method="post" action="{{ route('logout') }}" style="margin-top: 1rem;">
                @csrf
                <button class="button danger" type="submit">Sign Out</button>
            </form>
        </article>

        <article class="card">
            <p class="eyebrow">Login History</p>
            <div class="summary-list">
                @forelse ($loginHistory as $entry)
                    <div class="summary-row">
                        <div>
                            <strong>{{ $entry->device_name }}</strong>
                            <p class="muted">{{ $entry->ip_address ?? 'Unknown IP' }}</p>
                        </div>
                        <span class="muted">{{ $entry->authenticated_at->diffForHumans() }}</span>
                    </div>
                @empty
                    <p class="muted">No login history recorded yet.</p>
                @endforelse
            </div>
        </article>
    </section>
@endsection
