<?php
/**
 * Layout público - /app/views/layouts/public.php
 */
$marca = $config ?? config_marca();
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= e($pageTitle ?? ($marca['marca_nome'] ?? 'OFFICE')) ?></title>
<meta name="description" content="<?= e($marca['meta_descricao'] ?? '') ?>">
<?php if (!empty($marca['marca_favicon'])): ?>
<link rel="icon" href="<?= upload_url($marca['marca_favicon']) ?>">
<?php endif; ?>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="<?= url('assets/css/app.css') ?>">
<style>
  :root {
    --color-primary: <?= e($marca['cor_primaria'] ?? '#0A0A0A') ?>;
    --color-secondary: <?= e($marca['cor_secundaria'] ?? '#C9A55C') ?>;
    --color-gold: <?= e($marca['cor_secundaria'] ?? '#C9A55C') ?>;
    --color-text: <?= e($marca['cor_texto'] ?? '#1A1A1A') ?>;
  }
</style>
</head>
<body>

<header class="site-header">
  <div class="container site-header__inner">
    <a href="<?= url() ?>" class="brand">
      <?php if (!empty($marca['marca_logo'])): ?>
        <img src="<?= upload_url($marca['marca_logo']) ?>" alt="<?= e($marca['marca_nome'] ?? 'OFFICE') ?>">
      <?php else: ?>
        <?= e($marca['marca_nome'] ?? 'OFFICE') ?>
      <?php endif; ?>
    </a>

    <button class="nav-toggle" aria-label="Menu">☰</button>

    <nav class="nav">
      <a href="<?= url() ?>" class="<?= is_active('/home') ?>">Home</a>
      <a href="<?= url('catalogo') ?>" class="<?= is_active('catalogo') ?>">Catálogo</a>
      <a href="<?= url('sobre') ?>" class="<?= is_active('sobre') ?>">Sobre</a>
      <a href="<?= url('contato') ?>" class="<?= is_active('contato') ?>">Contato</a>
      <a href="<?= url('carrinho') ?>" class="nav-cart">
        Meu Pedido
        <?php $c = cart_count(); if ($c): ?><span class="badge"><?= $c ?></span><?php endif; ?>
      </a>
    </nav>
  </div>
</header>

<main>
  <?php if (has_flash('success')): ?>
    <div class="container" style="padding-top:20px"><div class="flash success"><?= e(flash('success')) ?></div></div>
  <?php endif; ?>
  <?php if (has_flash('error')): ?>
    <div class="container" style="padding-top:20px"><div class="flash error"><?= e(flash('error')) ?></div></div>
  <?php endif; ?>

  <?= $content ?>
</main>

<footer class="site-footer">
  <div class="container">
    <div class="site-footer__grid">
      <div>
        <h4><?= e($marca['marca_nome'] ?? 'OFFICE') ?></h4>
        <p style="max-width:360px;font-size:.92rem;line-height:1.7">
          <?= e($marca['marca_slogan'] ?? 'Elegância em cada olhar.') ?>
        </p>
      </div>
      <div>
        <h4>Navegação</h4>
        <ul>
          <li><a href="<?= url('catalogo') ?>">Catálogo</a></li>
          <li><a href="<?= url('sobre') ?>">Sobre</a></li>
          <li><a href="<?= url('contato') ?>">Contato</a></li>
        </ul>
      </div>
      <div>
        <h4>Contato</h4>
        <ul>
          <?php if (!empty($marca['contato_email'])): ?><li><a href="mailto:<?= e($marca['contato_email']) ?>"><?= e($marca['contato_email']) ?></a></li><?php endif; ?>
          <?php if (!empty($marca['contato_telefone'])): ?><li><?= e($marca['contato_telefone']) ?></li><?php endif; ?>
          <?php if (!empty($marca['contato_whatsapp'])): ?><li><a href="<?= e(whatsapp_link($marca['contato_whatsapp'])) ?>" target="_blank">WhatsApp</a></li><?php endif; ?>
        </ul>
      </div>
      <div>
        <h4>Social</h4>
        <ul>
          <?php if (!empty($marca['instagram'])): ?><li><a href="<?= e($marca['instagram']) ?>" target="_blank">Instagram</a></li><?php endif; ?>
          <?php if (!empty($marca['facebook'])): ?><li><a href="<?= e($marca['facebook']) ?>" target="_blank">Facebook</a></li><?php endif; ?>
          <?php if (!empty($marca['tiktok'])): ?><li><a href="<?= e($marca['tiktok']) ?>" target="_blank">TikTok</a></li><?php endif; ?>
        </ul>
      </div>
    </div>
    <div class="site-footer__bottom">
      <span>© <?= date('Y') ?> <?= e($marca['marca_nome'] ?? 'OFFICE') ?>. Todos os direitos reservados.</span>
      <span>Catálogo premium</span>
    </div>
  </div>
</footer>

<script src="<?= url('assets/js/app.js') ?>"></script>
</body>
</html>
