<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
  * { box-sizing: border-box; }
  body { font-family: DejaVu Sans, sans-serif; color: #1a1a1a; font-size: 12px; margin: 0; padding: 0; }
  .wrap { padding: 34px 40px; }
  .brand { font-size: 26px; font-weight: bold; color: #ff6b1a; letter-spacing: 1px; }
  .brand-sub { color: #777; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; margin-top: 2px; }
  .muted { color: #777; }
  .right { text-align: right; }
  .h-table { width: 100%; border-collapse: collapse; margin-bottom: 26px; }
  .h-table td { vertical-align: top; }
  .doc-title { font-size: 22px; font-weight: bold; color: #111; letter-spacing: 1px; }
  .pill { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 10px; font-weight: bold; }
  .pill-paid { background: #e6f9f2; color: #06a877; }
  .pill-cod { background: #fff2e6; color: #ff6b1a; }
  .box { border: 1px solid #eee; border-radius: 8px; padding: 14px 16px; }
  .label { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: #999; margin-bottom: 5px; }
  table.items { width: 100%; border-collapse: collapse; margin-top: 8px; }
  table.items th { background: #111; color: #fff; text-align: left; padding: 9px 12px; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
  table.items th.num, table.items td.num { text-align: right; }
  table.items td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }
  .totals { width: 46%; margin-left: 54%; margin-top: 14px; border-collapse: collapse; }
  .totals td { padding: 6px 4px; }
  .totals .num { text-align: right; }
  .totals .grand td { border-top: 2px solid #111; font-size: 15px; font-weight: bold; padding-top: 10px; }
  .discount td { color: #06a877; }
  .footer { margin-top: 34px; border-top: 1px solid #eee; padding-top: 16px; color: #888; font-size: 10px; line-height: 1.7; }
  .thanks { margin-top: 26px; padding: 16px; background: #fff8f3; border: 1px solid #ffe3cc; border-radius: 8px; color: #b35400; font-size: 12px; }
</style>
</head>
<body>
<div class="wrap">

  <table class="h-table">
    <tr>
      <td style="width:55%">
        <div class="brand">GOD'S TREAT</div>
        <div class="brand-sub">By Dreemoh &mdash; Premium Makhana</div>
        <div class="muted" style="margin-top:10px;line-height:1.6">
          {{ config('mail.from.address', 'orders@godstreat.in') }}<br>
          {{ config('app.url') }}
        </div>
      </td>
      <td class="right" style="width:45%">
        <div class="doc-title">INVOICE</div>
        <div class="muted" style="margin-top:8px">
          <strong>{{ $order->order_number }}</strong><br>
          {{ optional($order->created_at)->format('d M Y, h:i A') }}
        </div>
        <div style="margin-top:10px">
          @if($order->payment_method === 'cod')
            <span class="pill pill-cod">COD &mdash; Pay on Delivery</span>
          @else
            <span class="pill pill-paid">PAID ONLINE</span>
          @endif
        </div>
      </td>
    </tr>
  </table>

  <table class="h-table">
    <tr>
      <td style="width:50%;padding-right:10px">
        <div class="box">
          <div class="label">Billed &amp; Shipped To</div>
          <strong>{{ $order->name }}</strong><br>
          {{ $order->address }}<br>
          {{ $order->city }} &mdash; {{ $order->pincode }}<br>
          {{ $order->phone }}<br>
          {{ $order->email }}
        </div>
      </td>
      <td style="width:50%;padding-left:10px">
        <div class="box">
          <div class="label">Order Details</div>
          Order No: <strong>{{ $order->order_number }}</strong><br>
          Status: {{ $order->status_label }}<br>
          Payment: {{ $order->payment_label }}<br>
          @if($order->payment_id)Txn: {{ $order->payment_id }}<br>@endif
          Est. Delivery: {{ $order->estimated_delivery }}
        </div>
      </td>
    </tr>
  </table>

  <table class="items">
    <thead>
      <tr>
        <th>Item</th>
        <th class="num">Price</th>
        <th class="num">Qty</th>
        <th class="num">Amount</th>
      </tr>
    </thead>
    <tbody>
      @foreach($order->items as $item)
      <tr>
        <td>{{ $item->name }}</td>
        <td class="num">&#8377;{{ number_format($item->price) }}</td>
        <td class="num">{{ $item->qty }}</td>
        <td class="num">&#8377;{{ number_format($item->price * $item->qty) }}</td>
      </tr>
      @endforeach
    </tbody>
  </table>

  <table class="totals">
    <tr>
      <td class="muted">Subtotal</td>
      <td class="num">&#8377;{{ number_format($order->subtotal) }}</td>
    </tr>
    @if($order->discount > 0)
    <tr class="discount">
      <td>Discount @if($order->coupon_code)({{ $order->coupon_code }})@endif</td>
      <td class="num">&minus;&#8377;{{ number_format($order->discount) }}</td>
    </tr>
    @endif
    <tr>
      <td class="muted">Delivery</td>
      <td class="num">{{ $order->shipping_cost > 0 ? '₹'.number_format($order->shipping_cost) : 'FREE' }}</td>
    </tr>
    <tr class="grand">
      <td>Total</td>
      <td class="num">&#8377;{{ number_format($order->total) }}</td>
    </tr>
  </table>

  <div class="thanks">
    Thank you for snacking smarter with God's Treat! Every pack is hand-picked, air-dried and sealed fresh &mdash; just for you. 🌾
  </div>

  <div class="footer">
    This is a computer-generated invoice and does not require a physical signature.<br>
    Prices are inclusive of all applicable taxes. For any queries about this order, reply to
    {{ config('mail.from.address', 'orders@godstreat.in') }} quoting your order number {{ $order->order_number }}.<br>
    <strong>God's Treat by Dreemoh</strong> &mdash; From Tradition to Nutrition.
  </div>

</div>
</body>
</html>
