<?php
$base = $theme['base'];
$light = $theme['light'];
$soft = $theme['soft'];
?>
<div class="quote-sheet template-clean print-scope">
    <div class="quote-top-line" style="background: <?php echo q_e($base); ?>;"></div>

    <header class="quote-header clean-layout">
        <div class="brand-block">
            <?php if (!empty($professional['logo_data_uri'])): ?>
                <div class="logo-shell clean-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">
                    <?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; ?>
                    <?php if (!empty($professional['email_profissional'])): ?><span><?php echo q_e($professional['email_profissional']); ?></span><?php endif; ?>
                </div>
            </div>
        </div>
        <div class="quote-meta clean-meta">
            <div class="quote-tag" style="color: <?php echo q_e($base); ?>;">ORÇAMENTO</div>
            <div><strong>Nº</strong> <?php echo q_e($professional['numero_orcamento'] ?? ''); ?></div>
            <div><strong>Data</strong> <?php echo q_e(q_format_date($professional['data_orcamento'] ?? '')); ?></div>
        </div>
    </header>

    <section class="client-simple-block">
        <div class="section-caption">Dados do cliente</div>
        <div class="client-name"><?php echo q_e($professional['nome_cliente'] ?: 'Cliente'); ?></div>
        <div class="client-lines">
            <?php if (!empty($professional['telefone_cliente'])): ?><span><?php echo q_e($professional['telefone_cliente']); ?></span><?php endif; ?>
            <?php if (!empty($professional['endereco_cliente'])): ?><span><?php echo q_e($professional['endereco_cliente']); ?></span><?php endif; ?>
            <?php if (!empty($professional['cidade_cliente'])): ?><span><?php echo q_e($professional['cidade_cliente']); ?></span><?php endif; ?>
        </div>
        <?php if (!empty($professional['observacoes_cliente'])): ?>
            <p class="mini-note"><?php echo nl2br(q_e($professional['observacoes_cliente'])); ?></p>
        <?php endif; ?>
    </section>

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

    <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>
        <div class="meta-footer-line">
            <span><strong>Formas:</strong> <?php echo q_e($payment['formas_legenda']); ?></span>
        </div>
    </section>

    <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>

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