<?php

namespace FleekDash\Services\Dashboard;

/**
 * Dashboard Template Factory
 *
 * Generates pre-configured dashboard templates
 * Extracted from DashboardTemplateService for better organization
 *
 * @package FleekDash\Services\Dashboard
 * @since 2.2.0
 */
class TemplateFactory
{
    /**
     * Get all default dashboard templates
     *
     * @return array Array of template configurations
     */
    public function getDefaultTemplates(): array
    {
        return [
            $this->getFleekDashDefaultTemplate(),
            $this->getEcommerceTemplate(),
            $this->getMarketingTemplate(),
            $this->getContentPerformanceTemplate(),
            $this->getBusinessOverviewTemplate(),
        ];
    }

    /**
     * Get FleekDash default template (detailed version)
     *
     * @return array Template configuration
     */
    public function getFleekDashDefaultTemplate(): array
    {
        return [
            'name' => 'FleekDash Default',
            'description' => 'Default FleekDash dashboard with KPI cards, growth chart, and latest posts grid',
            'category' => 'default',
            'is_default' => 1,
            'is_active' => 1,
            'config' => json_encode([
                'layout' => [
                    'type' => 'grid',
                    'columns' => 12,
                    'rows' => 'auto',
                    'gap' => 6,
                    'containerClass' => 'flex flex-col gap-6 @container'
                ],
                'widgets' => [
                    // Top Row - Stats Cards and Main Chart
                    [
                        'id' => 'stats-cards-container',
                        'type' => 'container',
                        'className' => 'grid gap-6 @5xl:grid-cols-5 @2xl:grid-cols-1 grid-cols-1',
                        'children' => [
                            // Left Side - Stats Cards (2x2 Grid)
                            [
                                'id' => 'stats-cards-grid',
                                'type' => 'container',
                                'className' => '@4xl:col-span-2 grid gap-4 @lg:grid-cols-2 grid-cols-1',
                                'children' => [
                                    // Card 1: Published Content
                                    [
                                        'id' => 'published-content-card',
                                        'type' => 'chart-widget',
                                        'title' => 'Published Content',
                                        'description' => 'Total published content',
                                        'iconName' => 'chart',
                                        'cardSize' => 'default',
                                        'chartType' => 'line',
                                        'compact' => true,
                                        'showCardHeader' => false,
                                        'showGuides' => false,
                                        'showDots' => false,
                                        'strokeWidth' => 2,
                                        'fillColor' => 'var(--color-card-foreground)',
                                        'showYAxis' => false,
                                        'showXAxis' => false,
                                        'showLegend' => false,
                                        'showTimeRangeSelector' => false,
                                        'showHexagonBadge' => false,
                                        'headerSeparator' => false,
                                        'className' => 'h-full flex-1',
                                        'kpiInfo' => [
                                            'value' => '12.5%',
                                            'percentage' => '12.5',
                                            'badgeAttached' => true,
                                            'variationType' => 'positive',
                                            'subtitle' => 'Published Content',
                                            'showSubtitle' => true,
                                            'showVariation' => true
                                        ],
                                        'data' => [
                                            ['date' => '2024-01-01', 'value' => 69700],
                                            ['date' => '2024-01-02', 'value' => 70200],
                                            ['date' => '2024-01-03', 'value' => 69800],
                                            ['date' => '2024-01-04', 'value' => 70500],
                                            ['date' => '2024-01-05', 'value' => 71000]
                                        ]
                                    ],
                                    // Card 2: Users Engagement
                                    [
                                        'id' => 'users-engagement-card',
                                        'type' => 'chart-widget',
                                        'title' => 'Users Engagement',
                                        'description' => 'Total users engagement',
                                        'iconName' => 'chart',
                                        'cardSize' => 'default',
                                        'chartType' => 'line',
                                        'compact' => true,
                                        'showCardHeader' => false,
                                        'showGuides' => false,
                                        'showDots' => false,
                                        'strokeWidth' => 2,
                                        'fillColor' => 'var(--color-card-foreground)',
                                        'showYAxis' => false,
                                        'showXAxis' => false,
                                        'showLegend' => false,
                                        'showTimeRangeSelector' => false,
                                        'showHexagonBadge' => false,
                                        'headerSeparator' => false,
                                        'className' => 'h-full flex-1',
                                        'fill' => false,
                                        'kpiInfo' => [
                                            'value' => '12.5%',
                                            'percentage' => '12.5',
                                            'badgeAttached' => true,
                                            'variationType' => 'positive',
                                            'subtitle' => 'Users Engagement',
                                            'showSubtitle' => true,
                                            'showVariation' => true
                                        ],
                                        'data' => [
                                            ['date' => '2024-01-01', 'value' => 29420],
                                            ['date' => '2024-01-02', 'value' => 29800],
                                            ['date' => '2024-01-03', 'value' => 29500],
                                            ['date' => '2024-01-04', 'value' => 30100],
                                            ['date' => '2024-01-05', 'value' => 30500]
                                        ]
                                    ],
                                    // Card 3: Growth Rate
                                    [
                                        'id' => 'growth-rate-card',
                                        'type' => 'stats-card-with-progress',
                                        'title' => 'Growth Rate',
                                        'value' => '1,836',
                                        'description' => 'Growth Rate',
                                        'goalValue' => '3,000',
                                        'currentProgress' => 61,
                                        'goalRemaining' => '1,164 to Goal',
                                        'changeValue' => '2.2%',
                                        'changeType' => 'negative',
                                        'cardSize' => 'default',
                                        'progressColor' => 'bg-green-500',
                                        'className' => 'h-full flex-1'
                                    ],
                                    // Card 4: New Users
                                    [
                                        'id' => 'new-users-card',
                                        'type' => 'stats-card-with-avatars',
                                        'value' => '6.3k',
                                        'description' => 'New Users',
                                        'changeValue' => '8.3%',
                                        'changeType' => 'positive',
                                        'avatarGroupTitle' => "Today's Heroes",
                                        'avatars' => [
                                            ['fallback' => 'S', 'className' => 'bg-green-500 text-white'],
                                            ['src' => 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200&h=200&fit=crop&crop=face'],
                                            ['fallback' => 'A', 'className' => 'bg-blue-500 text-white'],
                                            ['src' => 'https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=200&h=200&fit=crop&crop=face'],
                                            ['fallback' => '+42', 'className' => 'bg-purple-500 text-white']
                                        ],
                                        'maxVisible' => 6,
                                        'avatarSize' => 'xl',
                                        'cardSize' => 'default',
                                        'badgeAttached' => true,
                                        'className' => 'h-full flex-1'
                                    ]
                                ]
                            ],
                            // Right Side - Main Chart
                            [
                                'id' => 'growth-evolution-chart',
                                'type' => 'chart-widget',
                                'title' => 'Growth Evolution',
                                'description' => '+20.1% from last period',
                                'chartType' => 'area',
                                'yKeys' => ['current', 'previous'],
                                'height' => 300,
                                'showGuides' => true,
                                'showLegend' => false,
                                'showTooltip' => true,
                                'showXAxis' => true,
                                'showYAxis' => true,
                                'showTimeRangeSelector' => true,
                                'exportable' => true,
                                'loading' => false,
                                'compact' => false,
                                'smoothCurves' => false,
                                'showDots' => false,
                                'dotColors' => ['#009DFF', '#ff6b35'],
                                'horizontalGradient' => false,
                                'glowEffect' => true,
                                'glowColor' => '#f1c9ff',
                                'glowIntensity' => 'none',
                                'glowPulse' => false,
                                'simulateTimeRangeData' => true,
                                'usePrimaryColors' => false,
                                'cardSize' => 'default',
                                'cardVariant' => 'default',
                                'cardInteractive' => 'none',
                                'cardStatus' => 'default',
                                'disabled' => false,
                                'collapsible' => false,
                                'forceDark' => true,
                                'customGradient' => false,
                                'customGradientColor1' => '#45057c',
                                'customGradientColor2' => '#3f144c',
                                'gradientBackground' => 'grad-cosmic-01',
                                'strokeWidth' => 2,
                                'fillOpacity' => 0.5,
                                'fillColor' => '#ffffff',
                                'headerSeparator' => false,
                                'useDateRangeCalendar' => true,
                                'className' => '@4xl:col-span-3',
                                'defaultDateRange' => [
                                    'from' => '30d-ago',
                                    'to' => 'today'
                                ]
                            ]
                        ]
                    ],
                    // Bottom Row - Latest Posts Grid
                    [
                        'id' => 'latest-posts-card',
                        'type' => 'card',
                        'className' => '',
                        'header' => [
                            'title' => 'Latest Posts',
                            'description' => 'Quick approve or reject posts here.',
                            'actions' => [
                                [
                                    'type' => 'button',
                                    'variant' => 'secondary',
                                    'size' => 'sm',
                                    'successText' => 'Approved',
                                    'icon' => 'check',
                                    'text' => 'Approve All'
                                ],
                                [
                                    'type' => 'button',
                                    'variant' => 'secondary',
                                    'size' => 'sm',
                                    'successText' => 'Rejected',
                                    'icon' => 'close',
                                    'text' => 'Reject All'
                                ]
                            ]
                        ],
                        'content' => [
                            'type' => 'grid-posts',
                            'className' => 'h-[400px]',
                            'config' => [
                                'postType' => 'all',
                                'postTypeLabel' => 'Latest Posts',
                                'enableVirtualization' => false,
                                'emptyStateTitle' => 'No posts found',
                                'emptyStateDescription' => 'There are no recent posts to display.',
                                'customColumns' => [['id' => 'category', 'visible' => false]],
                                'hideHeader' => true,
                                'enableResponsiveColumns' => true,
                                'limit' => 5,
                                'orderby' => 'date',
                                'order' => 'desc'
                            ]
                        ]
                    ]
                ],
                'filters' => [
                    'timeRange' => '30d',
                    'sources' => ['wordpress'],
                    'categories' => ['content', 'users', 'analytics']
                ],
                'metadata' => [
                    'version' => '1.0',
                    'created' => '2024-01-01',
                    'author' => 'FleekDash',
                    'description' => 'Default FleekDash dashboard layout with KPI cards, growth chart, and latest posts grid'
                ]
            ])
        ];
    }

    /**
     * Get E-commerce template
     *
     * @return array Template configuration
     */
    private function getEcommerceTemplate(): array
    {
        return [
            'name' => 'E-commerce Overview',
            'description' => 'Complete e-commerce dashboard with sales, orders, and customer metrics',
            'category' => 'ecommerce',
            'is_default' => 0,
            'is_active' => 1,
            'config' => json_encode([
                'widgets' => [
                    [
                        'id' => 'revenue-overview',
                        'type' => 'chart',
                        'title' => 'Revenue Overview',
                        'metric' => 'revenue',
                        'category' => 'sales',
                        'chartType' => 'area',
                        'timeRange' => '30d',
                        'position' => ['x' => 0, 'y' => 0, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'orders-summary',
                        'type' => 'chart',
                        'title' => 'Orders Summary',
                        'metric' => 'orders',
                        'category' => 'sales',
                        'chartType' => 'bar',
                        'timeRange' => '30d',
                        'position' => ['x' => 6, 'y' => 0, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'top-products',
                        'type' => 'chart',
                        'title' => 'Top Products',
                        'metric' => 'product_performance',
                        'category' => 'sales',
                        'chartType' => 'bar',
                        'timeRange' => '30d',
                        'position' => ['x' => 0, 'y' => 4, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'customer-metrics',
                        'type' => 'chart',
                        'title' => 'Customer Metrics',
                        'metric' => 'customer_engagement',
                        'category' => 'users',
                        'chartType' => 'line',
                        'timeRange' => '30d',
                        'position' => ['x' => 6, 'y' => 4, 'w' => 6, 'h' => 4]
                    ]
                ],
                'filters' => [
                    'timeRange' => '30d',
                    'sources' => ['woocommerce', 'wordpress'],
                    'categories' => ['sales', 'users']
                ]
            ])
        ];
    }

    /**
     * Get Marketing template
     *
     * @return array Template configuration
     */
    private function getMarketingTemplate(): array
    {
        return [
            'name' => 'Marketing Analytics',
            'description' => 'Marketing-focused dashboard with traffic, conversions, and campaign metrics',
            'category' => 'marketing',
            'is_default' => 0,
            'is_active' => 1,
            'config' => json_encode([
                'widgets' => [
                    [
                        'id' => 'traffic-overview',
                        'type' => 'chart',
                        'title' => 'Traffic Overview',
                        'metric' => 'unique_visitors',
                        'category' => 'traffic',
                        'chartType' => 'area',
                        'timeRange' => '30d',
                        'position' => ['x' => 0, 'y' => 0, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'conversion-rate',
                        'type' => 'chart',
                        'title' => 'Conversion Rate',
                        'metric' => 'conversion_rate',
                        'category' => 'sales',
                        'chartType' => 'line',
                        'timeRange' => '30d',
                        'position' => ['x' => 6, 'y' => 0, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'traffic-sources',
                        'type' => 'chart',
                        'title' => 'Traffic Sources',
                        'metric' => 'referrers',
                        'category' => 'traffic',
                        'chartType' => 'bar',
                        'timeRange' => '30d',
                        'position' => ['x' => 0, 'y' => 4, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'campaign-performance',
                        'type' => 'chart',
                        'title' => 'Campaign Performance',
                        'metric' => 'campaign_metrics',
                        'category' => 'marketing',
                        'chartType' => 'bar',
                        'timeRange' => '30d',
                        'position' => ['x' => 6, 'y' => 4, 'w' => 6, 'h' => 4]
                    ]
                ],
                'filters' => [
                    'timeRange' => '30d',
                    'sources' => ['google_analytics', 'wordpress', 'facebook'],
                    'categories' => ['traffic', 'sales', 'marketing']
                ]
            ])
        ];
    }

    /**
     * Get Content Performance template
     *
     * @return array Template configuration
     */
    private function getContentPerformanceTemplate(): array
    {
        return [
            'name' => 'Content Performance',
            'description' => 'Content-focused dashboard with post performance and engagement metrics',
            'category' => 'content',
            'is_default' => 0,
            'is_active' => 1,
            'config' => json_encode([
                'widgets' => [
                    [
                        'id' => 'popular-posts',
                        'type' => 'chart',
                        'title' => 'Popular Posts',
                        'metric' => 'popular_posts',
                        'category' => 'content',
                        'chartType' => 'bar',
                        'timeRange' => '30d',
                        'position' => ['x' => 0, 'y' => 0, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'content-engagement',
                        'type' => 'chart',
                        'title' => 'Content Engagement',
                        'metric' => 'content_engagement',
                        'category' => 'content',
                        'chartType' => 'line',
                        'timeRange' => '30d',
                        'position' => ['x' => 6, 'y' => 0, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'user-comments',
                        'type' => 'chart',
                        'title' => 'User Comments',
                        'metric' => 'comments',
                        'category' => 'content',
                        'chartType' => 'area',
                        'timeRange' => '30d',
                        'position' => ['x' => 0, 'y' => 4, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'social-shares',
                        'type' => 'chart',
                        'title' => 'Social Shares',
                        'metric' => 'social_shares',
                        'category' => 'content',
                        'chartType' => 'bar',
                        'timeRange' => '30d',
                        'position' => ['x' => 6, 'y' => 4, 'w' => 6, 'h' => 4]
                    ]
                ],
                'filters' => [
                    'timeRange' => '30d',
                    'sources' => ['wordpress', 'social_media'],
                    'categories' => ['content']
                ]
            ])
        ];
    }

    /**
     * Get Business Overview template
     *
     * @return array Template configuration
     */
    private function getBusinessOverviewTemplate(): array
    {
        return [
            'name' => 'Business Overview',
            'description' => 'General business dashboard with key performance indicators',
            'category' => 'business',
            'is_default' => 1,
            'is_active' => 1,
            'config' => json_encode([
                'widgets' => [
                    [
                        'id' => 'revenue-trends',
                        'type' => 'chart',
                        'title' => 'Revenue Trends',
                        'metric' => 'revenue',
                        'category' => 'sales',
                        'chartType' => 'area',
                        'timeRange' => '30d',
                        'position' => ['x' => 0, 'y' => 0, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'user-growth',
                        'type' => 'chart',
                        'title' => 'User Growth',
                        'metric' => 'new_users',
                        'category' => 'users',
                        'chartType' => 'line',
                        'timeRange' => '30d',
                        'position' => ['x' => 6, 'y' => 0, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'traffic-overview',
                        'type' => 'chart',
                        'title' => 'Traffic Overview',
                        'metric' => 'unique_visitors',
                        'category' => 'traffic',
                        'chartType' => 'area',
                        'timeRange' => '30d',
                        'position' => ['x' => 0, 'y' => 4, 'w' => 6, 'h' => 4]
                    ],
                    [
                        'id' => 'content-performance',
                        'type' => 'chart',
                        'title' => 'Content Performance',
                        'metric' => 'content_engagement',
                        'category' => 'content',
                        'chartType' => 'bar',
                        'timeRange' => '30d',
                        'position' => ['x' => 6, 'y' => 4, 'w' => 6, 'h' => 4]
                    ]
                ],
                'filters' => [
                    'timeRange' => '30d',
                    'sources' => ['wordpress', 'woocommerce', 'google_analytics'],
                    'categories' => ['sales', 'users', 'traffic', 'content']
                ]
            ])
        ];
    }

    /**
     * Get simple template for get_templates() method
     *
     * @return array Simple template structure
     */
    public function getSimpleFleekDashTemplate(): array
    {
        return [
            'id' => 'fleekdash-default',
            'name' => 'FleekDash Default',
            'description' => 'Default dashboard layout with KPI cards and analytics charts',
            'category' => 'general',
            'version' => '1.0.0',
            'author' => 'FleekDash',
            'created' => '2024-01-01',
            'layout' => [
                'type' => 'grid',
                'columns' => 12,
                'rows' => 'auto',
                'gap' => 6,
                'containerClass' => 'grid gap-6'
            ],
            'widgets' => [
                [
                    'id' => 'kpi-1',
                    'type' => 'kpi',
                    'title' => 'Total Visitors',
                    'value' => '12,345',
                    'change' => '+20.1%',
                    'period' => 'from last month',
                    'position' => ['x' => 0, 'y' => 0, 'w' => 3, 'h' => 1]
                ],
                [
                    'id' => 'kpi-2',
                    'type' => 'kpi',
                    'title' => 'Page Views',
                    'value' => '45,678',
                    'change' => '+15.3%',
                    'period' => 'from last month',
                    'position' => ['x' => 3, 'y' => 0, 'w' => 3, 'h' => 1]
                ],
                [
                    'id' => 'kpi-3',
                    'type' => 'kpi',
                    'title' => 'Bounce Rate',
                    'value' => '23.4%',
                    'change' => '-2.1%',
                    'period' => 'from last month',
                    'position' => ['x' => 6, 'y' => 0, 'w' => 3, 'h' => 1]
                ],
                [
                    'id' => 'kpi-4',
                    'type' => 'kpi',
                    'title' => 'Avg. Session',
                    'value' => '2m 34s',
                    'change' => '+12.5%',
                    'period' => 'from last month',
                    'position' => ['x' => 9, 'y' => 0, 'w' => 3, 'h' => 1]
                ],
                [
                    'id' => 'chart-1',
                    'type' => 'chart',
                    'title' => 'Visitors Over Time',
                    'description' => 'Unique visitors and page views for the selected period',
                    'chartType' => 'area',
                    'data' => [
                        ['date' => '2024-01-01', 'visitors' => 120, 'pageviews' => 450],
                        ['date' => '2024-01-02', 'visitors' => 135, 'pageviews' => 520],
                        ['date' => '2024-01-03', 'visitors' => 142, 'pageviews' => 580],
                        ['date' => '2024-01-04', 'visitors' => 128, 'pageviews' => 490],
                        ['date' => '2024-01-05', 'visitors' => 156, 'pageviews' => 620],
                        ['date' => '2024-01-06', 'visitors' => 168, 'pageviews' => 680],
                        ['date' => '2024-01-07', 'visitors' => 145, 'pageviews' => 550]
                    ],
                    'yKeys' => ['visitors', 'pageviews'],
                    'position' => ['x' => 0, 'y' => 1, 'w' => 8, 'h' => 2]
                ],
                [
                    'id' => 'chart-2',
                    'type' => 'chart',
                    'title' => 'Popular Posts',
                    'description' => 'Most viewed posts in the selected period',
                    'chartType' => 'bar',
                    'data' => [
                        ['date' => 'Post 1', 'views' => 1250],
                        ['date' => 'Post 2', 'views' => 980],
                        ['date' => 'Post 3', 'views' => 850],
                        ['date' => 'Post 4', 'views' => 720],
                        ['date' => 'Post 5', 'views' => 680],
                        ['date' => 'Post 6', 'views' => 620],
                        ['date' => 'Post 7', 'views' => 580],
                        ['date' => 'Post 8', 'views' => 520]
                    ],
                    'yKeys' => ['views'],
                    'position' => ['x' => 8, 'y' => 1, 'w' => 4, 'h' => 2]
                ]
            ],
            'filters' => [
                'timeRange' => '30d',
                'sources' => ['wordpress'],
                'categories' => ['all']
            ],
            'metadata' => [
                'version' => '1.0.0',
                'created' => '2024-01-01',
                'author' => 'FleekDash',
                'description' => 'Default dashboard layout with KPI cards and analytics charts'
            ]
        ];
    }

    /**
     * Get Analytics Focus template
     *
     * @return array Template configuration
     */
    public function getAnalyticsFocusTemplate(): array
    {
        return [
            'id' => 'analytics-focus',
            'name' => 'Analytics Focus',
            'description' => 'Comprehensive analytics dashboard with detailed metrics and real-time data',
            'category' => 'analytics',
            'version' => '1.0.0',
            'author' => 'FleekDash',
            'created' => '2024-01-01',
            'layout' => [
                'type' => 'grid',
                'columns' => 12,
                'rows' => 'auto',
                'gap' => 6,
                'containerClass' => 'grid gap-6'
            ],
            'widgets' => [
                [
                    'id' => 'kpi-1',
                    'type' => 'kpi',
                    'title' => 'Unique Visitors',
                    'value' => '8,234',
                    'change' => '+12.5%',
                    'period' => 'from last week',
                    'position' => ['x' => 0, 'y' => 0, 'w' => 3, 'h' => 1]
                ],
                [
                    'id' => 'kpi-2',
                    'type' => 'kpi',
                    'title' => 'Page Views',
                    'value' => '32,156',
                    'change' => '+8.2%',
                    'period' => 'from last week',
                    'position' => ['x' => 3, 'y' => 0, 'w' => 3, 'h' => 1]
                ],
                [
                    'id' => 'kpi-3',
                    'type' => 'kpi',
                    'title' => 'Bounce Rate',
                    'value' => '18.7%',
                    'change' => '-3.2%',
                    'period' => 'from last week',
                    'position' => ['x' => 6, 'y' => 0, 'w' => 3, 'h' => 1]
                ],
                [
                    'id' => 'kpi-4',
                    'type' => 'kpi',
                    'title' => 'Avg. Session',
                    'value' => '4m 12s',
                    'change' => '+15.8%',
                    'period' => 'from last week',
                    'position' => ['x' => 9, 'y' => 0, 'w' => 3, 'h' => 1]
                ],
                [
                    'id' => 'chart-1',
                    'type' => 'chart',
                    'title' => 'Visitor Analytics',
                    'description' => 'Detailed visitor and page view analytics over time',
                    'chartType' => 'area',
                    'data' => [
                        ['date' => '2024-01-01', 'visitors' => 180, 'pageviews' => 650],
                        ['date' => '2024-01-02', 'visitors' => 195, 'pageviews' => 720],
                        ['date' => '2024-01-03', 'visitors' => 202, 'pageviews' => 780],
                        ['date' => '2024-01-04', 'visitors' => 188, 'pageviews' => 690],
                        ['date' => '2024-01-05', 'visitors' => 216, 'pageviews' => 820],
                        ['date' => '2024-01-06', 'visitors' => 228, 'pageviews' => 880],
                        ['date' => '2024-01-07', 'visitors' => 205, 'pageviews' => 750]
                    ],
                    'yKeys' => ['visitors', 'pageviews'],
                    'position' => ['x' => 0, 'y' => 1, 'w' => 8, 'h' => 2]
                ],
                [
                    'id' => 'realtime-1',
                    'type' => 'realtime',
                    'title' => 'Real-time Activity',
                    'description' => 'Current active visitors and recent activity',
                    'data' => [
                        'active_visitors' => 23,
                        'recent_pageviews' => [
                            ['page' => '/home', 'timestamp' => '2024-01-07T10:30:00Z'],
                            ['page' => '/about', 'timestamp' => '2024-01-07T10:28:00Z'],
                            ['page' => '/contact', 'timestamp' => '2024-01-07T10:25:00Z']
                        ]
                    ],
                    'position' => ['x' => 8, 'y' => 1, 'w' => 4, 'h' => 2]
                ]
            ],
            'filters' => [
                'timeRange' => '30d',
                'sources' => ['wordpress', 'analytics'],
                'categories' => ['all']
            ],
            'metadata' => [
                'version' => '1.0.0',
                'created' => '2024-01-01',
                'author' => 'FleekDash',
                'description' => 'Comprehensive analytics dashboard with detailed metrics and real-time data'
            ]
        ];
    }
}
