<?php
$base = $theme['base'];
$light = $theme['light'];
$soft = $theme['soft'];
?>
<div class="quote-sheet template-commercial print-scope">
    <header class="commercial-split-header">
        <div class="left-pane" style="background: <?php echo q_e($base); ?>; color: #fff;">
            <div class="brand-block inverse compact-brand">
                <?php if (!empty($professional['logo_data_uri'])): ?>
                    <div class="logo-shell hero-logo"><img src="<?php echo q_e($professional['logo_data_uri']); ?>" alt="Logo"></div>
                <?php endif; ?>
                <div>
                    <h1 class="company-name"><?php echo q_e($professional['nome_profissional'] ?: 'Nome da Empresa'); ?></h1>
                    <div class="company-meta light-text">
                        <?php if (!empty($professional['telefone_profissional'])): ?><span><?php echo q_e($professional['telefone_profissional']); ?></span><?php endif; ?>
                        <?php if (!empty($professional['cidade_profissional'])): ?><span><?php echo q_e($professional['cidade_profissional']); ?></span><?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="right-pane" style="background: <?php echo q_e($soft); ?>; border-color: <?php echo q_e($light); ?>; color: <?php echo q_e($base); ?>;">
            <div class="quote-tag">ORÇAMENTO</div>
            <div class="hero-number"><?php echo q_e($professional['numero_orcamento'] ?? ''); ?></div>
            <div><?php echo q_e(q_format_date($professional['data_orcamento'] ?? '')); ?></div>
        </div>
    </header>

    <section class="client-card" style="background: <?php echo q_e($soft); ?>; border-color: <?php echo q_e($light); ?>;">
        <div class="section-caption">Dados do cliente</div>
        <div class="client-card-grid">
            <div><strong><?php echo q_e($professional['nome_cliente'] ?: 'Cliente'); ?></strong></div>
            <div><?php echo q_e($professional['endereco_cliente'] ?? ''); ?></div>
            <div><?php echo q_e($professional['telefone_cliente'] ?? ''); ?></div>
            <div><?php echo q_e($professional['cidade_cliente'] ?? ''); ?></div>
        </div>
    </section>

    <?php include __DIR__ . '/table_shared.php'; ?>

    <section class="commercial-total" style="background: <?php echo q_e($base); ?>; color:#fff;">
        <span>Total Geral</span>
        <strong><?php echo q_money((float) $total); ?></strong>
    </section>

    <section class="payment-card" style="background: <?php echo q_e($soft); ?>; border-color: <?php echo q_e($light); ?>;">
        <h3>Condições de pagamento</h3>
        <div class="payment-grid compact">
            <?php if (!empty($payment['valor_avista_fmt'])): ?><div><span>À vista</span><strong><?php echo q_e($payment['valor_avista_fmt']); ?></strong></div><?php endif; ?>
            <?php if (!empty($payment['valor_parcelado'])): ?><div><span>Parcelado</span><strong><?php echo q_e($payment['parcelado_legenda'] ?: $payment['valor_parcelado_fmt']); ?></strong></div><?php endif; ?>
            <?php if (!empty($payment['entrada_fechamento_fmt'])): ?><div><span>Entrada</span><strong><?php echo q_e($payment['entrada_fechamento_fmt']); ?></strong></div><?php endif; ?>
            <?php if (!empty($payment['restante_entrega_fmt'])): ?><div><span>Restante</span><strong><?php echo q_e($payment['restante_entrega_fmt']); ?></strong></div><?php endif; ?>
            <div><span>Formas</span><strong><?php echo q_e($payment['formas_legenda']); ?></strong></div>
            <div><span>Garantia</span><strong><?php echo q_e($payment['garantia'] ?? '-'); ?></strong></div>
        </div>
    </section>

    <?php if (!empty($payment['observacoes'])): ?>
        <section class="notes-box">
            <h4>Observações</h4>
            <p><?php echo nl2br(q_e($payment['observacoes'])); ?></p>
        </section>
    <?php endif; ?>

    <footer class="quote-footer clean-footer">
        <div>Validade: <?php echo q_e($professional['validade_orcamento'] ?? '-'); ?></div>
        <div>Garantia: <?php echo q_e($payment['garantia'] ?? '-'); ?></div>
    </footer>
</div>
