<?php
/**
 * Template Library
 * Pre-loaded project templates for common freelance design/development projects
 *
 * @package Freelance_Studio
 */

if (!defined('ABSPATH')) {
    exit;
}

class FS_Template_Library {

    /**
     * Get all available library templates
     */
    public static function get_templates() {
        return array(
            'website-design-development' => array(
                'name' => __('Website Design & Development', 'freelance-studio'),
                'description' => __('Full website project from discovery to launch. Ideal for complete website redesigns or new site builds.', 'freelance-studio'),
                'category' => 'web',
                'default_billing_type' => 'fixed',
                'estimated_hours' => 60,
                'typical_price_min' => 3000,
                'typical_price_max' => 15000,
                'milestones' => array(
                    array('name' => 'Discovery & Strategy', 'days_offset' => 0, 'invoice_on_completion' => 1, 'invoice_percentage' => 25, 'description' => 'Initial research, client interviews, and project planning'),
                    array('name' => 'Wireframes & Sitemap', 'days_offset' => 7, 'invoice_on_completion' => 0, 'description' => 'Page structure and content organization'),
                    array('name' => 'Design Concepts', 'days_offset' => 14, 'invoice_on_completion' => 1, 'invoice_percentage' => 25, 'description' => 'Visual design mockups for key pages'),
                    array('name' => 'Design Revisions & Approval', 'days_offset' => 21, 'invoice_on_completion' => 0, 'description' => 'Refinements based on client feedback'),
                    array('name' => 'Development', 'days_offset' => 28, 'invoice_on_completion' => 1, 'invoice_percentage' => 25, 'description' => 'Build out the approved designs'),
                    array('name' => 'Testing & Launch', 'days_offset' => 42, 'invoice_on_completion' => 1, 'invoice_percentage' => 25, 'description' => 'QA testing and site launch'),
                ),
                'tasks' => array(
                    array('title' => 'Send client questionnaire', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Competitor analysis', 'priority' => 'medium', 'days_offset' => 1, 'milestone_index' => 0),
                    array('title' => 'Create sitemap', 'priority' => 'high', 'days_offset' => 7, 'milestone_index' => 1),
                    array('title' => 'Design wireframes', 'priority' => 'high', 'days_offset' => 8, 'milestone_index' => 1),
                    array('title' => 'Wireframe review meeting', 'priority' => 'medium', 'days_offset' => 10, 'milestone_index' => 1),
                    array('title' => 'Homepage design', 'priority' => 'high', 'days_offset' => 14, 'milestone_index' => 2),
                    array('title' => 'Interior page designs', 'priority' => 'high', 'days_offset' => 17, 'milestone_index' => 2),
                    array('title' => 'Mobile responsive designs', 'priority' => 'medium', 'days_offset' => 19, 'milestone_index' => 2),
                    array('title' => 'Design presentation', 'priority' => 'high', 'days_offset' => 21, 'milestone_index' => 3),
                    array('title' => 'Apply revision feedback', 'priority' => 'medium', 'days_offset' => 23, 'milestone_index' => 3),
                    array('title' => 'Development environment setup', 'priority' => 'high', 'days_offset' => 28, 'milestone_index' => 4),
                    array('title' => 'Build homepage', 'priority' => 'high', 'days_offset' => 30, 'milestone_index' => 4),
                    array('title' => 'Build interior pages', 'priority' => 'high', 'days_offset' => 34, 'milestone_index' => 4),
                    array('title' => 'Content integration', 'priority' => 'medium', 'days_offset' => 38, 'milestone_index' => 4),
                    array('title' => 'Browser testing', 'priority' => 'high', 'days_offset' => 42, 'milestone_index' => 5),
                    array('title' => 'Mobile testing', 'priority' => 'high', 'days_offset' => 43, 'milestone_index' => 5),
                    array('title' => 'Client walkthrough', 'priority' => 'medium', 'days_offset' => 44, 'milestone_index' => 5),
                    array('title' => 'Launch checklist', 'priority' => 'high', 'days_offset' => 45, 'milestone_index' => 5),
                ),
            ),
            
            'brand-identity' => array(
                'name' => __('Brand Identity Package', 'freelance-studio'),
                'description' => __('Complete logo and brand guidelines package. Perfect for new businesses or rebranding projects.', 'freelance-studio'),
                'category' => 'branding',
                'default_billing_type' => 'fixed',
                'estimated_hours' => 25,
                'typical_price_min' => 1500,
                'typical_price_max' => 5000,
                'milestones' => array(
                    array('name' => 'Discovery & Research', 'days_offset' => 0, 'invoice_on_completion' => 1, 'invoice_percentage' => 30, 'description' => 'Brand questionnaire and competitive research'),
                    array('name' => 'Logo Concepts', 'days_offset' => 7, 'invoice_on_completion' => 0, 'description' => 'Initial logo directions'),
                    array('name' => 'Refinement & Selection', 'days_offset' => 14, 'invoice_on_completion' => 1, 'invoice_percentage' => 30, 'description' => 'Refine chosen concept'),
                    array('name' => 'Brand Guidelines', 'days_offset' => 21, 'invoice_on_completion' => 0, 'description' => 'Document brand standards'),
                    array('name' => 'Final Deliverables', 'days_offset' => 28, 'invoice_on_completion' => 1, 'invoice_percentage' => 40, 'description' => 'All final files delivered'),
                ),
                'tasks' => array(
                    array('title' => 'Send brand questionnaire', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Competitor logo analysis', 'priority' => 'medium', 'days_offset' => 2, 'milestone_index' => 0),
                    array('title' => 'Create mood board', 'priority' => 'medium', 'days_offset' => 4, 'milestone_index' => 0),
                    array('title' => 'Design logo concept 1', 'priority' => 'high', 'days_offset' => 7, 'milestone_index' => 1),
                    array('title' => 'Design logo concept 2', 'priority' => 'high', 'days_offset' => 8, 'milestone_index' => 1),
                    array('title' => 'Design logo concept 3', 'priority' => 'high', 'days_offset' => 9, 'milestone_index' => 1),
                    array('title' => 'Client presentation', 'priority' => 'high', 'days_offset' => 14, 'milestone_index' => 2),
                    array('title' => 'Refine selected concept', 'priority' => 'high', 'days_offset' => 16, 'milestone_index' => 2),
                    array('title' => 'Finalize color palette', 'priority' => 'medium', 'days_offset' => 18, 'milestone_index' => 2),
                    array('title' => 'Select typography', 'priority' => 'medium', 'days_offset' => 19, 'milestone_index' => 2),
                    array('title' => 'Create brand guidelines document', 'priority' => 'high', 'days_offset' => 21, 'milestone_index' => 3),
                    array('title' => 'Design logo usage examples', 'priority' => 'medium', 'days_offset' => 24, 'milestone_index' => 3),
                    array('title' => 'Prepare logo file package', 'priority' => 'high', 'days_offset' => 28, 'milestone_index' => 4),
                ),
            ),
            
            'wordpress-website' => array(
                'name' => __('WordPress Website', 'freelance-studio'),
                'description' => __('Theme-based WordPress website build. Great for blogs, small business sites, and content-focused projects.', 'freelance-studio'),
                'category' => 'web',
                'default_billing_type' => 'fixed',
                'estimated_hours' => 30,
                'typical_price_min' => 1500,
                'typical_price_max' => 5000,
                'milestones' => array(
                    array('name' => 'Planning & Setup', 'days_offset' => 0, 'invoice_on_completion' => 1, 'invoice_percentage' => 25, 'description' => 'WordPress installation and theme setup'),
                    array('name' => 'Design Customization', 'days_offset' => 5, 'invoice_on_completion' => 1, 'invoice_percentage' => 25, 'description' => 'Theme customization and styling'),
                    array('name' => 'Content & Development', 'days_offset' => 12, 'invoice_on_completion' => 1, 'invoice_percentage' => 25, 'description' => 'Page builds and functionality'),
                    array('name' => 'Testing & Launch', 'days_offset' => 21, 'invoice_on_completion' => 1, 'invoice_percentage' => 25, 'description' => 'Final testing and go-live'),
                ),
                'tasks' => array(
                    array('title' => 'Hosting/domain setup', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'WordPress installation', 'priority' => 'high', 'days_offset' => 1, 'milestone_index' => 0),
                    array('title' => 'Theme selection/purchase', 'priority' => 'high', 'days_offset' => 2, 'milestone_index' => 0),
                    array('title' => 'Essential plugin installation', 'priority' => 'medium', 'days_offset' => 3, 'milestone_index' => 0),
                    array('title' => 'Homepage customization', 'priority' => 'high', 'days_offset' => 5, 'milestone_index' => 1),
                    array('title' => 'Header/footer styling', 'priority' => 'high', 'days_offset' => 7, 'milestone_index' => 1),
                    array('title' => 'Color and typography adjustments', 'priority' => 'medium', 'days_offset' => 9, 'milestone_index' => 1),
                    array('title' => 'Build interior pages', 'priority' => 'high', 'days_offset' => 12, 'milestone_index' => 2),
                    array('title' => 'Contact form setup', 'priority' => 'medium', 'days_offset' => 15, 'milestone_index' => 2),
                    array('title' => 'Content entry', 'priority' => 'medium', 'days_offset' => 17, 'milestone_index' => 2),
                    array('title' => 'SEO basics setup', 'priority' => 'medium', 'days_offset' => 19, 'milestone_index' => 2),
                    array('title' => 'Speed optimization', 'priority' => 'medium', 'days_offset' => 21, 'milestone_index' => 3),
                    array('title' => 'Mobile responsiveness check', 'priority' => 'high', 'days_offset' => 22, 'milestone_index' => 3),
                    array('title' => 'Client training session', 'priority' => 'high', 'days_offset' => 23, 'milestone_index' => 3),
                    array('title' => 'Launch checklist', 'priority' => 'high', 'days_offset' => 24, 'milestone_index' => 3),
                ),
            ),
            
            'landing-page' => array(
                'name' => __('Landing Page', 'freelance-studio'),
                'description' => __('Single conversion-focused landing page. Perfect for campaigns, product launches, or lead generation.', 'freelance-studio'),
                'category' => 'web',
                'default_billing_type' => 'fixed',
                'estimated_hours' => 12,
                'typical_price_min' => 500,
                'typical_price_max' => 2000,
                'milestones' => array(
                    array('name' => 'Strategy & Wireframe', 'days_offset' => 0, 'invoice_on_completion' => 1, 'invoice_percentage' => 50, 'description' => 'Goal setting and page structure'),
                    array('name' => 'Design & Development', 'days_offset' => 3, 'invoice_on_completion' => 0, 'description' => 'Visual design and build'),
                    array('name' => 'Testing & Launch', 'days_offset' => 7, 'invoice_on_completion' => 1, 'invoice_percentage' => 50, 'description' => 'Final testing and go-live'),
                ),
                'tasks' => array(
                    array('title' => 'Define conversion goal', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Wireframe sketch', 'priority' => 'high', 'days_offset' => 1, 'milestone_index' => 0),
                    array('title' => 'Copy review/suggestions', 'priority' => 'medium', 'days_offset' => 2, 'milestone_index' => 0),
                    array('title' => 'Visual design', 'priority' => 'high', 'days_offset' => 3, 'milestone_index' => 1),
                    array('title' => 'Responsive development', 'priority' => 'high', 'days_offset' => 5, 'milestone_index' => 1),
                    array('title' => 'Form/CTA integration', 'priority' => 'high', 'days_offset' => 6, 'milestone_index' => 1),
                    array('title' => 'Analytics setup', 'priority' => 'medium', 'days_offset' => 7, 'milestone_index' => 2),
                    array('title' => 'Cross-browser testing', 'priority' => 'high', 'days_offset' => 8, 'milestone_index' => 2),
                    array('title' => 'Launch', 'priority' => 'high', 'days_offset' => 9, 'milestone_index' => 2),
                ),
            ),
            
            'logo-design' => array(
                'name' => __('Logo Design', 'freelance-studio'),
                'description' => __('Standalone logo design project. Quick turnaround for clients who need a logo only.', 'freelance-studio'),
                'category' => 'branding',
                'default_billing_type' => 'fixed',
                'estimated_hours' => 10,
                'typical_price_min' => 500,
                'typical_price_max' => 2000,
                'milestones' => array(
                    array('name' => 'Discovery', 'days_offset' => 0, 'invoice_on_completion' => 1, 'invoice_percentage' => 50, 'description' => 'Understand brand and requirements'),
                    array('name' => 'Initial Concepts', 'days_offset' => 3, 'invoice_on_completion' => 0, 'description' => 'Present logo directions'),
                    array('name' => 'Refinements', 'days_offset' => 7, 'invoice_on_completion' => 0, 'description' => 'Polish selected direction'),
                    array('name' => 'Final Delivery', 'days_offset' => 10, 'invoice_on_completion' => 1, 'invoice_percentage' => 50, 'description' => 'Deliver all logo files'),
                ),
                'tasks' => array(
                    array('title' => 'Logo questionnaire', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Competitor review', 'priority' => 'medium', 'days_offset' => 1, 'milestone_index' => 0),
                    array('title' => 'Mood board creation', 'priority' => 'medium', 'days_offset' => 2, 'milestone_index' => 0),
                    array('title' => 'Concept direction 1', 'priority' => 'high', 'days_offset' => 3, 'milestone_index' => 1),
                    array('title' => 'Concept direction 2', 'priority' => 'high', 'days_offset' => 4, 'milestone_index' => 1),
                    array('title' => 'Concept direction 3', 'priority' => 'high', 'days_offset' => 5, 'milestone_index' => 1),
                    array('title' => 'Client feedback meeting', 'priority' => 'high', 'days_offset' => 7, 'milestone_index' => 2),
                    array('title' => 'Round 1 revisions', 'priority' => 'high', 'days_offset' => 8, 'milestone_index' => 2),
                    array('title' => 'Round 2 revisions', 'priority' => 'medium', 'days_offset' => 9, 'milestone_index' => 2),
                    array('title' => 'Prepare final file package', 'priority' => 'high', 'days_offset' => 10, 'milestone_index' => 3),
                ),
            ),
            
            'ecommerce-website' => array(
                'name' => __('E-commerce Website', 'freelance-studio'),
                'description' => __('Online store with product catalog and checkout. Ideal for businesses selling products online.', 'freelance-studio'),
                'category' => 'web',
                'default_billing_type' => 'fixed',
                'estimated_hours' => 80,
                'typical_price_min' => 5000,
                'typical_price_max' => 20000,
                'milestones' => array(
                    array('name' => 'Discovery & Planning', 'days_offset' => 0, 'invoice_on_completion' => 1, 'invoice_percentage' => 20, 'description' => 'Requirements and platform setup'),
                    array('name' => 'Design', 'days_offset' => 7, 'invoice_on_completion' => 1, 'invoice_percentage' => 20, 'description' => 'Store design and UX'),
                    array('name' => 'Development', 'days_offset' => 21, 'invoice_on_completion' => 1, 'invoice_percentage' => 30, 'description' => 'Build and configure store'),
                    array('name' => 'Product Setup & Testing', 'days_offset' => 42, 'invoice_on_completion' => 1, 'invoice_percentage' => 15, 'description' => 'Add products and test checkout'),
                    array('name' => 'Launch & Training', 'days_offset' => 56, 'invoice_on_completion' => 1, 'invoice_percentage' => 15, 'description' => 'Go live and train client'),
                ),
                'tasks' => array(
                    array('title' => 'E-commerce questionnaire', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Platform selection (WooCommerce/Shopify)', 'priority' => 'high', 'days_offset' => 2, 'milestone_index' => 0),
                    array('title' => 'Payment gateway setup', 'priority' => 'high', 'days_offset' => 4, 'milestone_index' => 0),
                    array('title' => 'Shipping configuration', 'priority' => 'high', 'days_offset' => 5, 'milestone_index' => 0),
                    array('title' => 'Homepage design', 'priority' => 'high', 'days_offset' => 7, 'milestone_index' => 1),
                    array('title' => 'Product listing design', 'priority' => 'high', 'days_offset' => 10, 'milestone_index' => 1),
                    array('title' => 'Product page design', 'priority' => 'high', 'days_offset' => 13, 'milestone_index' => 1),
                    array('title' => 'Cart/checkout design', 'priority' => 'high', 'days_offset' => 16, 'milestone_index' => 1),
                    array('title' => 'Theme development/customization', 'priority' => 'high', 'days_offset' => 21, 'milestone_index' => 2),
                    array('title' => 'Build product pages', 'priority' => 'high', 'days_offset' => 28, 'milestone_index' => 2),
                    array('title' => 'Configure checkout flow', 'priority' => 'high', 'days_offset' => 35, 'milestone_index' => 2),
                    array('title' => 'Tax settings', 'priority' => 'medium', 'days_offset' => 38, 'milestone_index' => 2),
                    array('title' => 'Product data import', 'priority' => 'high', 'days_offset' => 42, 'milestone_index' => 3),
                    array('title' => 'Test transactions', 'priority' => 'high', 'days_offset' => 48, 'milestone_index' => 3),
                    array('title' => 'Order fulfillment testing', 'priority' => 'high', 'days_offset' => 50, 'milestone_index' => 3),
                    array('title' => 'Client training', 'priority' => 'high', 'days_offset' => 56, 'milestone_index' => 4),
                    array('title' => 'Launch checklist', 'priority' => 'high', 'days_offset' => 58, 'milestone_index' => 4),
                    array('title' => 'Post-launch support', 'priority' => 'medium', 'days_offset' => 60, 'milestone_index' => 4),
                ),
            ),
            
            'mobile-app-ui' => array(
                'name' => __('Mobile App UI Design', 'freelance-studio'),
                'description' => __('App screen designs and prototypes. For startups and businesses building mobile applications.', 'freelance-studio'),
                'category' => 'design',
                'default_billing_type' => 'fixed',
                'estimated_hours' => 40,
                'typical_price_min' => 3000,
                'typical_price_max' => 10000,
                'milestones' => array(
                    array('name' => 'Research & User Flows', 'days_offset' => 0, 'invoice_on_completion' => 1, 'invoice_percentage' => 25, 'description' => 'Understand users and map journeys'),
                    array('name' => 'Wireframes', 'days_offset' => 7, 'invoice_on_completion' => 0, 'description' => 'Low-fidelity screen layouts'),
                    array('name' => 'UI Design', 'days_offset' => 14, 'invoice_on_completion' => 1, 'invoice_percentage' => 50, 'description' => 'High-fidelity screen designs'),
                    array('name' => 'Prototyping & Handoff', 'days_offset' => 28, 'invoice_on_completion' => 1, 'invoice_percentage' => 25, 'description' => 'Interactive prototype and dev specs'),
                ),
                'tasks' => array(
                    array('title' => 'User persona review', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Competitive app analysis', 'priority' => 'medium', 'days_offset' => 2, 'milestone_index' => 0),
                    array('title' => 'User flow diagrams', 'priority' => 'high', 'days_offset' => 4, 'milestone_index' => 0),
                    array('title' => 'Low-fi wireframes', 'priority' => 'high', 'days_offset' => 7, 'milestone_index' => 1),
                    array('title' => 'Wireframe review meeting', 'priority' => 'high', 'days_offset' => 10, 'milestone_index' => 1),
                    array('title' => 'Wireframe revisions', 'priority' => 'medium', 'days_offset' => 12, 'milestone_index' => 1),
                    array('title' => 'UI style guide', 'priority' => 'high', 'days_offset' => 14, 'milestone_index' => 2),
                    array('title' => 'Core screen designs', 'priority' => 'high', 'days_offset' => 17, 'milestone_index' => 2),
                    array('title' => 'Secondary screen designs', 'priority' => 'high', 'days_offset' => 21, 'milestone_index' => 2),
                    array('title' => 'Component library', 'priority' => 'medium', 'days_offset' => 25, 'milestone_index' => 2),
                    array('title' => 'Interactive prototype', 'priority' => 'high', 'days_offset' => 28, 'milestone_index' => 3),
                    array('title' => 'Developer handoff specs', 'priority' => 'high', 'days_offset' => 32, 'milestone_index' => 3),
                    array('title' => 'Asset export', 'priority' => 'medium', 'days_offset' => 34, 'milestone_index' => 3),
                ),
            ),
            
            'marketing-collateral' => array(
                'name' => __('Marketing Collateral', 'freelance-studio'),
                'description' => __('Print materials package including business cards, letterhead, and promotional items.', 'freelance-studio'),
                'category' => 'print',
                'default_billing_type' => 'fixed',
                'estimated_hours' => 15,
                'typical_price_min' => 800,
                'typical_price_max' => 2500,
                'milestones' => array(
                    array('name' => 'Brief & Planning', 'days_offset' => 0, 'invoice_on_completion' => 1, 'invoice_percentage' => 30, 'description' => 'Creative brief and requirements'),
                    array('name' => 'Design Concepts', 'days_offset' => 3, 'invoice_on_completion' => 0, 'description' => 'Initial design directions'),
                    array('name' => 'Revisions & Approval', 'days_offset' => 10, 'invoice_on_completion' => 1, 'invoice_percentage' => 30, 'description' => 'Refinements based on feedback'),
                    array('name' => 'Print-Ready Files', 'days_offset' => 14, 'invoice_on_completion' => 1, 'invoice_percentage' => 40, 'description' => 'Final files for print production'),
                ),
                'tasks' => array(
                    array('title' => 'Creative brief', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Gather brand assets', 'priority' => 'high', 'days_offset' => 1, 'milestone_index' => 0),
                    array('title' => 'Business card design', 'priority' => 'high', 'days_offset' => 3, 'milestone_index' => 1),
                    array('title' => 'Letterhead design', 'priority' => 'high', 'days_offset' => 5, 'milestone_index' => 1),
                    array('title' => 'Envelope design', 'priority' => 'medium', 'days_offset' => 6, 'milestone_index' => 1),
                    array('title' => 'Flyer/brochure design', 'priority' => 'high', 'days_offset' => 7, 'milestone_index' => 1),
                    array('title' => 'Client review meeting', 'priority' => 'high', 'days_offset' => 10, 'milestone_index' => 2),
                    array('title' => 'Apply revision feedback', 'priority' => 'high', 'days_offset' => 11, 'milestone_index' => 2),
                    array('title' => 'Print vendor coordination', 'priority' => 'medium', 'days_offset' => 13, 'milestone_index' => 2),
                    array('title' => 'Prepare print-ready files', 'priority' => 'high', 'days_offset' => 14, 'milestone_index' => 3),
                ),
            ),
            
            'social-media-package' => array(
                'name' => __('Social Media Design Package', 'freelance-studio'),
                'description' => __('Templates and branded graphics for social media platforms.', 'freelance-studio'),
                'category' => 'design',
                'default_billing_type' => 'fixed',
                'estimated_hours' => 20,
                'typical_price_min' => 600,
                'typical_price_max' => 2000,
                'milestones' => array(
                    array('name' => 'Strategy & Templates', 'days_offset' => 0, 'invoice_on_completion' => 1, 'invoice_percentage' => 50, 'description' => 'Platform audit and template designs'),
                    array('name' => 'Content Creation', 'days_offset' => 5, 'invoice_on_completion' => 0, 'description' => 'Design branded post graphics'),
                    array('name' => 'Final Delivery', 'days_offset' => 14, 'invoice_on_completion' => 1, 'invoice_percentage' => 50, 'description' => 'All files and templates delivered'),
                ),
                'tasks' => array(
                    array('title' => 'Social media audit', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Define visual strategy', 'priority' => 'high', 'days_offset' => 1, 'milestone_index' => 0),
                    array('title' => 'Profile cover designs', 'priority' => 'high', 'days_offset' => 2, 'milestone_index' => 0),
                    array('title' => 'Feed post templates', 'priority' => 'high', 'days_offset' => 3, 'milestone_index' => 0),
                    array('title' => 'Story templates', 'priority' => 'medium', 'days_offset' => 4, 'milestone_index' => 0),
                    array('title' => 'Design post graphics (batch 1)', 'priority' => 'high', 'days_offset' => 5, 'milestone_index' => 1),
                    array('title' => 'Design post graphics (batch 2)', 'priority' => 'high', 'days_offset' => 8, 'milestone_index' => 1),
                    array('title' => 'Design story graphics', 'priority' => 'medium', 'days_offset' => 10, 'milestone_index' => 1),
                    array('title' => 'Canva template setup (optional)', 'priority' => 'low', 'days_offset' => 12, 'milestone_index' => 1),
                    array('title' => 'Create social style guide', 'priority' => 'medium', 'days_offset' => 14, 'milestone_index' => 2),
                    array('title' => 'Export all files', 'priority' => 'high', 'days_offset' => 15, 'milestone_index' => 2),
                ),
            ),
            
            'website-maintenance-retainer' => array(
                'name' => __('Website Maintenance Retainer', 'freelance-studio'),
                'description' => __('Monthly ongoing website support and maintenance. Keeps client sites secure and up to date.', 'freelance-studio'),
                'category' => 'retainer',
                'default_billing_type' => 'retainer',
                'estimated_hours' => 5,
                'typical_price_min' => 150,
                'typical_price_max' => 500,
                'milestones' => array(
                    array('name' => 'Monthly Maintenance', 'days_offset' => 0, 'invoice_on_completion' => 1, 'invoice_percentage' => 100, 'description' => 'Regular monthly maintenance tasks'),
                ),
                'tasks' => array(
                    array('title' => 'WordPress core update', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Plugin updates', 'priority' => 'high', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Theme updates', 'priority' => 'medium', 'days_offset' => 0, 'milestone_index' => 0),
                    array('title' => 'Security scan', 'priority' => 'high', 'days_offset' => 1, 'milestone_index' => 0),
                    array('title' => 'Backup verification', 'priority' => 'high', 'days_offset' => 1, 'milestone_index' => 0),
                    array('title' => 'Performance check', 'priority' => 'medium', 'days_offset' => 2, 'milestone_index' => 0),
                    array('title' => 'Content updates (if requested)', 'priority' => 'low', 'days_offset' => 3, 'milestone_index' => 0),
                    array('title' => 'Monthly report', 'priority' => 'medium', 'days_offset' => 5, 'milestone_index' => 0),
                ),
            ),
        );
    }

    /**
     * Get template by slug
     */
    public static function get_template($slug) {
        $templates = self::get_templates();
        return isset($templates[$slug]) ? $templates[$slug] : null;
    }

    /**
     * Get templates by category
     */
    public static function get_templates_by_category($category) {
        $templates = self::get_templates();
        $filtered = array();
        
        foreach ($templates as $slug => $template) {
            if ($template['category'] === $category) {
                $filtered[$slug] = $template;
            }
        }
        
        return $filtered;
    }

    /**
     * Get available categories
     */
    public static function get_categories() {
        return array(
            'web' => __('Web Design & Development', 'freelance-studio'),
            'branding' => __('Branding & Identity', 'freelance-studio'),
            'design' => __('Graphic Design', 'freelance-studio'),
            'print' => __('Print Design', 'freelance-studio'),
            'retainer' => __('Retainer Services', 'freelance-studio'),
        );
    }

    /**
     * Import a template to the database
     */
    public static function import_template($slug) {
        $template = self::get_template($slug);
        
        if (!$template) {
            return new WP_Error('invalid_template', __('Template not found', 'freelance-studio'));
        }
        
        // Check if template with same name already exists
        $existing = FS_Project_Template::get_all();
        foreach ($existing as $existing_template) {
            if ($existing_template->name === $template['name']) {
                return new WP_Error('duplicate_template', __('A template with this name already exists', 'freelance-studio'));
            }
        }
        
        // Create the template
        $template_id = FS_Project_Template::create(array(
            'name' => $template['name'],
            'description' => $template['description'],
            'default_billing_type' => $template['default_billing_type'],
            'estimated_hours' => $template['estimated_hours'],
            'typical_price_min' => $template['typical_price_min'],
            'typical_price_max' => $template['typical_price_max'],
            'default_milestones' => $template['milestones'],
            'default_tasks' => $template['tasks'],
        ));
        
        if (!$template_id) {
            return new WP_Error('create_failed', __('Failed to create template', 'freelance-studio'));
        }
        
        return $template_id;
    }

    /**
     * Import multiple templates
     */
    public static function import_templates($slugs) {
        $results = array(
            'success' => array(),
            'errors' => array(),
        );
        
        foreach ($slugs as $slug) {
            $result = self::import_template($slug);
            
            if (is_wp_error($result)) {
                $results['errors'][$slug] = $result->get_error_message();
            } else {
                $results['success'][$slug] = $result;
            }
        }
        
        return $results;
    }

    /**
     * Check which templates are already imported
     */
    public static function get_imported_status() {
        $templates = self::get_templates();
        $existing = FS_Project_Template::get_all();
        $existing_names = array();
        
        foreach ($existing as $template) {
            $existing_names[] = $template->name;
        }
        
        $status = array();
        foreach ($templates as $slug => $template) {
            $status[$slug] = in_array($template['name'], $existing_names);
        }
        
        return $status;
    }
}
