<?php
/**
 * Classic — traditional, restrained, black on white. Table-based with inline
 * styles (dompdf's CSS subset). Renders in $data['font']; shared body comes from
 * _content.php. Every value is escaped in the partials and here.
 *
 * @var array<string, mixed> $data
 */

if (!defined('ABSPATH')) {
    exit;
}

// Template partial included in a render method; its locals are not globals.
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
    body { font-family: <?php echo esc_attr($data['font']); ?>; font-size: 12px; color: #1f2937; }
    .head { width: 100%; } .head td { vertical-align: top; }
    .logo img { max-height: 64px; }
    h1 { font-size: 22px; margin: 0 0 4px; color: #111827; }
    .muted { color: #6b7280; }
    .seller { text-align: right; font-size: 11px; }
    .meta { width: 100%; margin: 24px 0; } .meta td { vertical-align: top; width: 50%; font-size: 11px; }
    .label { text-transform: uppercase; font-size: 10px; letter-spacing: .04em; color: #6b7280; margin-bottom: 4px; }
    table.items { width: 100%; border-collapse: collapse; margin-top: 12px; }
    table.items th { text-align: left; border-bottom: 2px solid #111827; padding: 8px 6px; font-size: 11px; }
    table.items td { padding: 8px 6px; border-bottom: 1px solid #e5e7eb; }
    .right { text-align: right; }
    table.totals { width: 40%; margin-left: 60%; margin-top: 12px; border-collapse: collapse; }
    table.totals td { padding: 6px; }
    table.totals tr:last-child td { border-top: 2px solid #111827; font-weight: bold; }
    .foot { margin-top: 40px; font-size: 10px; color: #6b7280; border-top: 1px solid #e5e7eb; padding-top: 10px; }
</style>
</head>
<body>
    <?php require $data['partials'] . '/_watermark.php'; ?>

    <table class="head">
        <tr>
            <td>
                <?php if (!empty($data['logo'])) : ?>
                    <div class="logo"><img src="<?php echo esc_attr($data['logo']); ?>" alt=""></div>
                <?php else : ?>
                    <h1><?php echo esc_html($data['seller']['name']); ?></h1>
                <?php endif; ?>
            </td>
            <td class="seller">
                <strong><?php echo esc_html($data['seller']['name']); ?></strong><br>
                <?php echo nl2br(esc_html($data['seller']['address'])); ?><br>
                <?php if ($data['seller']['vat'] !== '') : ?><?php echo esc_html__('VAT', 'softminal-b2b-wholesale-for-woocommerce') . ': ' . esc_html($data['seller']['vat']); ?><br><?php endif; ?>
                <?php echo esc_html($data['seller']['email']); ?>
            </td>
        </tr>
    </table>

    <h1><?php echo esc_html($data['doc_title']); ?> #<?php echo esc_html($data['invoice_no']); ?></h1>
    <span class="muted"><?php echo esc_html($data['date']); ?><?php if (!empty($data['po_number'])) : ?> &middot; <?php echo esc_html__('PO', 'softminal-b2b-wholesale-for-woocommerce') . ': ' . esc_html($data['po_number']); ?><?php endif; ?></span>

    <?php require $data['partials'] . '/_content.php'; ?>
</body>
</html>
