<?php /** /app/views/admin/configuracoes/index.php */
$c = $config ?? [];
?>

<form action="<?= admin_url('configuracoes/salvar') ?>" method="post" enctype="multipart/form-data">
  <?= csrf_field() ?>

  <div class="card">
    <h3 style="margin-top:0">Identidade da marca</h3>

    <div class="form-row">
      <div class="form-group">
        <label>Nome da marca</label>
        <input type="text" name="marca_nome" class="form-control" value="<?= e($c['marca_nome'] ?? 'OFFICE') ?>">
      </div>
      <div class="form-group">
        <label>Slogan</label>
        <input type="text" name="marca_slogan" class="form-control" value="<?= e($c['marca_slogan'] ?? '') ?>">
      </div>
    </div>

    <div class="form-row">
      <div class="form-group">
        <label>Logotipo</label>
        <?php if (!empty($c['marca_logo'])): ?>
          <div style="margin-bottom:8px"><img src="<?= upload_url($c['marca_logo']) ?>" style="max-height:60px;background:#111;padding:8px"></div>
        <?php endif; ?>
        <input type="file" name="marca_logo" class="form-control" accept="image/*">
      </div>
      <div class="form-group">
        <label>Favicon</label>
        <?php if (!empty($c['marca_favicon'])): ?>
          <div style="margin-bottom:8px"><img src="<?= upload_url($c['marca_favicon']) ?>" style="max-height:32px"></div>
        <?php endif; ?>
        <input type="file" name="marca_favicon" class="form-control" accept="image/*">
      </div>
    </div>

    <div class="form-row-3">
      <div class="form-group">
        <label>Cor primária</label>
        <input type="color" name="cor_primaria" class="form-control" value="<?= e($c['cor_primaria'] ?? '#0A0A0A') ?>">
      </div>
      <div class="form-group">
        <label>Cor secundária (dourado)</label>
        <input type="color" name="cor_secundaria" class="form-control" value="<?= e($c['cor_secundaria'] ?? '#C9A55C') ?>">
      </div>
      <div class="form-group">
        <label>Cor de texto</label>
        <input type="color" name="cor_texto" class="form-control" value="<?= e($c['cor_texto'] ?? '#1A1A1A') ?>">
      </div>
    </div>
  </div>

  <div class="card">
    <h3 style="margin-top:0">Banner principal (Home)</h3>

    <div class="form-group">
      <label>Imagem de banner</label>
      <?php if (!empty($c['banner_principal'])): ?>
        <div style="margin-bottom:8px"><img src="<?= upload_url($c['banner_principal']) ?>" style="max-height:160px"></div>
      <?php endif; ?>
      <input type="file" name="banner_principal" class="form-control" accept="image/*">
    </div>

    <div class="form-row">
      <div class="form-group">
        <label>Título do banner</label>
        <input type="text" name="banner_titulo" class="form-control" value="<?= e($c['banner_titulo'] ?? '') ?>">
      </div>
      <div class="form-group">
        <label>Subtítulo</label>
        <input type="text" name="banner_subtitulo" class="form-control" value="<?= e($c['banner_subtitulo'] ?? '') ?>">
      </div>
    </div>
  </div>

  <div class="card">
    <h3 style="margin-top:0">Textos institucionais</h3>

    <div class="form-group">
      <label>Título da seção "Sobre"</label>
      <input type="text" name="sobre_titulo" class="form-control" value="<?= e($c['sobre_titulo'] ?? '') ?>">
    </div>

    <div class="form-group">
      <label>Texto da seção "Sobre"</label>
      <textarea name="sobre_texto" class="form-control" rows="6"><?= e($c['sobre_texto'] ?? '') ?></textarea>
    </div>
  </div>

  <div class="card">
    <h3 style="margin-top:0">Contatos</h3>

    <div class="form-row-3">
      <div class="form-group">
        <label>E-mail</label>
        <input type="email" name="contato_email" class="form-control" value="<?= e($c['contato_email'] ?? '') ?>">
      </div>
      <div class="form-group">
        <label>Telefone</label>
        <input type="text" name="contato_telefone" class="form-control" value="<?= e($c['contato_telefone'] ?? '') ?>">
      </div>
      <div class="form-group">
        <label>WhatsApp (apenas números, ex: 5544999999999)</label>
        <input type="text" name="contato_whatsapp" class="form-control" value="<?= e($c['contato_whatsapp'] ?? '') ?>">
      </div>
    </div>

    <div class="form-group">
      <label>Endereço</label>
      <textarea name="contato_endereco" class="form-control" rows="2"><?= e($c['contato_endereco'] ?? '') ?></textarea>
    </div>

    <div class="form-row-3">
      <div class="form-group">
        <label>Instagram (URL)</label>
        <input type="url" name="instagram" class="form-control" value="<?= e($c['instagram'] ?? '') ?>">
      </div>
      <div class="form-group">
        <label>Facebook (URL)</label>
        <input type="url" name="facebook" class="form-control" value="<?= e($c['facebook'] ?? '') ?>">
      </div>
      <div class="form-group">
        <label>TikTok (URL)</label>
        <input type="url" name="tiktok" class="form-control" value="<?= e($c['tiktok'] ?? '') ?>">
      </div>
    </div>
  </div>

  <div class="card">
    <h3 style="margin-top:0">E-mail / Notificações</h3>
    <div class="form-row">
      <div class="form-group">
        <label>E-mail remetente</label>
        <input type="email" name="email_remetente" class="form-control" value="<?= e($c['email_remetente'] ?? '') ?>">
      </div>
      <div class="form-group">
        <label>E-mail para receber pedidos</label>
        <input type="email" name="email_notificacao" class="form-control" value="<?= e($c['email_notificacao'] ?? '') ?>">
      </div>
    </div>
  </div>

  <div class="card">
    <h3 style="margin-top:0">SEO (Home)</h3>
    <div class="form-group">
      <label>Meta título</label>
      <input type="text" name="meta_titulo" class="form-control" value="<?= e($c['meta_titulo'] ?? '') ?>">
    </div>
    <div class="form-group">
      <label>Meta descrição</label>
      <textarea name="meta_descricao" class="form-control" rows="2"><?= e($c['meta_descricao'] ?? '') ?></textarea>
    </div>
  </div>

  <div style="text-align:right">
    <button type="submit" class="btn btn-gold" style="padding:14px 40px">Salvar configurações</button>
  </div>
</form>
