# Master script to rebuild all remaining templates with modern structure
$baseTemplate = Get-Content "src-tauri\templates\core\default.json" -Raw | ConvertFrom-Json

$templates = @(
    @{path="corporate\professional.json"; id="professional"; name="Professional Business"; category="Corporate"; desc="Professional business formatting for corporate documents, reports, and proposals. Clean sans-serif typography with authoritative presence."; vibe="Corporate, Trustworthy, Polished"; fonts="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap"; heading="Open Sans"; body="Open Sans"; text="1A202C"; accent="2C5282"},
    @{path="creative\modern-portfolio.json"; id="modern-portfolio"; name="Modern Portfolio"; category="Creative"; desc="Bold, contemporary design for creative portfolios and showcases. Geometric fonts with striking visual hierarchy."; vibe="Creative, Bold, Contemporary"; fonts="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap"; heading="Space Grotesk"; body="Space Grotesk"; text="1A1A1A"; accent="E94560"},
    @{path="editorial\classic-newspaper.json"; id="classic-newspaper"; name="Classic Newspaper"; category="Editorial"; desc="Traditional newspaper-style formatting with column layout and classic serif typography."; vibe="Editorial, Timeless, Authoritative"; fonts="https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,400;0,700;1,400&display=swap"; heading="Merriweather"; body="Merriweather"; text="1A1A1A"; accent="8B0000"},
    @{path="industrial\brutalist.json"; id="brutalist"; name="Brutalist"; category="Industrial"; desc="Raw, bold, unapologetic design inspired by brutalist architecture. Monospace typography with aggressive spacing."; vibe="Bold, Raw, Unrefined"; fonts="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700&display=swap"; heading="Roboto Mono"; body="Roboto Mono"; text="000000"; accent="FF4500"},
    @{path="lifestyle\elegant-magazine.json"; id="elegant-magazine"; name="Elegant Magazine"; category="Lifestyle"; desc="Sophisticated magazine layout with elegant serif typography and generous whitespace."; vibe="Sophisticated, Luxurious, Refined"; fonts="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&display=swap"; heading="Cormorant Garamond"; body="Cormorant Garamond"; text="2B2B2B"; accent="D4A574"},
    @{path="tech\tech-startup.json"; id="tech-startup"; name="Tech Startup"; category="Tech"; desc="Modern, clean design for tech companies and startups. Sans-serif typography with vibrant accents."; vibe="Innovative, Modern, Dynamic"; fonts="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap"; heading="Plus Jakarta Sans"; body="Plus Jakarta Sans"; text="0F172A"; accent="6366F1"},
    @{path="vintage\retro-typewriter.json"; id="retro-typewriter"; name="Retro Typewriter"; category="Vintage"; desc="Vintage typewriter aesthetic with monospace fonts and classic styling."; vibe="Nostalgic, Classic, Authentic"; fonts="https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400&display=swap"; heading="Courier Prime"; body="Courier Prime"; text="2C2C2C"; accent="5C4033"}
)

foreach ($t in $templates) {
    $new = $baseTemplate.PSObject.Copy()
    
    # Update metadata
    $new.id = $t.id
    $new.name = $t.name
    $new.category = $t.category
    $new.description = $t.desc
    $new.vibe = $t.vibe
    $new.googleFontsImport = $t.fonts
    
    # Update typography
    $new.typography.fonts.heading = $t.heading
    $new.typography.fonts.body = $t.body
    $new.typography.colors.text = $t.text
    $new.typography.colors.accent = $t.accent
    $new.typography.colors.blockquoteBorder = $t.accent
    
    # Write to file
    $json = $new | ConvertTo-Json -Depth 10
    $fullPath = "src-tauri\templates\$($t.path)"
    [System.IO.File]::WriteAllLines($fullPath, $json)
    Write-Host "✅ Created $($t.path)" -ForegroundColor Green
}

Write-Host "`n✅ All templates rebuilt successfully!" -ForegroundColor Green
