<?php
// phpcs:ignoreFile WordPress.NamingConventions.PrefixAllGlobals
 defined( 'ABSPATH' ) || exit; ?>

<div class="wrap zs-seo-wrap">
    <div class="zs-seo-header">
        <div class="zs-seo-logo">
            <span class="zs-seo-logo-icon">⚡</span>
            <h1>ZS_SEO</h1>
            <span class="zs-seo-version">v<?php echo esc_html( ZS_SEO_VERSION ); ?></span>
        </div>
        <p class="zs-seo-tagline"><?php esc_html_e('Complete SEO + GEO Optimization — Developer Edition', 'zs-seo-audit-optimization'); ?></p>
    </div>

    <!-- Quick Stats -->
    <div class="zs-seo-cards">
        <?php
        $total_posts = wp_count_posts( 'post' );
        $total_pages = wp_count_posts( 'page' );
        $published   = ( $total_posts->publish ?? 0 ) + ( $total_pages->publish ?? 0 );
        global $wpdb;
        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
        $redirect_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}zs_seo_redirects" );
        ?>
        <div class="zs-seo-card">
            <div class="zs-seo-card-icon">📄</div>
            <div class="zs-seo-card-data">
                <span class="zs-seo-card-number"><?php echo esc_html( $published ); ?></span>
                <span class="zs-seo-card-label"><?php esc_html_e('Published Pages', 'zs-seo-audit-optimization'); ?></span>
            </div>
        </div>
        <div class="zs-seo-card">
            <div class="zs-seo-card-icon">🔀</div>
            <div class="zs-seo-card-data">
                <span class="zs-seo-card-number"><?php echo esc_html( $redirect_count ?: 0 ); ?></span>
                <span class="zs-seo-card-label"><?php esc_html_e('Redirects', 'zs-seo-audit-optimization'); ?></span>
            </div>
        </div>
        <div class="zs-seo-card">
            <div class="zs-seo-card-icon">🤖</div>
            <div class="zs-seo-card-data">
                <span class="zs-seo-card-number">GEO</span>
                <span class="zs-seo-card-label"><?php esc_html_e('AI Search Ready', 'zs-seo-audit-optimization'); ?></span>
            </div>
        </div>
        <div class="zs-seo-card">
            <div class="zs-seo-card-icon">✅</div>
            <div class="zs-seo-card-data">
                <span class="zs-seo-card-number"><?php echo zs_seo_is_pro() ? 'Pro ⚡' : 'Free'; ?></span>
                <span class="zs-seo-card-label">
                    <?php if ( zs_seo_is_pro() ) : ?>
                        <?php esc_html_e('All features unlocked', 'zs-seo-audit-optimization'); ?>
                    <?php else : ?>
                        <a href="<?php echo esc_url( admin_url( 'admin.php?page=zs-seo-pricing' ) ); ?>" style="color:var(--zen-primary);font-weight:600;">
                            ⚡ <?php esc_html_e('Upgrade to Pro', 'zs-seo-audit-optimization'); ?>
                        </a>
                    <?php endif; ?>
                </span>
            </div>
        </div>
    </div>

    <!-- Site-wide Audit -->
    <div class="zs-seo-box">
        <h2>🔍 <?php esc_html_e('Site-wide SEO Audit', 'zs-seo-audit-optimization'); ?></h2>
        <p><?php esc_html_e('Scan all published posts and pages for SEO issues.', 'zs-seo-audit-optimization'); ?></p>
        <button type="button" id="zs-seo-scan-all" class="button button-primary button-large">
            🚀 <?php esc_html_e('Scan All Pages', 'zs-seo-audit-optimization'); ?>
        </button>
        <div id="zs-seo-scan-results" style="margin-top:20px;"></div>
    </div>

    <!-- Feature Overview -->
    <div class="zs-seo-box">
        <h2>⚡ <?php esc_html_e('What ZS_SEO Covers', 'zs-seo-audit-optimization'); ?></h2>
        <div class="zs-seo-features-grid">
            <div class="zs-seo-feature">
                <span class="dashicons dashicons-editor-ol"></span>
                <h4><?php esc_html_e('Heading Structure', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('H1–H6 order, duplicate H1 detection, skipped levels.', 'zs-seo-audit-optimization'); ?></p>
            </div>
            <div class="zs-seo-feature">
                <span class="dashicons dashicons-tag"></span>
                <h4><?php esc_html_e('Meta Tags', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('SEO title, meta description, OG tags, Twitter cards.', 'zs-seo-audit-optimization'); ?></p>
            </div>
            <div class="zs-seo-feature">
                <span class="dashicons dashicons-format-image"></span>
                <h4><?php esc_html_e('Image Audit', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('Alt text, PNG→WebP suggestion, lazy load, CLS check.', 'zs-seo-audit-optimization'); ?></p>
            </div>
            <div class="zs-seo-feature">
                <span class="dashicons dashicons-performance"></span>
                <h4><?php esc_html_e('Performance Hints', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('LCP, CLS, preload hints, iframe count warnings.', 'zs-seo-audit-optimization'); ?></p>
            </div>
            <div class="zs-seo-feature">
                <span class="dashicons dashicons-universal-access"></span>
                <h4><?php esc_html_e('Accessibility', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('Aria labels, empty links, button text, table scope.', 'zs-seo-audit-optimization'); ?></p>
            </div>
            <div class="zs-seo-feature">
                <span class="dashicons dashicons-superhero"></span>
                <h4><?php esc_html_e('GEO / AI Search', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('FAQ schema, JSON-LD for ChatGPT, Gemini, AI Overview.', 'zs-seo-audit-optimization'); ?></p>
            </div>
            <div class="zs-seo-feature">
                <span class="dashicons dashicons-randomize"></span>
                <h4><?php esc_html_e('Redirects Manager', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('301/302 redirects with hit counter tracking.', 'zs-seo-audit-optimization'); ?></p>
            </div>
            <div class="zs-seo-feature">
                <span class="dashicons dashicons-share"></span>
                <h4><?php esc_html_e('Schema Markup', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('Article, WebSite, Organization, Breadcrumb, FAQ.', 'zs-seo-audit-optimization'); ?></p>
            </div>
        </div>
    </div>
</div>
