<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Parcel List</title>
    <style>
        body { font-family: sans-serif; font-size: 12px; }
        table { width: 100%; border-collapse: collapse; margin-top: 20px; }
        th, td { border: 1px solid #ddd; padding: 6px; text-align: left; }
        th { background-color: #f2f2f2; }
        .header { text-align: center; margin-bottom: 20px; }
        .meta { margin-bottom: 10px; font-size: 10px; color: #666; }
        @media print {
            .no-print { display: none; }
            table { font-size: 10px; }
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>Parcel List</h1>
        <p class="meta">Generated on: {% now "Y-m-d H:i" %}</p>
    </div>
    
    {% if not is_pdf %}
    <div class="no-print" style="margin-bottom: 20px; text-align: center;">
        <button onclick="window.print()" style="padding: 10px 20px; font-size: 16px; cursor: pointer;">Print List</button>
        <button onclick="window.history.back()" style="padding: 10px 20px; font-size: 16px; cursor: pointer; margin-left: 10px;">Back</button>
    </div>
    {% endif %}

    <table>
        <thead>
            <tr>
                <th>Tracking #</th>
                <th>Shipper</th>
                <th>Carrier</th>
                <th>Receiver</th>
                <th>From</th>
                <th>To</th>
                <th>Status</th>
                <th>Price</th>
                <th>Created At</th>
            </tr>
        </thead>
        <tbody>
            {% for parcel in parcels %}
            <tr>
                <td>{{ parcel.tracking_number }}</td>
                <td>{{ parcel.shipper.username|default:"-" }}</td>
                <td>{{ parcel.carrier.username|default:"-" }}</td>
                <td>{{ parcel.receiver_name }}</td>
                <td>{{ parcel.pickup_city.name_en|default:"-" }}</td>
                <td>{{ parcel.delivery_city.name_en|default:"-" }}</td>
                <td>{{ parcel.get_status_display }}</td>
                <td>{{ parcel.price }}</td>
                <td>{{ parcel.created_at|date:"Y-m-d H:i" }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</body>
</html>