{% extends "base.html" %}
{% load i18n %}

{% block content %}
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-8 col-lg-6">
            <div class="card shadow-lg border-0">
                <div class="card-body p-5">
                    <h2 class="mb-4 text-center">{% trans "Send Shipping Offer" %}</h2>
                    
                    <div class="card bg-light border-0 mb-4">
                        <div class="card-body">
                            <h6 class="text-primary mb-2">{% trans "Target Truck" %}</h6>
                            <div class="d-flex align-items-center">
                                {% if truck.truck_picture %}
                                <img src="{{ truck.truck_picture.url }}" class="rounded me-3" style="width: 60px; height: 60px; object-fit: cover;">
                                {% else %}
                                <div class="bg-secondary bg-opacity-10 rounded me-3 d-flex align-items-center justify-content-center" style="width: 60px; height: 60px;">
                                    <i class="fa-solid fa-truck text-muted"></i>
                                </div>
                                {% endif %}
                                <div>
                                    <div class="fw-bold">{{ truck.display_truck_type }} - {{ truck.display_model }}</div>
                                    <small class="text-muted">{% trans "Owner" %}: {{ truck.owner.username }} | {% trans "Plate" %}: {{ truck.plate_no }}</small>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <form method="post" novalidate>
                        {% csrf_token %}
                        
                        <h6 class="border-bottom pb-2 mb-3">{% trans "Shipment Details" %}</h6>
                        
                        <div class="mb-3">
                            <label class="form-label">{{ form.description.label }}</label>
                            {{ form.description }}
                            {{ form.description.errors }}
                        </div>
                        
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label class="form-label">{{ form.origin.label }}</label>
                                {{ form.origin }}
                                {{ form.origin.errors }}
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">{{ form.destination.label }}</label>
                                {{ form.destination }}
                                {{ form.destination.errors }}
                            </div>
                        </div>
                        
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label class="form-label">{{ form.weight.label }}</label>
                                {{ form.weight }}
                                {{ form.weight.errors }}
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">{{ form.delivery_date.label }}</label>
                                {{ form.delivery_date }}
                                {{ form.delivery_date.errors }}
                            </div>
                        </div>
                        
                        <h6 class="border-bottom pb-2 mb-3 mt-4">{% trans "Pricing & Terms" %}</h6>
                        
                        <div class="mb-3">
                            <label class="form-label">{{ form.amount.label }}</label>
                            <div class="input-group">
                                <span class="input-group-text">$</span>
                                {{ form.amount }}
                            </div>
                            {{ form.amount.errors }}
                        </div>
                        
                        <div class="mb-4">
                            <label class="form-label">{{ form.comments.label }}</label>
                            {{ form.comments }}
                            {{ form.comments.errors }}
                        </div>
                        
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary btn-lg py-3">
                                <i class="fa-solid fa-paper-plane me-2"></i>{% trans "Send Offer to Truck Owner" %}
                            </button>
                            <a href="{% url 'marketplace' %}" class="btn btn-link text-muted">{% trans "Cancel" %}</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
