<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Invoice {{ $invoice->invoice_number }}</title>
    <style>
        @page {
            margin: 20mm;
        }
        body {
            font-family: 'DejaVu Sans', sans-serif;
            font-size: 12px;
            color: #333;
            line-height: 1.6;
        }
        .header {
            margin-bottom: 30px;
        }
        .company-info {
            margin-bottom: 20px;
        }
        .invoice-info {
            text-align: right;
        }
        .invoice-details {
            margin: 30px 0;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
        }
        th, td {
            padding: 10px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f5f5f5;
            font-weight: bold;
        }
        .text-right {
            text-align: right;
        }
        .total-section {
            margin-top: 20px;
            text-align: right;
        }
        .total-row {
            font-weight: bold;
            font-size: 14px;
        }
        .watermark {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) rotate(-45deg);
            font-size: 72px;
            color: rgba(255, 0, 0, 0.1);
            z-index: 1000;
            pointer-events: none;
            font-weight: bold;
        }
        .footer {
            margin-top: 50px;
            padding-top: 20px;
            border-top: 1px solid #ddd;
            font-size: 10px;
            color: #666;
        }
    </style>
</head>
<body style="background-color: rgba(0, 0, 0, 1) !important;">
    @if($showWatermark)
        <div class="watermark">UNLICENSED</div>
    @endif

    <div class="header">
        <div class="company-info">
            <h1>{{ config('app.name', 'ProInvoice') }}</h1>
            <p>Invoice</p>
        </div>
        <div class="invoice-info">
            <h2>Invoice #{{ $invoice->invoice_number }}</h2>
            <p>Issue Date: {{ $invoice->issue_date->format('M d, Y') }}</p>
            <p>Due Date: {{ $invoice->due_date->format('M d, Y') }}</p>
        </div>
    </div>

    <div class="invoice-details">
        <div style="width: 50%; float: left;">
            <h3>Bill To:</h3>
            <p><strong>{{ $invoice->customer->name }}</strong></p>
            @if($invoice->customer->company)
                <p>{{ $invoice->customer->company }}</p>
            @endif
            @if($invoice->customer->address)
                <p>{{ $invoice->customer->address }}</p>
            @endif
            @if($invoice->customer->city || $invoice->customer->state || $invoice->customer->zip)
                <p>
                    {{ $invoice->customer->city }}{{ $invoice->customer->city && ($invoice->customer->state || $invoice->customer->zip) ? ', ' : '' }}
                    {{ $invoice->customer->state }} {{ $invoice->customer->zip }}
                </p>
            @endif
        </div>
        <div style="clear: both;"></div>
    </div>

    <table>
        <thead>
            <tr>
                <th>Description</th>
                <th class="text-right">Quantity</th>
                <th class="text-right">Unit Price</th>
                <th class="text-right">Tax</th>
                <th class="text-right">Total</th>
            </tr>
        </thead>
        <tbody>
            @foreach($invoice->items as $item)
                <tr>
                    <td>{{ $item->description }}</td>
                    <td class="text-right">{{ number_format($item->quantity, 2) }}</td>
                    <td class="text-right">{{ number_format($item->unit_price, 2) }} {{ $invoice->currency }}</td>
                    <td class="text-right">{{ number_format($item->tax_rate, 2) }}%</td>
                    <td class="text-right">{{ number_format($item->total, 2) }} {{ $invoice->currency }}</td>
                </tr>
            @endforeach
        </tbody>
    </table>

    <div class="total-section">
        <table style="width: 300px; margin-left: auto;">
            <tr>
                <td>Subtotal:</td>
                <td class="text-right">{{ number_format($invoice->subtotal, 2) }} {{ $invoice->currency }}</td>
            </tr>
            <tr>
                <td>Tax:</td>
                <td class="text-right">{{ number_format($invoice->tax_amount, 2) }} {{ $invoice->currency }}</td>
            </tr>
            @if($invoice->discount_amount > 0)
                <tr>
                    <td>Discount:</td>
                    <td class="text-right">-{{ number_format($invoice->discount_amount, 2) }} {{ $invoice->currency }}</td>
                </tr>
            @endif
            <tr class="total-row">
                <td>Total:</td>
                <td class="text-right">{{ number_format($invoice->total, 2) }} {{ $invoice->currency }}</td>
            </tr>
            <tr>
                <td>Paid:</td>
                <td class="text-right">{{ number_format($invoice->paid_amount, 2) }} {{ $invoice->currency }}</td>
            </tr>
            <tr class="total-row">
                <td>Balance:</td>
                <td class="text-right">{{ number_format($invoice->balance, 2) }} {{ $invoice->currency }}</td>
            </tr>
        </table>
    </div>

    @if($invoice->notes)
        <div style="margin-top: 30px;">
            <h3>Notes:</h3>
            <p>{{ $invoice->notes }}</p>
        </div>
    @endif

    @if($invoice->terms)
        <div style="margin-top: 20px;">
            <h3>Terms & Conditions:</h3>
            <p>{{ $invoice->terms }}</p>
        </div>
    @endif

    <div class="footer">
        <p>Thank you for your business!</p>
    </div>
</body>
</html>






