{% extends "core/base.html" %}
{% block title %}{% if mode == 'create' %}Add Customer{% else %}Edit Customer{% endif %} — SwiftPOS{% endblock %}

{% block content %}
<div class="container-fluid px-4 py-4">
  <div class="row justify-content-center">
    <div class="col-md-7">
      <div class="card border-0 shadow-sm" style="border-radius:20px;overflow:hidden;">
        <div class="card-header border-0 pb-0 px-4 pt-4" style="background:linear-gradient(135deg,#667eea,#764ba2);">
          <h4 class="text-white fw-bold mb-1">
            <i class="fas fa-user-plus me-2"></i>
            {% if mode == 'create' %}Add New Customer{% else %}Edit Customer{% endif %}
          </h4>
          <p class="text-white opacity-75 small mb-3">Fill in the customer details below</p>
        </div>

        <div class="card-body p-4">
          <form method="post">
            {% csrf_token %}
            <div class="mb-3">
              <label class="form-label fw-semibold">Full Name <span class="text-danger">*</span></label>
              <input type="text" name="name" class="form-control" required
                     value="{% if mode == 'edit' %}{{ customer.name }}{% endif %}"
                     placeholder="Customer's full name">
            </div>
            <div class="row g-3 mb-3">
              <div class="col-md-6">
                <label class="form-label fw-semibold">Phone</label>
                <input type="tel" name="phone" class="form-control"
                       value="{% if mode == 'edit' %}{{ customer.phone }}{% endif %}"
                       placeholder="+234...">
              </div>
              <div class="col-md-6">
                <label class="form-label fw-semibold">Email</label>
                <input type="email" name="email" class="form-control"
                       value="{% if mode == 'edit' %}{{ customer.email }}{% endif %}"
                       placeholder="customer@email.com">
              </div>
            </div>
            <div class="mb-3">
              <label class="form-label fw-semibold">Address</label>
              <textarea name="address" class="form-control" rows="2"
                        placeholder="Delivery or home address">{% if mode == 'edit' %}{{ customer.address }}{% endif %}</textarea>
            </div>
            <div class="mb-4">
              <label class="form-label fw-semibold">Notes</label>
              <textarea name="notes" class="form-control" rows="2"
                        placeholder="Any special notes...">{% if mode == 'edit' %}{{ customer.notes }}{% endif %}</textarea>
            </div>

            <div class="d-flex gap-3">
              <button type="submit" class="btn btn-primary fw-bold flex-fill" style="border-radius:12px;padding:12px;">
                <i class="fas fa-save me-2"></i>
                {% if mode == 'create' %}Save Customer{% else %}Update Customer{% endif %}
              </button>
              <a href="{% url 'sales:customer_list' %}" class="btn btn-outline-secondary flex-fill" style="border-radius:12px;padding:12px;">
                Cancel
              </a>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}
