@extends('layouts.app')

@section('title', 'Deposits')
@section('heading', 'Deposits')

@section('content')
@php $currency = config('app.currency_symbol', '₹'); @endphp

@include('finance.top-submenu')

<x-card>
    <div class="mb-4 flex flex-wrap items-center justify-between gap-4">
        <div>
            <p class="text-sm text-slate-600">Record money received into company accounts.</p>
            <p class="mt-1 text-xs text-slate-500">Deposits automatically update the linked account balance.</p>
        </div>
        <a href="{{ route('deposits.create') }}" class="inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-sm font-medium text-white hover:bg-primary-hover">
            <i class="bi bi-plus-lg"></i> Add deposit
        </a>
    </div>
    <x-table>
        <x-slot name="head">
            <tr>
                <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Account</th>
                <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Amount</th>
                <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Date</th>
                <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500 hidden sm:table-cell">Reference</th>
                <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500 hidden lg:table-cell">Description</th>
                <th class="px-4 py-3 text-right text-xs font-medium uppercase text-slate-500">Actions</th>
            </tr>
        </x-slot>
        @forelse($deposits as $d)
            <tr class="hover:bg-slate-50/80">
                <td class="whitespace-nowrap px-4 py-3 text-sm font-medium text-slate-900">{{ $d->account?->name ?? '—' }}</td>
                <td class="whitespace-nowrap px-4 py-3 text-sm font-semibold text-emerald-700">+{{ $currency }}{{ number_format($d->amount, 2) }}</td>
                <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600">{{ $d->date?->format('M d, Y') }}</td>
                <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600 hidden sm:table-cell">{{ $d->reference ?? '—' }}</td>
                <td class="max-w-xs truncate px-4 py-3 text-sm text-slate-500 hidden lg:table-cell">{{ $d->description ?? '—' }}</td>
                <td class="whitespace-nowrap px-4 py-3 text-right text-sm">
                    <a href="{{ route('deposits.edit', $d) }}" class="btn-icon-action btn-icon-action--edit" title="Edit" aria-label="Edit"><i class="bi bi-pencil-square"></i></a>
                </td>
            </tr>
        @empty
            <tr><td colspan="6" class="px-4 py-10 text-center text-sm text-slate-500">No deposits yet.</td></tr>
        @endforelse
    </x-table>
    @if($deposits->hasPages())<div class="mt-4">{{ $deposits->links() }}</div>@endif
</x-card>
@endsection
