@extends('layouts.aura-main')

@section('main-content')
<div class="max-w-6xl mx-auto pb-20">
    <div class="flex justify-between items-end mb-8">
        <div>
            <h1 class="text-2xl font-black text-slate-900  tracking-tighter">Inventory Transfers</h1>
            <p class="text-[10px] font-bold text-slate-400  tracking-widest mt-1 italic">Internal relocation log for all warehouses</p>
        </div>
        <a href="{{ route('inventory.transfers.create') }}" class="bg-slate-900 text-white px-6 py-2.5 text-[10px] font-black  tracking-widest shadow-xl hover:bg-indigo-600 transition-all">
            + New Stock Transfer
        </a>
    </div>

    <div class="bg-white border border-slate-200 rounded-sm shadow-sm overflow-hidden">
        <table class="w-full text-left border-collapse">
            <thead>
                <tr class="border-b border-slate-900 bg-slate-50 text-[9px] font-black text-slate-500  tracking-widest">
                    <th class="px-6 py-4">Date</th>
                    <th class="px-6 py-4">Reference</th>
                    <th class="px-6 py-4">Product</th>
                    <th class="px-6 py-4">Location</th>
                    <th class="px-6 py-4">Type</th>
                    <th class="px-6 py-4 text-right">Quantity</th>
                </tr>
            </thead>
            <tbody class="text-[11px] font-medium divide-y divide-slate-100  tracking-tight">
                @forelse($transfers as $trf)
                <tr class="hover:bg-slate-50/50 transition">
                    <td class="px-6 py-4 font-mono text-slate-500">
                        {{ $trf->created_at->format('d M Y') }}
                    </td>
                    <td class="px-6 py-4 font-mono font-bold text-slate-900">
                        {{ $trf->reference }}
                    </td>
                    <td class="px-6 py-4">
                        <span class="block font-black text-slate-900">{{ $trf->product->name ?? 'N/A' }}</span>
                        <span class="text-[9px] text-slate-400 italic">SKU: {{ $trf->product->sku ?? '---' }}</span>
                    </td>
                    <td class="px-6 py-4 font-bold text-slate-600">
                        {{ $trf->warehouse->name ?? 'Unknown' }}
                    </td>
                    <td class="px-6 py-4">
                        @if($trf->type === 'transfer_in')
                            <span class="text-emerald-600 font-black tracking-widest bg-emerald-50 px-2 py-0.5 rounded-full text-[8px]">RECEIVED</span>
                        @else
                            <span class="text-rose-600 font-black tracking-widest bg-rose-50 px-2 py-0.5 rounded-full text-[8px]">SENT</span>
                        @endif
                    </td>
                    <td class="px-6 py-4 text-right font-mono font-black {{ $trf->quantity > 0 ? 'text-emerald-600' : 'text-rose-600' }}">
                        {{ number_format($trf->quantity, 2) }}
                    </td>
                </tr>
                @empty
                <tr>
                    <td colspan="6" class="px-6 py-20 text-center">
                        <p class="text-[10px] font-black text-slate-300  tracking-widest">No transfer history found.</p>
                        <a href="{{ route('inventory.transfers.create') }}" class="text-indigo-600 text-[10px] font-bold  underline mt-2 inline-block">Execute first transfer</a>
                    </td>
                </tr>
                @endforelse
            </tbody>
        </table>
    </div>

    <div class="mt-6">
        {{ $transfers->links() }}
    </div>
</div>
@endsection