<?php
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped,WordPress.Security.EscapeOutput.ExceptionNotEscaped,WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery,PluginCheck.Security.DirectDB.UnescapedDBParameter,WordPress.WP.AlternativeFunctions.file_system_operations_fopen,WordPress.WP.AlternativeFunctions.file_system_operations_fclose,WordPress.WP.AlternativeFunctions.file_system_operations_is_writable,WordPress.WP.AlternativeFunctions.file_system_operations_chmod,WordPress.WP.AlternativeFunctions.file_system_operations_rmdir,WordPress.DateTime.RestrictedFunctions.date_date,WordPress.WP.I18n.NonSingularStringLiteralDomain,WordPress.WP.I18n.MissingTranslatorsComment,WordPress.WP.I18n.MissingArgDomain,WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters,WordPress.WP.EnqueuedResources.NonEnqueuedScript,WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet -- WordPress.org PCP audit pass: legacy controlled-beta surfaces require targeted follow-up hardening.
// If this file is called directly, abort.
if (!defined('WPINC')) {
    die;
}

// Add completion page specific styles
?>
<!-- Local/system font stack only (no external font providers). -->

<style>
/* Completion Page Styles */
.aysa-completion-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: #ffffff;
    min-height: calc(100vh - 100px);
}

/* Header Section */
.aysa-completion-header {
    text-align: center;
    margin-bottom: 48px;
    padding: 32px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #2c3e50;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border: 1px solid #dee2e6;
}

.aysa-success-icon {
    width: 80px;
    height: 80px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    animation: aysa-bounce 2s infinite;
    border: 3px solid #495057;
    box-shadow: 0 4px 12px rgba(73, 80, 87, 0.3);
}

.aysa-success-icon .dashicons {
    font-size: 40px;
    width: 40px;
    height: 40px;
    color: #495057;
}

.aysa-completion-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 16px 0;
    color: #2c3e50;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.aysa-completion-subtitle {
    font-size: 1.2rem;
    margin: 0;
    color: #6c757d;
    line-height: 1.5;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Grid Layout */
.aysa-completion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 48px;
}

.aysa-completion-grid .aysa-primary-card {
    grid-column: 1 / -1;
}

/* Card Styles */
.aysa-completion-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aysa-completion-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.aysa-card-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.aysa-card-header .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #495057;
}

.aysa-card-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.aysa-card-content {
    padding: 24px;
}

/* Next Steps */
.aysa-next-step {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    align-items: flex-start;
}

.aysa-next-step:last-child {
    margin-bottom: 0;
}

.aysa-step-number {
    width: 32px;
    height: 32px;
    background: #495057;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    margin-top: 4px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.aysa-step-content h3 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.aysa-step-content p {
    margin: 0 0 16px 0;
    color: #6c757d;
    line-height: 1.5;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Feature Grid */
.aysa-feature-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.aysa-feature-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.aysa-feature-icon {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #495057;
    flex-shrink: 0;
    margin-top: 2px;
}

.aysa-feature-content h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.aysa-feature-content p {
    margin: 0;
    color: #6c757d;
    font-size: 0.9rem;
    line-height: 1.5;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Monitoring Sections */
.aysa-monitoring-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f0f0f0;
}

.aysa-monitoring-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.aysa-monitoring-section h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.aysa-monitoring-section h4 .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: #495057;
}

.aysa-monitoring-section p {
    margin: 0;
    color: #6c757d;
    line-height: 1.5;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Tips Card */
.aysa-tips-card {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    border-left: 4px solid #ffc107;
}

.aysa-tips-card .aysa-card-header h2 {
    color: #ffffff;
}

.aysa-tips-card .aysa-card-header .dashicons {
    color: #ffffff;
}

.aysa-tip-item {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-start;
}

.aysa-tip-item:last-child {
    margin-bottom: 0;
}

.aysa-tip-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Segoe UI Symbol', 'Android Emoji', 'EmojiSymbols', sans-serif;
    font-style: normal;
    font-weight: normal;
    line-height: 1;
    text-rendering: auto;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
}

.aysa-tip-content {
    color: #ffffff;
    line-height: 1.5;
    font-size: 15px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.aysa-tip-content strong {
    color: #ffffff;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Buttons */
.aysa-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.aysa-btn-primary {
    background: #495057;
    color: white;
}

.aysa-btn-primary:hover {
    background: #343a40;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(73, 80, 87, 0.3);
    color: white;
    text-decoration: none;
}

.aysa-btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.aysa-btn-secondary:hover {
    background: #e9ecef;
    color: #343a40;
    text-decoration: none;
}

.aysa-btn-large {
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Bottom Actions */
.aysa-completion-actions {
    background: white !important;
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.aysa-action-primary {
    margin-bottom: 32px;
}

.aysa-action-primary h3 {
    margin: 0 0 8px 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #000000 !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    text-shadow: none !important;
}

.aysa-action-primary p {
    margin: 0 0 24px 0;
    color: #343a40 !important;
    font-size: 1.1rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.aysa-help-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.aysa-help-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6c757d;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.aysa-help-link:hover {
    color: #495057;
    text-decoration: none;
}

.aysa-help-link .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Light mode specific styles */
@media (prefers-color-scheme: light), (prefers-color-scheme: no-preference) {
    .aysa-action-primary h3 {
        color: #000000 !important;
        text-shadow: none !important;
    }
    
    .aysa-action-primary p {
        color: #343a40 !important;
    }
    
    .aysa-completion-actions {
        background: white !important;
    }
    
    /* Keep tips card dark with light text for contrast */
    .aysa-tips-card {
        background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
    }
    
    .aysa-tips-card .aysa-tip-content {
        color: #ffffff !important;
    }
}

/* Animations */
@keyframes aysa-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .aysa-completion-grid {
        grid-template-columns: 1fr;
    }
    
    .aysa-completion-grid .aysa-primary-card {
        grid-column: 1;
    }
}

@media (max-width: 768px) {
    .aysa-completion-page {
        padding: 24px 16px;
    }
    
    .aysa-completion-header {
        padding: 24px;
    }
    
    .aysa-completion-header h1 {
        font-size: 2rem;
    }
    
    .aysa-completion-subtitle {
        font-size: 1rem;
    }
    
    .aysa-help-links {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }
    
    .aysa-next-step {
        flex-direction: column;
        text-align: center;
    }
    
    .aysa-feature-item,
    .aysa-tip-item {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }
}

/* Force light theme always - no dark mode */
* {
    color-scheme: light only;
}

.aysa-completion-page,
.aysa-completion-card:not(.aysa-tips-card),
.aysa-completion-actions {
    background: #ffffff !important;
    color: #2c3e50 !important;
}

/* Ensure tips card keeps its dark background and light text */
.aysa-tips-card {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
}

.aysa-tips-card .aysa-tip-content {
    color: #ffffff !important;
}

.aysa-tips-card .aysa-tip-content strong {
    color: #ffffff !important;
    font-weight: 700 !important;
}

.aysa-link-disabled {
    color: #bbb !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
    text-decoration: none !important;
    background: none !important;
    opacity: 0.7;
}
.aysa-link-disabled .dashicons {
    color: #bbb !important;
}
.aysa-link-disabled:hover {
    color: #bbb !important;
    text-decoration: none !important;
}
</style>

<div class="aysa-completion-page">
    <!-- Header Section -->
    <div class="aysa-completion-header">
        <div class="aysa-success-icon">
            <span class="dashicons dashicons-yes-alt"></span>
        </div>
        <h1>🎉 Your SEO Profile is Complete!</h1>
        <p class="aysa-completion-subtitle">Aysa is now configured and ready to fully automate your website's SEO — from keyword research and content creation to link building and social signals.</p>
    </div>

    <!-- Main Content Grid -->
    <div class="aysa-completion-grid">
        
        <!-- Next Steps Card -->
        <div class="aysa-completion-card aysa-primary-card">
            <div class="aysa-card-header">
                <span class="dashicons dashicons-list-view"></span>
                <h2>What's Next?</h2>
            </div>
            <div class="aysa-card-content">
                <div class="aysa-next-step">
                    <div class="aysa-step-number">1</div>
                    <div class="aysa-step-content">
                        <h3>Keyword Research & Analysis</h3>
                        <p>Discover high-performing keywords for your niche and analyze competitor strategies to dominate search results.</p>
                        <a href="<?php echo admin_url('admin.php?page=aysa-keyword-discovery'); ?>" class="aysa-btn aysa-btn-primary">
                            <span class="dashicons dashicons-search"></span>
                            Start Keyword Research
                        </a>
                    </div>
                </div>
                
                <div class="aysa-next-step">
                    <div class="aysa-step-number">2</div>
                    <div class="aysa-step-content">
                        <h3>Content Optimization</h3>
                        <p>Optimize your pages, posts, and products with AI-powered suggestions to improve rankings and user experience.</p>
                        <a href="<?php echo admin_url('admin.php?page=aysa-on-page-optimization'); ?>" class="aysa-btn aysa-btn-secondary">
                            <span class="dashicons dashicons-edit"></span>
                            Optimize Content
                        </a>
                    </div>
                </div>
                
                <div class="aysa-next-step">
                    <div class="aysa-step-number">3</div>
                    <div class="aysa-step-content">
                        <h3>Link Building & Off-Page SEO</h3>
                        <p>Build authority through strategic link building, competitor backlink analysis, and off-page optimization tactics.</p>
                        <a href="<?php echo admin_url('admin.php?page=aysa-off-page-optimization'); ?>" class="aysa-btn aysa-btn-secondary">
                            <span class="dashicons dashicons-admin-links"></span>
                            Build Links
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <!-- What Aysa Can Do Card -->
        <div class="aysa-completion-card">
            <div class="aysa-card-header">
                <span class="dashicons dashicons-superhero"></span>
                <h2>What Aysa Can Achieve for You</h2>
            </div>
            <div class="aysa-card-content">
                <div class="aysa-feature-grid">
                    <div class="aysa-feature-item">
                        <span class="aysa-feature-icon dashicons dashicons-chart-line"></span>
                        <div class="aysa-feature-content">
                            <h4>Boost Organic Traffic</h4>
                            <p>AI-powered keyword optimization and content suggestions to improve your search rankings.</p>
                        </div>
                    </div>
                    
                    <div class="aysa-feature-item">
                        <span class="aysa-feature-icon dashicons dashicons-images-alt2"></span>
                        <div class="aysa-feature-content">
                            <h4>Automated Image SEO</h4>
                            <p>Intelligent alt text generation and image optimization using advanced AI vision analysis.</p>
                        </div>
                    </div>
                    
                    <div class="aysa-feature-item">
                        <span class="aysa-feature-icon dashicons dashicons-admin-users"></span>
                        <div class="aysa-feature-content">
                            <h4>Competitor Insights</h4>
                            <p>Analyze competitor strategies, discover keyword gaps, and uncover backlink opportunities.</p>
                        </div>
                    </div>
                    
                    <div class="aysa-feature-item">
                        <span class="aysa-feature-icon dashicons dashicons-admin-tools"></span>
                        <div class="aysa-feature-content">
                            <h4>Technical SEO Fixes</h4>
                            <p>Automatic 404 tracking, redirect management, and technical optimization suggestions.</p>
                        </div>
                    </div>
                    
                    <div class="aysa-feature-item">
                        <span class="aysa-feature-icon dashicons dashicons-performance"></span>
                        <div class="aysa-feature-content">
                            <h4>Real-time Scoring</h4>
                            <p>Get instant SEO scores and optimization feedback as you create and edit content.</p>
                        </div>
                    </div>
                    
                    <div class="aysa-feature-item">
                        <span class="aysa-feature-icon dashicons dashicons-store"></span>
                        <div class="aysa-feature-content">
                            <h4>E-commerce Ready</h4>
                            <p>Specialized WooCommerce integration for product and category optimization.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Monitoring Performance Card -->
        <div class="aysa-completion-card">
            <div class="aysa-card-header">
                <span class="dashicons dashicons-analytics"></span>
                <h2>Monitor Your Performance</h2>
            </div>
            <div class="aysa-card-content">
                <div class="aysa-monitoring-section">
                    <h4><span class="dashicons dashicons-dashboard"></span> Main Dashboard</h4>
                    <p>Your central hub for tracking SEO progress, viewing optimization scores, and getting actionable insights.</p>
                </div>
                
                <div class="aysa-monitoring-section">
                    <h4><span class="dashicons dashicons-bell"></span> Automated Alerts</h4>
                    <p>Get notified about new 404 errors, keyword ranking changes, and optimization opportunities.</p>
                </div>
                
                <div class="aysa-monitoring-section">
                    <h4><span class="dashicons dashicons-calendar-alt"></span> Regular Reports</h4>
                    <p>Receive automated SEO reports showing your progress, improvements, and recommended actions.</p>
                </div>
            </div>
        </div>

        <!-- Quick Tips Card -->
        <div class="aysa-completion-card aysa-tips-card">
            <div class="aysa-card-header">
                <span class="dashicons dashicons-lightbulb"></span>
                <h2>Pro Tips for Success</h2>
            </div>
            <div class="aysa-card-content">
                <div class="aysa-tip-item">
                    <span class="aysa-tip-icon">💡</span>
                    <div class="aysa-tip-content">
                        <strong>Start with High-Impact Pages:</strong> Focus on your most important pages first - homepage, top products, and key service pages.
                    </div>
                </div>
                
                <div class="aysa-tip-item">
                    <span class="aysa-tip-icon">🔄</span>
                    <div class="aysa-tip-content">
                        <strong>Regular Optimization:</strong> Check your dashboard weekly and apply Aysa's suggestions consistently for best results.
                    </div>
                </div>
                
                <div class="aysa-tip-item">
                    <span class="aysa-tip-icon">📊</span>
                    <div class="aysa-tip-content">
                        <strong>Monitor Competitors:</strong> Keep an eye on competitor analysis to stay ahead and discover new opportunities.
                    </div>
                </div>
                
                <div class="aysa-tip-item">
                    <span class="aysa-tip-icon">🚀</span>
                    <div class="aysa-tip-content">
                        <strong>Let Aysa Work for You:</strong> Let Aysa create content, build links, track keyword rankings and continuously monitor and improve your SEO performance automatically.
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Bottom Action Section -->
    <div class="aysa-completion-actions">
        <div class="aysa-action-primary">
            <h3>Ready to Dominate Search Results?</h3>
            <p>Start your SEO journey with AI-powered optimization</p>
            <a href="<?php echo admin_url('admin.php?page=aysa'); ?>" class="aysa-btn aysa-btn-large aysa-btn-primary">
                <span class="dashicons dashicons-performance"></span>
                Launch Aysa Dashboard
            </a>
        </div>
        
        <div class="aysa-action-secondary">
            <div class="aysa-help-links">
                <a href="<?php echo admin_url('admin.php?page=aysa-settings'); ?>" class="aysa-help-link">
                    <span class="dashicons dashicons-admin-settings"></span>
                    Settings & Configuration
                </a>
                <a class="aysa-help-link aysa-link-disabled" tabindex="-1">
                    <span class="dashicons dashicons-sos"></span>
                    Get Support
                </a>
                <a class="aysa-help-link aysa-link-disabled" tabindex="-1">
                    <span class="dashicons dashicons-book-alt"></span>
                    Documentation
                </a>
            </div>
        </div>
    </div>
</div>

<script>
jQuery(document).ready(function($) {
    // Add some interactive elements
    $('.aysa-completion-card').each(function(index) {
        $(this).css('animation-delay', (index * 0.1) + 's');
        $(this).addClass('aysa-card-animate');
    });
    
    // Track completion event (for analytics)
    if (typeof gtag !== 'undefined') {
        gtag('event', 'setup_complete', {
            'event_category': 'onboarding',
            'event_label': 'seo_profile_setup'
        });
    }
});
</script>
