<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Receipt - <?= htmlspecialchars($receipt->receipt_number) ?></title>
<style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body { font-family: 'Segoe UI', Arial, sans-serif; background: #f5f5f5; padding: 40px; }
    .receipt { max-width: 700px; margin: 0 auto; background: #fff; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); overflow: hidden; }
    .receipt-header { background: linear-gradient(135deg, #4e73df, #224abe); color: #fff; padding: 30px 40px; text-align: center; }
    .receipt-header h1 { font-size: 24px; margin-bottom: 4px; }
    .receipt-header .receipt-number { font-size: 14px; opacity: 0.8; }
    .receipt-body { padding: 40px; }
    .receipt-section { margin-bottom: 24px; }
    .receipt-section h3 { font-size: 14px; color: #666; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; border-bottom: 2px solid #4e73df; padding-bottom: 6px; }
    .receipt-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
    .receipt-table td { padding: 8px 12px; border-bottom: 1px solid #eee; }
    .receipt-table td:first-child { color: #666; width: 160px; }
    .receipt-table td:last-child { font-weight: 600; }
    .receipt-total { text-align: right; margin-top: 20px; padding-top: 16px; border-top: 2px solid #4e73df; font-size: 20px; font-weight: 700; color: #224abe; }
    .receipt-footer { text-align: center; padding: 20px 40px; border-top: 1px solid #eee; color: #999; font-size: 13px; }
    .badge { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; }
    .badge-success { background: #d4edda; color: #155724; }
    @media print {
        body { background: #fff; padding: 0; }
        .receipt { box-shadow: none; border-radius: 0; }
        .no-print { display: none !important; }
    }
    .no-print { text-align: center; margin-bottom: 16px; }
    .no-print button { padding: 10px 24px; border: none; background: #4e73df; color: #fff; border-radius: 6px; cursor: pointer; font-size: 14px; }
    .no-print button:hover { background: #224abe; }
</style>
</head>
<body>
<div class="no-print">
    <button onclick="window.print()"><i class="fas fa-print"></i> Print / Save as PDF</button>
</div>
<div class="receipt">
    <div class="receipt-header">
        <h1><?= htmlspecialchars($receipt->company_name ?? 'Ghana Anaesthesiologists Society') ?></h1>
        <div class="receipt-number">Receipt: <?= htmlspecialchars($receipt->receipt_number) ?></div>
    </div>
    <div class="receipt-body">
        <div class="receipt-section">
            <h3>Payment Receipt</h3>
            <table class="receipt-table">
                <tr><td>Receipt Number</td><td><?= htmlspecialchars($receipt->receipt_number) ?></td></tr>
                <tr><td>Issue Date</td><td><?= date('F d, Y', strtotime($receipt->issued_date)) ?></td></tr>
                <tr><td>Status</td><td><span class="badge badge-success">Paid</span></td></tr>
            </table>
        </div>
        <div class="receipt-section">
            <h3>Member Details</h3>
            <table class="receipt-table">
                <tr><td>Name</td><td><?= htmlspecialchars($receipt->first_name ? trim($receipt->first_name . ' ' . $receipt->last_name) : ($receipt->user_name ?? '')) ?></td></tr>
                <tr><td>Email</td><td><?= htmlspecialchars($receipt->email ?? '') ?></td></tr>
            </table>
        </div>
        <div class="receipt-section">
            <h3>Contribution Details</h3>
            <table class="receipt-table">
                <tr><td>Type</td><td><?= htmlspecialchars($receipt->contribution_type_name ?? 'N/A') ?></td></tr>
                <tr><td>Amount</td><td>GHS <?= number_format($receipt->amount, 2) ?></td></tr>
                <tr><td>Payment Date</td><td><?= isset($receipt->payment_date) ? date('F d, Y', strtotime($receipt->payment_date)) : 'N/A' ?></td></tr>
                <tr><td>Payment Method</td><td><?= htmlspecialchars(ucwords(str_replace('_', ' ', $receipt->payment_method ?? 'N/A'))) ?></td></tr>
                <?php if (!empty($receipt->transaction_ref)): ?>
                <tr><td>Transaction Ref</td><td><?= htmlspecialchars($receipt->transaction_ref) ?></td></tr>
                <?php endif; ?>
                <?php if (!empty($receipt->paid_month)): ?>
                <tr><td>Period</td><td><?= date('F Y', strtotime($receipt->paid_month . '-01')) ?></td></tr>
                <?php endif; ?>
            </table>
            <div class="receipt-total">GHS <?= number_format($receipt->amount, 2) ?></div>
        </div>
        <?php if (!empty($receipt->company_details)): ?>
        <div class="receipt-footer">
            <?= nl2br(htmlspecialchars($receipt->company_details)) ?>
        </div>
        <?php endif; ?>
        <div class="receipt-footer">
            Issued by: <?= htmlspecialchars($receipt->issued_by_name ?? 'System') ?>
        </div>
    </div>
</div>
</body>
</html>
