@extends('layouts.admin')

@section('title', 'Platform Transactions')
@section('header_title', 'Razorpay Payment Transactions')

@section('content')
    <div class="card">
        <table>
            <thead>
                <tr>
                    <th>Txn ID / Order ID</th>
                    <th>Optical Store</th>
                    <th>Package Plan</th>
                    <th>Amount</th>
                    <th>Payment Gateway</th>
                    <th>Status</th>
                    <th>Date & Time</th>
                </tr>
            </thead>
            <tbody>
                @forelse($transactions as $txn)
                    <tr>
                        <td>
                            <strong style="color: #fff;">{{ $txn->txn_id }}</strong>
                            <div style="font-size: 0.8rem; color: var(--text-muted);">{{ $txn->order_id ?? 'N/A' }}</div>
                        </td>
                        <td>
                            <strong>{{ $txn->user->vendorProfile->vendor_name ?? $txn->user->name }}</strong>
                            <div style="font-size: 0.8rem; color: var(--text-muted);">{{ $txn->user->email }}</div>
                        </td>
                        <td>{{ $txn->package->name ?? 'Custom Plan' }}</td>
                        <td style="font-weight: 700; font-size: 1.05rem; color: #10B981;">₹{{ number_format($txn->amount, 2) }}</td>
                        <td><span class="badge" style="background: rgba(99, 102, 241, 0.2); color: var(--primary);">{{ strtoupper($txn->gateway) }}</span></td>
                        <td>
                            <span class="badge {{ $txn->status === 'success' ? 'badge-success' : 'badge-danger' }}">
                                {{ ucfirst($txn->status) }}
                            </span>
                        </td>
                        <td>{{ $txn->created_at->format('d M Y, h:i A') }}</td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="7" style="text-align: center; color: var(--text-muted); padding: 2rem;">No transaction logs available.</td>
                    </tr>
                @endforelse
            </tbody>
        </table>

        <div style="margin-top: 1.5rem;">
            {{ $transactions->links() }}
        </div>
    </div>
@endsection
