<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Debit Note {{ $debitNote->number }}</title>
    <style>
        body {
            font-family: 'Helvetica', Arial, sans-serif;
            font-size: 12px;
            color: #333;
            margin: 40px;
        }
        .company-name {
            font-size: 24px;
            font-weight: bold;
            color: #1d4ed8;
        }
        .document-title {
            font-size: 28px;
            font-weight: bold;
            text-align: right;
            color: #ea5455;
        }
        .document-meta {
            text-align: right;
            margin-top: 8px;
        }
        .meta-label {
            color: #666;
        }
        .address-label {
            font-weight: bold;
            font-size: 11px;
            text-transform: uppercase;
            color: #666;
            margin-bottom: 5px;
        }
        .amount-box {
            background-color: #fff5f5;
            border: 2px solid #ea5455;
            border-radius: 8px;
            padding: 20px;
            text-align: center;
            margin: 30px 0;
        }
        .amount-box .label {
            font-size: 14px;
            color: #666;
            margin-bottom: 5px;
        }
        .amount-box .amount {
            font-size: 32px;
            font-weight: bold;
            color: #ea5455;
        }
        .reason-box {
            background-color: #f9f9f9;
            border: 1px solid #eee;
            border-radius: 4px;
            padding: 15px;
            margin: 20px 0;
        }
        .reason-box .label {
            font-weight: bold;
            font-size: 11px;
            text-transform: uppercase;
            color: #666;
            margin-bottom: 5px;
        }
        .status-badge {
            display: inline-block;
            padding: 4px 12px;
            border-radius: 4px;
            font-size: 11px;
            font-weight: bold;
            text-transform: uppercase;
            color: white;
        }
        .status-issued {
            background-color: #ff9f43;
        }
        .status-draft {
            background-color: #82868b;
        }
        .status-voided {
            background-color: #ea5455;
        }
        .details-table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
        }
        .details-table td {
            padding: 8px 12px;
            border-bottom: 1px solid #eee;
        }
        .details-table td:first-child {
            color: #666;
            width: 40%;
        }
        .details-table td:last-child {
            font-weight: 500;
        }
        .footer {
            margin-top: 40px;
            text-align: center;
            font-size: 10px;
            color: #999;
            border-top: 1px solid #eee;
            padding-top: 15px;
        }
    </style>
</head>
<body>
    {{-- Header --}}
    <table width="100%" style="margin-bottom: 30px;">
        <tr>
            <td width="50%" style="vertical-align: top;">
                <div class="company-name">EZSCALE</div>
                <div style="margin-top: 5px; color: #666;">Cloud Infrastructure Services</div>
            </td>
            <td width="50%" style="vertical-align: top; text-align: right;">
                <div class="document-title">DEBIT NOTE</div>
                <div class="document-meta">
                    <div><span class="meta-label">Debit Note #:</span> {{ $debitNote->number }}</div>
                    <div><span class="meta-label">Date:</span> {{ $debitNote->issued_at ? $debitNote->issued_at->format('M d, Y') : $debitNote->created_at->format('M d, Y') }}</div>
                    <div style="margin-top: 5px;">
                        <span class="status-badge status-{{ strtolower($debitNote->status) }}">{{ ucfirst($debitNote->status) }}</span>
                    </div>
                </div>
            </td>
        </tr>
    </table>

    {{-- Customer Info --}}
    <table width="100%" style="margin-bottom: 30px;">
        <tr>
            <td width="50%" style="vertical-align: top;">
                <div class="address-label">Issued To</div>
                <div><strong>{{ $debitNote->user->name }}</strong></div>
                <div>{{ $debitNote->user->email }}</div>
                @if($debitNote->user->company)<div>{{ $debitNote->user->company }}</div>@endif
                @if($debitNote->user->phone)<div>{{ $debitNote->user->phone }}</div>@endif
            </td>
            <td width="50%" style="vertical-align: top;">
                <div class="address-label">From</div>
                <div><strong>EZSCALE</strong></div>
                <div>support@ezscale.cloud</div>
            </td>
        </tr>
    </table>

    {{-- Amount --}}
    <div class="amount-box">
        <div class="label">Debit Amount</div>
        <div class="amount">${{ number_format((float) $debitNote->amount, 2) }} {{ $debitNote->currency }}</div>
    </div>

    {{-- Details --}}
    <table class="details-table">
        <tr>
            <td>Debit Note Number</td>
            <td>{{ $debitNote->number }}</td>
        </tr>
        <tr>
            <td>Amount</td>
            <td>${{ number_format((float) $debitNote->amount, 2) }}</td>
        </tr>
        <tr>
            <td>Currency</td>
            <td>{{ $debitNote->currency }}</td>
        </tr>
        <tr>
            <td>Reason Type</td>
            <td>{{ str_replace('_', ' ', ucfirst($debitNote->reason_type)) }}</td>
        </tr>
        <tr>
            <td>Status</td>
            <td>{{ ucfirst($debitNote->status) }}</td>
        </tr>
        @if($debitNote->invoice)
            <tr>
                <td>Related Invoice</td>
                <td>{{ $debitNote->invoice->number }}</td>
            </tr>
        @endif
        <tr>
            <td>Issue Date</td>
            <td>{{ $debitNote->issued_at ? $debitNote->issued_at->format('M d, Y') : 'N/A' }}</td>
        </tr>
    </table>

    {{-- Reason --}}
    @if($debitNote->reason)
        <div class="reason-box">
            <div class="label">Reason</div>
            <div>{{ $debitNote->reason }}</div>
        </div>
    @endif

    {{-- Footer --}}
    <div class="footer">
        <p>This amount has been debited from your account balance.</p>
        <p>EZSCALE &mdash; Cloud Infrastructure Services &mdash; support@ezscale.cloud</p>
    </div>
</body>
</html>
