<x-layouts.app :title="'Notifications - ' . config('app.name')" activePage="notifications">
<div class="space-y-6">
    <div class="flex flex-col sm:flex-row sm:justify-between sm:items-end gap-3">
        <div>
            <h2 class="text-xl sm:text-2xl font-bold text-gray-800">Notifications</h2>
            <p class="text-sm text-gray-500 mt-1">Your alerts and account activity updates.</p>
        </div>
        @if($notifications->total() > 0)
            <form method="POST" action="{{ route('notifications.markAllRead') }}">
                @csrf
                <button type="submit" class="text-sm text-blue-700 font-medium hover:underline">Mark all as read</button>
            </form>
        @endif
    </div>

    <!-- Filter -->
    <form method="GET" action="{{ route('notifications') }}" class="flex items-center gap-3 flex-wrap">
        <select name="type" class="text-sm border border-gray-300 rounded px-3 py-2 bg-white focus:ring-1 focus:ring-blue-500 focus:border-blue-500">
            <option value="">All Types</option>
            @foreach(\App\Enums\NotificationType::cases() as $notifType)
                <option value="{{ $notifType->value }}" {{ request('type') === $notifType->value ? 'selected' : '' }}>{{ $notifType->label() }}</option>
            @endforeach
        </select>
        <button type="submit" class="px-4 py-2 bg-gray-800 text-white text-sm rounded hover:bg-gray-700">Filter</button>
    </form>

    <div class="space-y-3">
        @forelse($notifications as $notification)
            <div class="bg-white border border-gray-200 rounded shadow-sm p-4 flex items-start gap-4 {{ !$notification->is_read ? 'border-l-4 border-l-blue-600' : '' }}">
                <div class="shrink-0 mt-0.5">
                    @if($notification->type === \App\Enums\NotificationType::Success)
                        <div class="w-10 h-10 rounded-full bg-green-100 flex items-center justify-center">
                            <svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M5 13l4 4L19 7" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg>
                        </div>
                    @elseif($notification->type === \App\Enums\NotificationType::Warning)
                        <div class="w-10 h-10 rounded-full bg-yellow-100 flex items-center justify-center">
                            <svg class="w-5 h-5 text-yellow-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg>
                        </div>
                    @elseif($notification->type === \App\Enums\NotificationType::Alert)
                        <div class="w-10 h-10 rounded-full bg-red-100 flex items-center justify-center">
                            <svg class="w-5 h-5 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg>
                        </div>
                    @else
                        <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center">
                            <svg class="w-5 h-5 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg>
                        </div>
                    @endif
                </div>
                <div class="flex-1 min-w-0">
                    <div class="flex items-center justify-between gap-2">
                        <h3 class="text-sm font-semibold text-gray-800">{{ $notification->title }}</h3>
                        <span class="text-xs text-gray-400 shrink-0">{{ $notification->created_at->diffForHumans() }}</span>
                    </div>
                    <p class="text-sm text-gray-600 mt-1">{{ $notification->message }}</p>
                    @if($notification->link)
                        <a href="{{ $notification->link }}" class="text-xs text-blue-700 font-medium mt-2 inline-block hover:underline">View Details &rarr;</a>
                    @endif
                </div>
            </div>
        @empty
            <div class="bg-white border border-gray-200 rounded shadow-sm p-12 text-center text-gray-500">
                <svg class="w-12 h-12 mx-auto mb-3 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg>
                <p>No notifications yet.</p>
            </div>
        @endforelse
    </div>

    <div class="mt-4">
        {{ $notifications->links() }}
    </div>
</div>
</x-layouts.app>
