import os
import zipfile

# Caminho base
base_path = "/mnt/data/tarefaspay"
os.makedirs(f"{base_path}/assets/css", exist_ok=True)
os.makedirs(f"{base_path}/assets/js", exist_ok=True)

# Conteúdos dos arquivos
files = {
    "style.css": """/*
Theme Name: TarefasPay
Theme URI: https://zenngi.com/
Author: Edvan Castro
Description: Tema WordPress para site de tarefas e recompensas em dinheiro.
Version: 1.0
License: GPLv2 or later
Text Domain: tarefaspay
*/""",

    "functions.php": """<?php
function tarefaspay_scripts() {
    wp_enqueue_style('tarefaspay-style', get_stylesheet_uri());
    wp_enqueue_style('tarefaspay-main', get_template_directory_uri() . '/assets/css/main.css');
    wp_enqueue_script('tarefaspay-main', get_template_directory_uri() . '/assets/js/main.js', array('jquery'), null, true);
}
add_action('wp_enqueue_scripts', 'tarefaspay_scripts');

function tarefaspay_setup() {
    add_theme_support('title-tag');
    add_theme_support('post-thumbnails');
    register_nav_menus(array(
        'menu-principal' => __('Menu Principal', 'tarefaspay')
    ));
}
add_action('after_setup_theme', 'tarefaspay_setup');
?>""",

    "index.php": """<?php get_header(); ?>
<main class="home">
  <section class="hero">
    <h1>💸 Ganhe dinheiro completando tarefas!</h1>
    <p>Assista vídeos, siga no Instagram, curta no YouTube e receba por isso.</p>
    <a href="<?php echo site_url('/tarefas'); ?>" class="btn">Ver Tarefas</a>
  </section>

  <section class="vantagens">
    <h2>Por que usar o TarefasPay?</h2>
    <div class="cards">
      <div class="card">
        <h3>💰 Pagamentos Rápidos</h3>
        <p>Receba via Pix após completar suas tarefas.</p>
      </div>
      <div class="card">
        <h3>📱 Fácil de Usar</h3>
        <p>Interface simples, intuitiva e totalmente responsiva.</p>
      </div>
      <div class="card">
        <h3>🎯 Tarefas Diárias</h3>
        <p>Novas oportunidades todos os dias.</p>
      </div>
    </div>
  </section>
</main>
<?php get_footer(); ?>""",

    "header.php": """<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
  <meta charset="<?php bloginfo('charset'); ?>">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
  <header class="header">
    <div class="container">
      <a href="<?php echo home_url(); ?>" class="logo">💸 <strong>TarefasPay</strong></a>
      <nav class="menu">
        <?php wp_nav_menu(array('theme_location' => 'menu-principal')); ?>
      </nav>
    </div>
  </header>""",

    "footer.php": """<footer class="footer">
  <div class="container">
    <p>© <?php echo date('Y'); ?> TarefasPay — Ganhe dinheiro online com tarefas simples.</p>
  </div>
</footer>
<?php wp_footer(); ?>
</body>
</html>""",

    "page-tarefas.php": """<?php
/* Template Name: Tarefas */
get_header(); ?>
<main class="tarefas">
  <h2>Tarefas Disponíveis</h2>
  <div class="lista-tarefas">
    <div class="tarefa">
      <h3>📸 Seguir no Instagram</h3>
      <p>Ganhe R$0,50 por seguir contas específicas.</p>
      <button class="btn">Completar</button>
    </div>
    <div class="tarefa">
      <h3>▶️ Assistir vídeo no YouTube</h3>
      <p>Ganhe R$0,25 por vídeo assistido.</p>
      <button class="btn">Completar</button>
    </div>
    <div class="tarefa">
      <h3>📲 Baixar aplicativo</h3>
      <p>Ganhe R$1,00 por download completo.</p>
      <button class="btn">Completar</button>
    </div>
  </div>
</main>
<?php get_footer(); ?>""",

    "page-dashboard.php": """<?php
/* Template Name: Dashboard */
get_header(); ?>

<main class="dashboard">
  <?php $user = wp_get_current_user(); ?>
  <h2>Olá, <?php echo $user->display_name ? $user->display_name : 'Usuário'; ?> 👋</h2>
  <p>Saldo atual: <strong>R$50,00</strong></p>

  <div class="acoes">
    <a href="/tarefas" class="btn">Ver Tarefas</a>
    <a href="#" class="btn">Sacar via Pix</a>
  </div>
</main>

<?php get_footer(); ?>""",

    "assets/css/main.css": """body {
  font-family: 'Poppins', sans-serif;
  margin: 0;
  background: #f7f9fb;
  color: #333;
}
.header {
  background: #4caf50;
  color: #fff;
  padding: 15px 30px;
}
.container { max-width: 1200px; margin: 0 auto; }
.hero { text-align: center; padding: 80px 20px; background: linear-gradient(135deg, #4caf50, #2e7d32); color: white; }
.btn {
  background: #fff; color: #2e7d32; padding: 10px 20px; border-radius: 30px;
  text-decoration: none; font-weight: bold; display: inline-block; transition: 0.3s;
}
.btn:hover { background: #e8f5e9; }
.tarefas { max-width: 1000px; margin: 40px auto; padding: 0 20px; }
.tarefa {
  background: white; margin: 15px 0; padding: 20px; border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.footer {
  background: #2e7d32; color: #fff; text-align: center; padding: 20px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin: 40px auto; max-width: 1000px; }
.card {
  background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.dashboard { max-width: 800px; margin: 50px auto; text-align: center; }""",

    "assets/js/main.js": """document.addEventListener("DOMContentLoaded", () => {
  const buttons = document.querySelectorAll(".tarefa .btn");
  buttons.forEach(btn => {
    btn.addEventListener("click", () => {
      alert("✅ Tarefa marcada como concluída! Aguarde a confirmação do saldo.");
    });
  });
});"""
}

# Criação dos arquivos
for path, content in files.items():
    file_path = os.path.join(base_path, path)
    os.makedirs(os.path.dirname(file_path), exist_ok=True)
    with open(file_path, "w", encoding="utf-8") as f:
        f.write(content)

# Compactar tudo em .zip
zip_path = "/mnt/data/tarefaspay.zip"
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
    for root, _, filenames in os.walk(base_path):
        for filename in filenames:
            filepath = os.path.join(root, filename)
            arcname = os.path.relpath(filepath, base_path)
            zipf.write(filepath, arcname)

zip_path
