{% extends "base.html" %}

{% block title %}Checkout - Golden Uniforms{% endblock %}

{% block content %}
<div class="container py-4">
    <h2 class="mb-4">Checkout</h2>
    
    <div class="row">
        <div class="col-lg-8">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">Customer Information</h5>
                </div>
                <div class="card-body">
                    <form method="POST">
                        {{ form.hidden_tag() }}
                        
                        <div class="mb-3">
                            {{ form.name.label(class="form-label") }}
                            {{ form.name(class="form-control") }}
                            {% if form.name.errors %}
                                <div class="text-danger">
                                    {% for error in form.name.errors %}
                                        <small>{{ error }}</small>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                        
                        <div class="mb-3">
                            {{ form.phone.label(class="form-label") }}
                            {{ form.phone(class="form-control") }}
                            {% if form.phone.errors %}
                                <div class="text-danger">
                                    {% for error in form.phone.errors %}
                                        <small>{{ error }}</small>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                        
                        <div class="mb-3">
                            {{ form.email.label(class="form-label") }}
                            {{ form.email(class="form-control") }}
                            {% if form.email.errors %}
                                <div class="text-danger">
                                    {% for error in form.email.errors %}
                                        <small>{{ error }}</small>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                        
                        <div class="alert alert-info">
                            <i class="fas fa-whatsapp me-2"></i>
                            <strong>WhatsApp Checkout:</strong> After clicking "Finish Order", you will be redirected to WhatsApp to complete your order with our team.
                        </div>
                        
                        <button type="submit" class="btn btn-orange btn-lg w-100">
                            <i class="fas fa-whatsapp me-2"></i>Finish Order via WhatsApp
                        </button>
                    </form>
                </div>
            </div>
        </div>
        
        <div class="col-lg-4">
            <div class="card">
                <div class="card-header bg-orange text-white">
                    <h5 class="mb-0">Order Summary</h5>
                </div>
                <div class="card-body">
                    {% for item in cart_items %}
                    <div class="d-flex justify-content-between mb-2">
                        <div>
                            <small>{{ item.product.name }}</small>
                            <br>
                            <small class="text-muted">Qty: {{ item.quantity }}</small>
                        </div>
                        <span>KES {{ "%.2f"|format(item.get_total_price()) }}</span>
                    </div>
                    {% endfor %}
                    
                    <hr>
                    <div class="d-flex justify-content-between mb-2">
                        <span>Subtotal:</span>
                        <span>KES {{ "%.2f"|format(total) }}</span>
                    </div>
                    <div class="d-flex justify-content-between mb-2">
                        <span>Shipping:</span>
                        <span class="text-success">FREE</span>
                    </div>
                    <hr>
                    <div class="d-flex justify-content-between">
                        <strong>Total:</strong>
                        <strong class="text-orange">KES {{ "%.2f"|format(total) }}</strong>
                    </div>
                </div>
            </div>
            
            <div class="card mt-3">
                <div class="card-body text-center">
                    <i class="fas fa-shield-alt fa-2x text-success mb-2"></i>
                    <h6>Secure Checkout</h6>
                    <small class="text-muted">Your information is safe with us</small>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}


