@extends('layouts.customer')

@section('title', 'Notifications – Customer Portal')
@section('page_title', 'Notifications & Alerts')

@section('content')
<div class="max-w-4xl space-y-6">
    
    <div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
        <div>
            <h2 class="text-xl font-bold text-white font-heading">System Notifications</h2>
            <p class="text-xs text-slate-400">Live auction bid status updates, vessel tracking alerts, and invoicing milestones.</p>
        </div>
        
        @if(Auth::user()->unreadNotifications()->count() > 0)
            <form method="POST" action="{{ route('customer.notifications.read-all') }}">
                @csrf
                <button type="submit" class="px-4 py-2 rounded-xl bg-white/10 hover:bg-white/20 text-white font-bold text-xs transition flex items-center gap-2">
                    <i class="fa-solid fa-check-double"></i>
                    <span>Mark All as Read</span>
                </button>
            </form>
        @endif
    </div>

    <div class="bg-slate-900 border border-white/10 rounded-2xl overflow-hidden shadow-xl">
        @if($notifications->count() > 0)
            <div class="divide-y divide-white/5">
                @foreach($notifications as $item)
                    <div class="p-5 flex items-start gap-4 transition {{ $item->is_read ? 'hover:bg-white/5 opacity-80' : 'bg-red-950/20 hover:bg-red-950/30' }}">
                        <div class="w-10 h-10 rounded-xl flex items-center justify-center shrink-0 text-base {{ $item->is_read ? 'bg-slate-800 text-slate-400' : 'bg-red-600 text-white shadow-lg' }}">
                            <i class="fa-solid fa-bell"></i>
                        </div>
                        <div class="flex-1 min-w-0">
                            <div class="flex items-center justify-between gap-2">
                                <h4 class="text-xs sm:text-sm font-bold {{ $item->is_read ? 'text-slate-200' : 'text-white' }}">
                                    {{ $item->title }}
                                </h4>
                                <span class="text-[10px] text-slate-500 shrink-0">
                                    {{ $item->created_at->diffForHumans() }}
                                </span>
                            </div>
                            <p class="text-xs text-slate-400 mt-1 leading-relaxed">
                                {{ $item->message }}
                            </p>
                            @if($item->action_url)
                                <a href="{{ $item->action_url }}" class="inline-flex items-center gap-1 text-[11px] font-bold text-red-400 hover:text-red-300 mt-2">
                                    <span>View Related Record</span> <i class="fa-solid fa-arrow-right text-[9px]"></i>
                                </a>
                            @endif
                        </div>
                    </div>
                @endforeach
            </div>
            <div class="p-4 border-t border-white/10">
                {{ $notifications->links() }}
            </div>
        @else
            <div class="p-12 text-center text-slate-400">
                <i class="fa-regular fa-bell-slash text-4xl mb-3 text-slate-600 block"></i>
                <p class="text-base font-bold text-white">No notifications yet.</p>
                <p class="text-xs text-slate-500 mt-1">When you place bids or track imports, real-time updates will appear here.</p>
            </div>
        @endif
    </div>

</div>
@endsection
