<?php
/**
 * Letterhead — a formal, centred masthead with an accent rule. Shared body from
 * _content.php.
 *
 * @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

$accent = '#b45309';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
    body { font-family: <?php echo esc_attr($data['font']); ?>; font-size: 12px; color: #292524; }
    .mast { text-align: center; border-bottom: 3px solid <?php echo esc_attr($accent); ?>; padding-bottom: 16px; margin-bottom: 6px; }
    .mast .logo img { max-height: 56px; margin-bottom: 6px; }
    .mast .name { font-size: 20px; font-weight: bold; color: <?php echo esc_attr($accent); ?>; letter-spacing: .02em; }
    .mast .contact { font-size: 10.5px; color: #78716c; margin-top: 4px; }
    .docline { text-align: center; margin: 16px 0 4px; font-size: 15px; letter-spacing: .18em; text-transform: uppercase; color: #44403c; }
    .docsub { text-align: center; font-size: 11px; color: #78716c; margin-bottom: 8px; }
    .meta { width: 100%; margin: 18px 0 20px; } .meta td { vertical-align: top; width: 50%; font-size: 11px; }
    .label { text-transform: uppercase; font-size: 9px; letter-spacing: .1em; color: <?php echo esc_attr($accent); ?>; margin-bottom: 4px; }
    table.items { width: 100%; border-collapse: collapse; }
    table.items th { text-align: left; border-bottom: 2px solid <?php echo esc_attr($accent); ?>; padding: 8px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
    table.items td { padding: 8px 6px; border-bottom: 1px solid #e7e5e4; }
    .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 <?php echo esc_attr($accent); ?>; font-weight: bold; }
    .foot { margin-top: 40px; font-size: 10px; color: #78716c; text-align: center; border-top: 1px solid #e7e5e4; padding-top: 10px; }
</style>
</head>
<body>
    <?php require $data['partials'] . '/_watermark.php'; ?>

    <div class="mast">
        <?php if (!empty($data['logo'])) : ?>
            <div class="logo"><img src="<?php echo esc_attr($data['logo']); ?>" alt=""></div>
        <?php endif; ?>
        <div class="name"><?php echo esc_html($data['seller']['name']); ?></div>
        <div class="contact">
            <?php echo esc_html(str_replace("\n", ' · ', $data['seller']['address'])); ?>
            <?php if ($data['seller']['email'] !== '') : ?> · <?php echo esc_html($data['seller']['email']); ?><?php endif; ?>
            <?php if ($data['seller']['vat'] !== '') : ?> · <?php echo esc_html__('VAT', 'softminal-b2b-wholesale-for-woocommerce') . ' ' . esc_html($data['seller']['vat']); ?><?php endif; ?>
        </div>
    </div>

    <div class="docline"><?php echo esc_html($data['doc_title']); ?></div>
    <div class="docsub">#<?php echo esc_html($data['invoice_no']); ?> &middot; <?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; ?></div>

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