<!DOCTYPE html>
<html lang="cs">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Deutsche Post Shipping Label</title>
    <style>
        @page {
            size: A4;
            margin: 1cm;
        }
        
        body {
            font-family: Arial, sans-serif;
            font-size: 12px;
            line-height: 1.4;
            margin: 0;
            padding: 0;
        }
        
        .header {
            text-align: center;
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 30px;
            border-bottom: 2px solid #333;
            padding-bottom: 10px;
        }
        
        .logo {
            color: #FF0000;
            font-size: 20px;
        }
        
        .order-info {
            margin-bottom: 30px;
            background-color: #f5f5f5;
            padding: 15px;
            border-radius: 5px;
        }
        
        .order-info h3 {
            margin-top: 0;
            color: #333;
            font-size: 14px;
        }
        
        .info-row {
            margin-bottom: 8px;
        }
        
        .label {
            font-weight: bold;
            display: inline-block;
            width: 120px;
        }
        
        .recipient-section {
            margin-bottom: 30px;
            border: 2px solid #333;
            padding: 20px;
            background-color: #fff;
        }
        
        .recipient-section h3 {
            margin-top: 0;
            font-size: 16px;
            font-weight: bold;
            text-transform: uppercase;
            border-bottom: 1px solid #ccc;
            padding-bottom: 5px;
        }
        
        .recipient-address {
            font-size: 14px;
            line-height: 1.6;
            margin-top: 15px;
        }
        
        .recipient-name {
            font-size: 16px;
            font-weight: bold;
            margin-bottom: 10px;
        }
        
        .shipment-details {
            display: flex;
            justify-content: space-between;
            margin-bottom: 30px;
        }
        
        .shipment-column {
            width: 48%;
            background-color: #f9f9f9;
            padding: 15px;
            border-radius: 5px;
        }
        
        .shipment-column h4 {
            margin-top: 0;
            color: #333;
            font-size: 14px;
            border-bottom: 1px solid #ddd;
            padding-bottom: 5px;
        }
        
        .barcode-section {
            text-align: center;
            margin-top: 30px;
            padding: 20px;
            background-color: #f0f0f0;
            border-radius: 5px;
        }
        
        .barcode {
            font-family: 'Courier New', monospace;
            font-size: 24px;
            font-weight: bold;
            letter-spacing: 2px;
            padding: 10px;
            background-color: #fff;
            border: 1px solid #333;
            display: inline-block;
            margin: 10px 0;
        }
        
        .tracking-info {
            text-align: center;
            margin-top: 20px;
            font-size: 10px;
            color: #666;
        }
        
        .service-badge {
            display: inline-block;
            padding: 5px 10px;
            background-color: #FF0000;
            color: white;
            border-radius: 3px;
            font-weight: bold;
            text-transform: uppercase;
        }
        
        .priority {
            background-color: #FF6600;
        }
        
        .standard {
            background-color: #0066CC;
        }
    </style>
</head>
<body>
    <div class="header">
        <div class="logo">Deutsche Post</div>
        <div>International Shipping Label</div>
    </div>

    <div class="order-info">
        <h3>Informace o objednávce / Order Information</h3>
        <div class="info-row">
            <span class="label">Order ID:</span>
            <span>{{ order.order_id|default:'Pending' }}</span>
        </div>
        <div class="info-row">
            <span class="label">AWB Number:</span>
            <span>{{ order.awb_number|default:'N/A' }}</span>
        </div>
        <div class="info-row">
            <span class="label">Barcode:</span>
            <span>{{ order.barcode|default:'N/A' }}</span>
        </div>
        <div class="info-row">
            <span class="label">Customer Ref:</span>
            <span>{{ order.cust_ref|default:'N/A' }}</span>
        </div>
        <div class="info-row">
            <span class="label">Service Level:</span>
            <span class="service-badge {% if order.service_level == 'PRIORITY' %}priority{% else %}standard{% endif %}">
                {{ order.service_level }}
            </span>
        </div>
    </div>

    <div class="recipient-section">
        <h3>Příjemce / Recipient</h3>
        <div class="recipient-address">
            <div class="recipient-name">{{ order.recipient_name }}</div>
            <div>{{ order.address_line1 }}</div>
            {% if order.address_line2 %}
                <div>{{ order.address_line2 }}</div>
            {% endif %}
            {% if order.address_line3 %}
                <div>{{ order.address_line3 }}</div>
            {% endif %}
            <div>{{ order.postal_code }} {{ order.city }}</div>
            {% if order.address_state %}
                <div>{{ order.address_state }}</div>
            {% endif %}
            <div><strong>{{ order.destination_country }}</strong></div>
            {% if order.recipient_phone %}
                <div>Tel: {{ order.recipient_phone }}</div>
            {% endif %}
            {% if order.recipient_email %}
                <div>Email: {{ order.recipient_email }}</div>
            {% endif %}
        </div>
    </div>

    <div class="shipment-details">
        <div class="shipment-column">
            <h4>Detaily zásilky / Shipment Details</h4>
            <div class="info-row">
                <span class="label">Product:</span>
                <span>{{ order.product_type }}</span>
            </div>
            <div class="info-row">
                <span class="label">Weight:</span>
                <span>{{ order.shipment_gross_weight }}g</span>
            </div>
            <div class="info-row">
                <span class="label">Value:</span>
                <span>{{ order.shipment_amount }} {{ order.shipment_currency }}</span>
            </div>
            {% if order.sender_tax_id %}
                <div class="info-row">
                    <span class="label">IOSS:</span>
                    <span>{{ order.sender_tax_id }}</span>
                </div>
            {% endif %}
        </div>
        
        <div class="shipment-column">
            <h4>Doručení / Delivery</h4>
            <div class="info-row">
                <span class="label">Est. Days:</span>
                <span>{{ estimated_delivery_days }} days</span>
            </div>
            <div class="info-row">
                <span class="label">Return:</span>
                <span>{% if order.return_item_wanted %}Yes{% else %}No{% endif %}</span>
            </div>
            <div class="info-row">
                <span class="label">Created:</span>
                <span>{{ order.created_at|date:"d.m.Y H:i" }}</span>
            </div>
        </div>
    </div>

    {% if order.awb_number or order.barcode %}
        <div class="barcode-section">
            <div>Tracking Number / Sledovací číslo</div>
            <div class="barcode">{{ order.awb_number|default:order.barcode }}</div>
            <div class="tracking-info">
                Track at: https://www.deutschepost.de/de/sendungsverfolgung.html
            </div>
        </div>
    {% endif %}

    <div class="tracking-info">
        Generated: {{ now|date:"d.m.Y H:i:s" }} | Deutsche Post International Shipping API
    </div>
</body>
</html>