// AI Brand Strategy Generator - Main Application Script // Modern ES6+ JavaScript with clean architecture class BrandStrategyApp { constructor() { this.currentStep = 1; this.totalSteps = 5; this.formData = {}; this.currentScreen = 'loginScreen'; this.demoScenarios = this.initializeDemoScenarios(); this.init(); } init() { this.initHeaderAnimations(); this.createFormSteps(); this.showFormStep(1); this.updateStepIndicator(); this.updateProgressBar(); this.setupAutoSave(); this.setupEventListeners(); } initHeaderAnimations() { // Initialize sophisticated header animations with staggered reveals const heroWords = document.querySelectorAll('.hero-word'); const heroLines = document.querySelectorAll('.hero-line'); const heroDecoration = document.querySelector('.hero-decoration'); // Animate words with staggered delays heroWords.forEach((word, index) => { const delay = parseInt(word.dataset.delay) || index * 100; word.style.animationDelay = `${delay}ms`; // Add hover interaction for extra sophistication word.addEventListener('mouseenter', () => { word.style.transform = 'scale(1.05) rotateX(-5deg)'; word.style.transition = 'transform 0.3s cubic-bezier(0.16, 1, 0.3, 1)'; }); word.addEventListener('mouseleave', () => { word.style.transform = 'scale(1) rotateX(0deg)'; }); }); // Animate subtitle lines heroLines.forEach((line, index) => { const delay = parseInt(line.dataset.delay) || (600 + index * 200); line.style.animationDelay = `${delay}ms`; }); // Animate decoration element if (heroDecoration) { const delay = parseInt(heroDecoration.dataset.delay) || 1000; heroDecoration.style.animationDelay = `${delay}ms`; // Add click interaction for decoration heroDecoration.addEventListener('click', () => { heroDecoration.style.animation = 'decorationShine 1s ease-in-out'; setTimeout(() => { heroDecoration.style.animation = ''; }, 1000); }); } // Add parallax effect to header background this.initParallaxEffect(); } initParallaxEffect() { const header = document.querySelector('.app-header'); if (!header) return; window.addEventListener('scroll', () => { const scrolled = window.pageYOffset; const rate = scrolled * -0.5; if (header) { header.style.transform = `translateY(${rate}px)`; } }); } initializeDemoScenarios() { return { tech: { companyName: "QuantumFlow AI", industry: "technology", companySize: "startup", website: "https://quantumflow.ai", description: "Revolutionary AI-powered workflow automation platform for enterprises seeking to transform their operational efficiency and reduce manual processes by up to 80%.", challenges: "Limited brand awareness in competitive market, high customer acquisition costs, difficulty communicating complex AI value proposition to non-technical decision makers", objectives: "Increase brand recognition by 300% in enterprise market, acquire 1000+ enterprise customers, achieve $10M ARR within 18 months, establish thought leadership in AI automation space", targetAudience: "Enterprise CTOs, IT Directors, and Operations Managers at companies with 500+ employees, typically aged 35-55, focused on digital transformation and operational efficiency", competitors: "Zapier, Microsoft Power Automate, UiPath, Automation Anywhere, ServiceNow", budget: "50k-100k", revenueGrowth: "100-200", timeline: "18-months", customerPains: "Manual repetitive tasks consuming 40% of employee time, disconnected systems requiring manual data transfer, lack of real-time operational visibility", geography: "national", advantages: "Advanced AI that learns from user patterns, 90% faster implementation than competitors, enterprise-grade security with SOC2 compliance", positioning: "innovation" }, healthcare: { companyName: "SmileCare Dental Group", industry: "healthcare", companySize: "medium", website: "https://smilecare.com", description: "Premier multi-location dental practice focused on comprehensive family and cosmetic dentistry, serving over 15,000 patients across 5 locations with state-of-the-art technology.", challenges: "Patient acquisition in digital-first environment, competing with corporate dental chains, managing online reputation across multiple locations, inconsistent brand messaging", objectives: "Increase new patient bookings by 150% across all locations, improve online reviews to 4.8+ stars, expand to 3 new locations within 2 years, launch comprehensive digital patient experience", targetAudience: "Health-conscious families with children, young professionals aged 25-45, seniors seeking specialized care, patients interested in cosmetic dentistry and wellness", competitors: "Aspen Dental, Heartland Dental, Pacific Dental Services, local independent practices, dental chains like Western Dental", budget: "25k-50k", revenueGrowth: "50-100", timeline: "2-years", customerPains: "Difficulty finding convenient appointment times, anxiety about dental procedures, confusion about insurance coverage, inconsistent care quality experiences", geography: "local", advantages: "Personalized care relationships, advanced pain-free technology, comprehensive family treatment under one roof, flexible scheduling and payment options", positioning: "service" }, retail: { companyName: "EcoStyle Fashion", industry: "retail", companySize: "small", website: "https://ecostyle.com", description: "Sustainable fashion brand creating ethically-made, eco-friendly apparel for conscious consumers, focusing on timeless designs and transparent supply chain practices.", challenges: "Transition from physical retail to online-first strategy, building brand trust in digital space, competing with fast fashion pricing, educating consumers about sustainable fashion value", objectives: "Achieve 70% online sales mix, build email list of 50,000 engaged subscribers, launch brand story campaign highlighting sustainability impact, increase average order value by 40%", targetAudience: "Environmentally conscious millennials and Gen Z consumers aged 18-40, income $50k+, values-driven shopping behavior, active on social media and sustainability communities", competitors: "Patagonia, Everlane, Reformation, Eileen Fisher, Organic Basics, local sustainable fashion brands", budget: "10k-25k", revenueGrowth: "50-100", timeline: "1-year", customerPains: "Difficulty finding stylish sustainable options, higher prices compared to fast fashion, uncertainty about true sustainability claims, limited size inclusivity in eco-fashion", geography: "national", advantages: "Fully transparent supply chain, carbon-neutral shipping, lifetime repair guarantee, inclusive sizing 0-24, partnership with environmental nonprofits", positioning: "value" } }; } setupEventListeners() { // Prevent form submission on Enter key document.addEventListener('keydown', (e) => { if (e.key === 'Enter' && e.target.tagName !== 'TEXTAREA') { e.preventDefault(); if (this.currentScreen === 'formScreen') { this.nextStep(); } } }); // Add smooth scrolling for better UX document.addEventListener('scroll', this.debounce(this.updateScrollProgress.bind(this), 100)); } setupAutoSave() { setInterval(() => { if (this.currentScreen === 'formScreen') { this.saveCurrentStepData(); console.log('Auto-saved form data:', this.formData); // Show subtle save indicator this.showSaveIndicator(); } }, 30000); // Auto-save every 30 seconds } showSaveIndicator() { // Create and show a subtle save indicator const indicator = document.createElement('div'); indicator.textContent = 'πŸ’Ύ Draft saved'; indicator.style.cssText = ` position: fixed; top: 20px; right: 20px; background: var(--success); color: white; padding: 8px 16px; border-radius: 8px; font-size: 14px; z-index: 1000; opacity: 0; transition: opacity 0.3s ease; `; document.body.appendChild(indicator); // Animate in setTimeout(() => indicator.style.opacity = '1', 100); // Remove after 2 seconds setTimeout(() => { indicator.style.opacity = '0'; setTimeout(() => document.body.removeChild(indicator), 300); }, 2000); } updateScrollProgress() { const scrolled = (window.scrollY / (document.documentElement.scrollHeight - window.innerHeight)) * 100; document.documentElement.style.setProperty('--scroll-progress', `${scrolled}%`); } showScreen(screenId) { // Add exit animation to current screen const currentScreenEl = document.querySelector('.screen.active'); if (currentScreenEl) { currentScreenEl.style.animation = 'fadeOut 0.3s ease-out'; setTimeout(() => { currentScreenEl.classList.remove('active'); currentScreenEl.style.animation = ''; }, 300); } // Show new screen with entrance animation setTimeout(() => { document.querySelectorAll('.screen').forEach(screen => { screen.classList.remove('active'); }); document.getElementById(screenId).classList.add('active'); this.currentScreen = screenId; }, 300); } login() { const username = document.getElementById('username').value; const password = document.getElementById('password').value; // Simple validation for demo if (username && password) { this.showScreen('dashboardScreen'); this.trackEvent('user_login', { demo_mode: true }); } else { this.showNotification('Please enter both username and password', 'warning'); } } logout() { this.showScreen('loginScreen'); this.resetForm(); this.trackEvent('user_logout'); } startNewStrategy() { this.showScreen('formScreen'); this.resetForm(); this.trackEvent('strategy_started'); } backToDashboard() { this.showScreen('dashboardScreen'); } loadDemoScenario(scenario) { const data = this.demoScenarios[scenario]; if (!data) { this.showNotification('Demo scenario not found', 'error'); return; } this.formData = { ...data }; // Fill form with demo data this.populateFormFields(data); // Track demo usage this.trackEvent('demo_scenario_loaded', { scenario }); // Show notification this.showNotification(`Loaded ${data.companyName} demo scenario`, 'success'); // Skip to processing screen setTimeout(() => this.showProcessingScreen(), 500); } populateFormFields(data) { const fieldMap = { 'companyName': data.companyName, 'industry': data.industry, 'companySize': data.companySize, 'website': data.website, 'description': data.description, 'challenges': data.challenges, 'budget': data.budget, 'objectives': data.objectives, 'revenueGrowth': data.revenueGrowth, 'timeline': data.timeline, 'targetAudience': data.targetAudience, 'customerPains': data.customerPains, 'geography': data.geography, 'competitors': data.competitors, 'advantages': data.advantages, 'positioning': data.positioning }; Object.entries(fieldMap).forEach(([fieldId, value]) => { const element = document.getElementById(fieldId); if (element && value) { element.value = value; } }); } resetForm() { this.currentStep = 1; this.formData = {}; const form = document.getElementById('clientForm'); if (form) form.reset(); this.updateStepIndicator(); this.updateProgressBar(); this.showFormStep(1); } nextStep() { if (this.validateCurrentStep()) { this.saveCurrentStepData(); if (this.currentStep < this.totalSteps) { this.currentStep++; this.showFormStep(this.currentStep); this.updateStepIndicator(); this.updateProgressBar(); this.trackEvent('form_step_completed', { step: this.currentStep - 1 }); } else { // Form completed, start processing this.trackEvent('form_completed', { data: this.formData }); this.showProcessingScreen(); } } } previousStep() { if (this.currentStep > 1) { this.currentStep--; this.showFormStep(this.currentStep); this.updateStepIndicator(); this.updateProgressBar(); } } validateCurrentStep() { const currentStepElement = document.querySelector(`.form-step:nth-child(${this.currentStep})`); if (!currentStepElement) return false; const requiredFields = currentStepElement.querySelectorAll('input[required], select[required], textarea[required]'); let isValid = true; let firstInvalidField = null; requiredFields.forEach(field => { const isFieldValid = field.value.trim() !== ''; if (!isFieldValid) { field.style.borderColor = 'var(--danger)'; field.style.boxShadow = '0 0 0 3px rgba(239, 68, 68, 0.1)'; isValid = false; if (!firstInvalidField) firstInvalidField = field; } else { field.style.borderColor = 'var(--glass-border)'; field.style.boxShadow = ''; } }); if (!isValid) { this.showNotification('Please fill in all required fields', 'warning'); if (firstInvalidField) { firstInvalidField.focus(); firstInvalidField.scrollIntoView({ behavior: 'smooth', block: 'center' }); } } return isValid; } saveCurrentStepData() { const currentStepElement = document.querySelector(`.form-step:nth-child(${this.currentStep})`); if (!currentStepElement) return; const inputs = currentStepElement.querySelectorAll('input, select, textarea'); inputs.forEach(input => { if (input.id) { this.formData[input.id] = input.value; } }); } showFormStep(step) { this.createFormSteps(); // Ensure steps exist document.querySelectorAll('.form-step').forEach((stepEl, index) => { stepEl.style.display = index + 1 === step ? 'block' : 'none'; }); // Update navigation buttons const prevBtn = document.getElementById('prevBtn'); const nextBtn = document.getElementById('nextBtn'); if (prevBtn) prevBtn.style.display = step > 1 ? 'inline-flex' : 'none'; if (nextBtn) nextBtn.textContent = step === this.totalSteps ? 'Generate Strategy πŸš€' : 'Next Step β†’'; } createFormSteps() { const form = document.getElementById('clientForm'); if (!form) return; // Check if steps already exist if (form.querySelectorAll('.form-step').length >= this.totalSteps) return; form.innerHTML = this.generateFormHTML(); } generateFormHTML() { return `

🏒 Company Basics

Tell us about your company and what industry you're in

πŸ“Š Current Situation

Help us understand your current market position and challenges

🎯 Business Objectives

Define your goals and growth targets for the next 12-24 months

πŸ‘₯ Target Audience

Tell us about your ideal customers and their needs

βš”οΈ Competitive Landscape

Help us understand your competitive environment and advantages

`; } updateStepIndicator() { for (let i = 1; i <= this.totalSteps; i++) { const indicator = document.getElementById(`step${i}Indicator`); if (!indicator) continue; indicator.classList.remove('active', 'completed'); if (i < this.currentStep) { indicator.classList.add('completed'); } else if (i === this.currentStep) { indicator.classList.add('active'); } } } updateProgressBar() { const progress = (this.currentStep / this.totalSteps) * 100; const progressFill = document.getElementById('progressFill'); if (progressFill) { progressFill.style.width = progress + '%'; } } showProcessingScreen() { this.showScreen('processingScreen'); this.simulateProcessing(); } simulateProcessing() { const messages = [ "πŸš€ Initializing AI Strategy Engine...", "πŸ“Š Analyzing market position and trends...", "πŸ” Researching competitive landscape...", "πŸ’‘ Generating strategic recommendations...", "⚑ Optimizing RACE framework...", "πŸ“ˆ Creating SWOT analysis...", "✨ Building comprehensive strategy...", "🎯 Finalizing strategy document..." ]; let messageIndex = 0; let progress = 0; const interval = setInterval(() => { if (messageIndex < messages.length) { const loadingMessage = document.getElementById('loadingMessage'); if (loadingMessage) { loadingMessage.textContent = messages[messageIndex]; } messageIndex++; } progress += Math.random() * 12 + 3; // More realistic progress if (progress > 100) progress = 100; const processingProgress = document.getElementById('processingProgress'); if (processingProgress) { processingProgress.style.width = progress + '%'; } if (progress >= 100) { clearInterval(interval); setTimeout(() => { this.generateStrategy(); this.showScreen('strategyScreen'); this.trackEvent('strategy_generated', { company: this.formData.companyName, industry: this.formData.industry }); }, 1000); } }, 600); // Slightly faster for better UX } generateStrategy() { const companyName = this.formData.companyName || "Your Company"; const clientCompanyName = document.getElementById('clientCompanyName'); if (clientCompanyName) { clientCompanyName.textContent = companyName; } const strategyContent = document.getElementById('strategyContent'); if (!strategyContent) return; strategyContent.innerHTML = this.generateStrategyHTML(); // Add smooth reveal animation for strategy sections setTimeout(() => { const sections = strategyContent.querySelectorAll('.strategy-section'); sections.forEach((section, index) => { setTimeout(() => { section.style.opacity = '0'; section.style.transform = 'translateY(20px)'; section.style.transition = 'all 0.5s ease'; setTimeout(() => { section.style.opacity = '1'; section.style.transform = 'translateY(0)'; }, 50); }, index * 200); }); }, 100); } generateStrategyHTML() { const data = this.formData; const companyName = data.companyName || "Your Company"; return `

🎯 Situation Analysis

Company Overview: ${data.description || 'A forward-thinking company positioned for growth in the competitive marketplace.'}

Current Challenges: ${data.challenges || 'Limited brand awareness and market penetration in target segments.'}

πŸ“Š Market Position Analysis & Competitive Mapping

SWOT Analysis:

πŸš€ Strategic Objectives

Primary Goals (${data.timeline || '12-month'} timeline):

πŸ“ˆ Revenue Growth Projection & Milestone Timeline

Key Performance Indicators:

πŸ’‘ Brand Strategy & Positioning

Brand Positioning Statement:
${companyName} is the ${data.positioning || 'innovative'} choice for ${data.targetAudience || 'forward-thinking businesses'} seeking ${data.advantages || 'superior solutions and exceptional value'} in the ${data.industry || 'technology'} space. We deliver measurable results through our unique approach that combines cutting-edge innovation with personalized service.

Value Proposition Framework:

Target Audience Segmentation:

⚑ Tactical Implementation (RACE Framework)

🎯 REACH - Build Awareness & Drive Traffic:

πŸ’¬ ACT - Drive Engagement & Interest:

πŸ’° CONVERT - Generate Quality Leads & Sales:

❀️ ENGAGE - Build Loyalty & Advocacy:

πŸ“‹ 90-Day Action Plan

Month 1 - Foundation & Setup:

Month 2 - Campaign Launch & Amplification:

Month 3 - Optimization & Scale:

πŸ“… Implementation Timeline & Resource Allocation Gantt Chart

Resource Requirements:

πŸ“Š Measurement & Control Framework

Monitoring Schedule:

Analytics & Reporting Tools:

πŸ“ˆ Real-Time Performance Dashboard & KPI Tracking

Success Benchmarks & Milestones:

Optimization Framework:

πŸ’Ό Investment Summary & ROI Projections

Recommended Investment Allocation:

πŸ’° Investment Allocation & ROI Projection Chart

Financial Projections:

Risk Mitigation:

`; } exportToPDF() { this.showNotification('PDF export feature would integrate with jsPDF library for production. Demo shows complete workflow.', 'info'); this.trackEvent('pdf_export_attempted'); // In production, this would use jsPDF or similar library // For demo, we'll simulate the export process const exportBtn = event.target; const originalText = exportBtn.textContent; exportBtn.textContent = 'πŸ“„ Generating PDF...'; exportBtn.disabled = true; setTimeout(() => { exportBtn.textContent = originalText; exportBtn.disabled = false; this.showNotification('PDF would be downloaded in production version', 'success'); }, 2000); } editStrategy() { this.showNotification('Edit mode would enable inline editing of all strategy sections. Demo shows UI flow.', 'info'); this.trackEvent('strategy_edit_mode'); // In production, this would enable contenteditable on strategy sections const sections = document.querySelectorAll('.strategy-section'); sections.forEach(section => { section.style.border = '2px dashed var(--accent-primary)'; section.style.cursor = 'pointer'; }); setTimeout(() => { sections.forEach(section => { section.style.border = '1px solid var(--glass-border)'; section.style.cursor = 'default'; }); }, 3000); } showNotification(message, type = 'info') { const notification = document.createElement('div'); notification.className = `notification notification-${type}`; const colors = { success: 'var(--success)', warning: 'var(--warning)', error: 'var(--danger)', info: 'var(--accent-primary)' }; notification.style.cssText = ` position: fixed; top: 24px; right: 24px; background: ${colors[type]}; color: white; padding: 16px 24px; border-radius: 12px; font-size: 14px; font-weight: 500; z-index: 1000; max-width: 400px; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: var(--transition); `; notification.textContent = message; document.body.appendChild(notification); // Animate in setTimeout(() => notification.style.transform = 'translateX(0)', 100); // Remove after 5 seconds setTimeout(() => { notification.style.transform = 'translateX(100%)'; setTimeout(() => { if (document.body.contains(notification)) { document.body.removeChild(notification); } }, 300); }, 5000); } trackEvent(eventName, properties = {}) { // Analytics tracking for production console.log('Event tracked:', eventName, properties); // In production, this would integrate with analytics services like: // - Google Analytics 4 // - Mixpanel // - Amplitude // - Custom analytics API } debounce(func, wait) { let timeout; return function executedFunction(...args) { const later = () => { clearTimeout(timeout); func(...args); }; clearTimeout(timeout); timeout = setTimeout(later, wait); }; } } // Initialize the application when DOM is loaded document.addEventListener('DOMContentLoaded', () => { window.brandStrategyApp = new BrandStrategyApp(); }); // Global functions for HTML onclick handlers (keeping for compatibility) function login() { window.brandStrategyApp?.login(); } function logout() { window.brandStrategyApp?.logout(); } function startNewStrategy() { window.brandStrategyApp?.startNewStrategy(); } function backToDashboard() { window.brandStrategyApp?.backToDashboard(); } function loadDemoScenario(scenario) { window.brandStrategyApp?.loadDemoScenario(scenario); } function nextStep() { window.brandStrategyApp?.nextStep(); } function previousStep() { window.brandStrategyApp?.previousStep(); } function exportToPDF() { window.brandStrategyApp?.exportToPDF(); } function editStrategy() { window.brandStrategyApp?.editStrategy(); }