{{-- 거래내역 테이블 (HTMX로 로드) --}}
<x-table-swipe>
    <table class="min-w-full">
        <thead class="bg-gray-50 border-b border-gray-200">
            <tr>
                <th class="px-6 py-3 text-center text-sm font-semibold text-gray-600">거래일</th>
                <th class="px-6 py-3 text-center text-sm font-semibold text-gray-600">유형</th>
                <th class="px-6 py-3 text-left text-sm font-semibold text-gray-600">적요</th>
                <th class="px-6 py-3 text-left text-sm font-semibold text-gray-600">거래상대방</th>
                <th class="px-6 py-3 text-right text-sm font-semibold text-gray-600">금액</th>
                <th class="px-6 py-3 text-right text-sm font-semibold text-gray-600">잔액</th>
                <th class="px-6 py-3 text-center text-sm font-semibold text-gray-600">대사</th>
            </tr>
        </thead>
        <tbody class="bg-white divide-y divide-gray-100">
            @forelse($transactions as $tx)
            <tr class="hover:bg-gray-50 transition-colors">
                {{-- 거래일 --}}
                <td class="px-6 py-4 whitespace-nowrap text-center text-sm text-gray-900">
                    {{ $tx->transaction_date->format('Y-m-d') }}
                    @if($tx->transaction_time)
                    <span class="text-gray-500 text-xs block">{{ $tx->transaction_time }}</span>
                    @endif
                </td>

                {{-- 유형 --}}
                <td class="px-6 py-4 whitespace-nowrap text-center">
                    <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
                        {{ $tx->transaction_type === 'deposit' ? 'bg-green-100 text-green-700' : '' }}
                        {{ $tx->transaction_type === 'withdrawal' ? 'bg-red-100 text-red-700' : '' }}
                        {{ $tx->transaction_type === 'transfer' ? 'bg-blue-100 text-blue-700' : '' }}
                    ">
                        {{ $tx->getTypeLabel() }}
                    </span>
                </td>

                {{-- 적요 --}}
                <td class="px-6 py-4 text-sm text-gray-900 max-w-xs truncate" title="{{ $tx->description }}">
                    {{ $tx->description ?? '-' }}
                </td>

                {{-- 거래상대방 --}}
                <td class="px-6 py-4 text-sm text-gray-700">
                    {{ $tx->counterparty ?? '-' }}
                </td>

                {{-- 금액 --}}
                <td class="px-6 py-4 whitespace-nowrap text-right">
                    <span class="text-sm font-semibold {{ $tx->getTypeColorClass() }}">
                        {{ $tx->formatted_amount }}
                    </span>
                </td>

                {{-- 잔액 --}}
                <td class="px-6 py-4 whitespace-nowrap text-right text-sm text-gray-900">
                    {{ $tx->formatted_balance_after }}
                </td>

                {{-- 대사 상태 --}}
                <td class="px-6 py-4 whitespace-nowrap text-center">
                    @if($tx->is_reconciled)
                    <span class="inline-flex items-center text-green-600" title="대사완료 {{ $tx->reconciled_at?->format('Y-m-d H:i') }}">
                        <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
                            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
                        </svg>
                    </span>
                    @else
                    <span class="inline-flex items-center text-gray-300">
                        <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
                            <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
                        </svg>
                    </span>
                    @endif
                </td>
            </tr>
            @empty
            <tr>
                <td colspan="7" class="px-6 py-12 text-center">
                    <div class="flex flex-col items-center gap-2">
                        <svg class="w-12 h-12 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
                        </svg>
                        <p class="text-gray-500">거래내역이 없습니다.</p>
                    </div>
                </td>
            </tr>
            @endforelse
        </tbody>
    </table>
</x-table-swipe>

{{-- 페이지네이션 --}}
@if($transactions->hasPages())
<div class="px-6 py-4 border-t border-gray-200 bg-gray-50">
    {{ $transactions->links() }}
</div>
@endif
