<!DOCTYPE html>
<html>
<head>
    <title>Booking Receipt</title>
    <style>
        body { font-family: Arial, sans-serif; font-size: 14px; color: #333; }
        .header { text-align: center; margin-bottom: 20px; }
        .details, .sessions { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
        .details td, .sessions td, .sessions th { border: 1px solid #ddd; padding: 8px; }
        .sessions th { background-color: #f0f0f0; }
    </style>
</head>
<body>
    <div class="header">
        <h2>Booking Receipt</h2>
        <p>Transaction ID: {{ $transaction->transaction_token }}</p>
    </div>

    <table class="details">
        <tr>
            <td><strong>Student:</strong></td>
            <td>{{ $transaction->student->name ?? 'N/a' }} </td>
        </tr>
        <tr>
            <td><strong>Tutor:</strong></td>
            <td>{{ $transaction->tutor->name ?? 'N/A' }} </td>
        </tr>
        <tr>
            <td><strong>Booking Date:</strong></td>
            <td>{{ \Carbon\Carbon::parse($transaction->date)->format('d, M Y') }}</td>
        </tr>
        <tr>
            <td><strong>Total Sessions:</strong></td>
            <td>{{ $transaction->total_session ?? $transaction->total_sessions }}</td>
        </tr>
        <tr>
            <td><strong>Total Amount:</strong></td>
            <td>${{ number_format($transaction->amount, 2) }}</td>
        </tr>
        <tr>
            <td><strong>Payment Method:</strong></td>
            <td>{{ $transaction->payment_method ?? 'Paypal' }}</td>
        </tr>
        <tr>
            <td><strong>Payment Status:</strong></td>
            <td>{{ $transaction->status }}</td>
        </tr>
    </table>

    <h3>Sessions</h3>
    @if($transaction->booking->sessions)
    <table class="sessions">
        <thead>
            <tr>
                <th>Date</th>
                <th>Start Time</th>
                <th>End Time</th>
            </tr>
        </thead>
        <tbody>
            @foreach($transaction->booking->sessions as $session)
            <tr>
                <td>{{ \Carbon\Carbon::parse($session->start_date)->format('d, M Y') }}</td>
                <td>{{ \Carbon\Carbon::parse($session->start_time)->format('h:i A') }}</td>
                <td>{{ \Carbon\Carbon::parse($session->end_time)->format('h:i A') }}</td>
            </tr>
            @endforeach
        </tbody>
    </table>
    @endif

    <p>Thank you for using Tutera!</p>
</body>
</html>