<?php
$base = $theme['base'];
$light = $theme['light'];
$soft = $theme['soft'];
?>
<div class="quote-sheet template-elegant print-scope">
    <header class="hero-header" style="background: <?php echo q_e($base); ?>; color: #fff;">
        <div class="brand-block inverse">
            <?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; ?>
                    <?php if (!empty($professional['email_profissional'])): ?><span><?php echo q_e($professional['email_profissional']); ?></span><?php endif; ?>
                </div>
            </div>
        </div>
        <div class="quote-meta hero-meta">
            <div class="quote-tag light-text">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-elegant" style="border-left-color: <?php echo q_e($base); ?>;">
        <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="elegant-summary" style="background: <?php echo q_e($soft); ?>; border-color: <?php echo q_e($light); ?>;">
        <div class="summary-col" style="border-left-color: <?php echo q_e($base); ?>;">
            <h3>Condições de pagamento</h3>
            <?php if (!empty($payment['valor_avista_fmt'])): ?><p><span>À vista</span><strong><?php echo q_e($payment['valor_avista_fmt']); ?></strong></p><?php endif; ?>
            <?php if (!empty($payment['valor_parcelado'])): ?><p><span>Parcelado</span><strong><?php echo q_e($payment['parcelado_legenda'] ?: $payment['valor_parcelado_fmt']); ?></strong></p><?php endif; ?>
            <?php if (!empty($payment['entrada_fechamento_fmt'])): ?><p><span>Entrada</span><strong><?php echo q_e($payment['entrada_fechamento_fmt']); ?></strong></p><?php endif; ?>
            <?php if (!empty($payment['restante_entrega_fmt'])): ?><p><span>Restante</span><strong><?php echo q_e($payment['restante_entrega_fmt']); ?></strong></p><?php endif; ?>
        </div>
        <div class="summary-col" style="border-left-color: <?php echo q_e($base); ?>;">
            <h3>Detalhes finais</h3>
            <p><span>Formas</span><strong><?php echo q_e($payment['formas_legenda']); ?></strong></p>
            <p><span>Garantia</span><strong><?php echo q_e($payment['garantia'] ?? '-'); ?></strong></p>
            <p><span>Validade</span><strong><?php echo q_e($professional['validade_orcamento'] ?? '-'); ?></strong></p>
        </div>
    </section>

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