@extends('layouts.admin')

@section('title', 'Income')

@section('page-title', 'Income')

@section('header-actions')
    <a href="{{ route('admin.income.create') }}" class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-blue-600 transition-colors flex items-center gap-2">
        <span class="material-symbols-outlined text-lg">add</span>
        <span>Record Income</span>
    </a>
@endsection

@section('content')
<div class="max-w-7xl mx-auto">
    <div class="bg-white rounded-xl shadow-sm border border-[#e5e7eb] overflow-hidden">
        <div class="overflow-x-auto">
            <table class="w-full text-left">
                <thead class="bg-background-light border-b border-[#e5e7eb]">
                    <tr>
                        <th class="py-3 px-4 text-xs font-semibold text-[#617589] uppercase tracking-wider">Income #</th>
                        <th class="py-3 px-4 text-xs font-semibold text-[#617589] uppercase tracking-wider">Account</th>
                        <th class="py-3 px-4 text-xs font-semibold text-[#617589] uppercase tracking-wider">Customer</th>
                        <th class="py-3 px-4 text-xs font-semibold text-[#617589] uppercase tracking-wider text-right">Amount</th>
                        <th class="py-3 px-4 text-xs font-semibold text-[#617589] uppercase tracking-wider">Date</th>
                        <th class="py-3 px-4 text-xs font-semibold text-[#617589] uppercase tracking-wider">Status</th>
                        <th class="py-3 px-4 text-xs font-semibold text-[#617589] uppercase tracking-wider text-right">Actions</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-[#e5e7eb]">
                    @forelse($income as $item)
                        <tr class="hover:bg-background-light/50 transition-colors">
                            <td class="py-4 px-4">
                                <a href="{{ route('admin.income.show', $item) }}" class="text-primary hover:underline font-medium">
                                    {{ $item->income_number }}
                                </a>
                            </td>
                            <td class="py-4 px-4 text-sm text-[#111418] text-gray-900">
                                {{ $item->account->name }}
                            </td>
                            <td class="py-4 px-4 text-sm text-[#617589]">
                                {{ $item->customer->name ?? '-' }}
                            </td>
                            <td class="py-4 px-4 text-sm font-medium text-[#111418] text-gray-900 text-right">
                                {{ $item->currency }} {{ number_format($item->total, 2) }}
                            </td>
                            <td class="py-4 px-4 text-sm text-[#617589]">
                                {{ $item->income_date->format('M d, Y') }}
                            </td>
                            <td class="py-4 px-4">
                                <span class="px-2 py-1 rounded text-xs font-medium {{ $item->status === 'recorded' ? 'bg-green-100 text-green-800' : 'bg-gray-100 text-gray-800' }}">
                                    {{ ucfirst($item->status) }}
                                </span>
                            </td>
                            <td class="py-4 px-4 text-right">
                                <a href="{{ route('admin.income.show', $item) }}" class="p-2 text-[#617589] hover:text-primary hover:bg-primary/10 rounded transition-colors" title="View">
                                    <span class="material-symbols-outlined text-lg">visibility</span>
                                </a>
                            </td>
                        </tr>
                    @empty
                        <tr>
                            <td colspan="7" class="py-12 px-4 text-center text-[#617589]">
                                <span class="material-symbols-outlined text-4xl mb-2 block">trending_up</span>
                                <p>No income records found</p>
                            </td>
                        </tr>
                    @endforelse
                </tbody>
            </table>
        </div>

        @if($income->hasPages())
            <div class="px-4 py-4 border-t border-[#e5e7eb]">
                {{ $income->links() }}
            </div>
        @endif
    </div>
</div>
@endsection



