<?php
/**
 * Blog Over — Admin Dashboard Page Template
 *
 * Premium two-column layout with gradient banner, comparison table,
 * quick-action sidebar, theme info, rating CTA, and support links.
 *
 * @package Blog_Over
 * @since   1.4.0
 */

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

$theme = wp_get_theme();
?>
<div class="blog-over-dashboard">

    <!-- ===== Gradient Banner ===== -->
    <div class="blog-over-dash-banner">
        <div class="blog-over-dash-banner-inner">
            <div class="blog-over-dash-banner-text">
                <h1><?php esc_html_e('Welcome to Blog Over!', 'blog-over'); ?></h1>
                <p><?php esc_html_e('Thank you for choosing our theme. Unlock all features with Premium!', 'blog-over'); ?>
                </p>
            </div>
            <div class="blog-over-dash-banner-actions">
                <a href="<?php echo esc_url(admin_url('customize.php')); ?>"
                    class="blog-over-dash-btn blog-over-dash-btn-banner">
                    <span class="dashicons dashicons-admin-customizer"></span>
                    <?php esc_html_e('Customize', 'blog-over'); ?>
                </a>
                <a href="https://awplife.com/demo/blog-over/" class="blog-over-dash-btn blog-over-dash-btn-banner"
                    target="_blank" rel="noopener noreferrer">
                    <span class="dashicons dashicons-visibility"></span>
                    <?php esc_html_e('Live Demo', 'blog-over'); ?>
                </a>
                <a href="https://awplife.com/wordpress-themes/blog-over/"
                    class="blog-over-dash-btn blog-over-dash-btn-upgrade" target="_blank" rel="noopener noreferrer">
                    <span class="dashicons dashicons-star-filled"></span>
                    <?php esc_html_e('Upgrade to Premium', 'blog-over'); ?>
                </a>
            </div>
        </div>
    </div>

    <!-- ===== Two-Column Body ===== -->
    <div class="blog-over-dash-body">

        <!-- Left Column: Comparison Table -->
        <div class="blog-over-dash-main">
            <div class="blog-over-dash-card">
                <h2 class="blog-over-dash-card-title">
                    <span class="dashicons dashicons-star-filled blog-over-dash-icon-accent"></span>
                    <?php esc_html_e('Free vs Premium Features', 'blog-over'); ?>
                </h2>

                <table class="blog-over-dash-table">
                    <thead>
                        <tr>
                            <th class="blog-over-dash-th-feature"><?php esc_html_e('Feature', 'blog-over'); ?></th>
                            <th class="blog-over-dash-th-free"><?php esc_html_e('Free', 'blog-over'); ?></th>
                            <th class="blog-over-dash-th-pro"><?php esc_html_e('Premium', 'blog-over'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $features = array(
                            // Frontpage
                            array( 'dashicons-sort', __( 'Drag & Drop Homepage Sections', 'blog-over' ), false, 'Reorder Everything!' ),
                            // Header & Menu
                            array( 'dashicons-megaphone', __( 'Announcement Bars', 'blog-over' ), 'Max 1 Bar', 'Unlimited + Layouts' ),
                            array( 'dashicons-minus', __( 'Top Bar Layouts', 'blog-over' ), '1 Layout', '2 Layouts' ),
                            array( 'dashicons-admin-appearance', __( 'Menu Layout Styles', 'blog-over' ), '1 Layout', '4 Layouts (inc. Minimal)' ),
                            array( 'dashicons-sticky', __( 'Sticky Header', 'blog-over' ), false, true ),
                            array( 'dashicons-slides', __( 'Menu Hover Effects', 'blog-over' ), false, true ),
                            array( 'dashicons-animation', __( 'Submenu Animations', 'blog-over' ), false, true ),
                            array( 'dashicons-search', __( 'Search Styles', 'blog-over' ), '1 Style', '4 Styles' ),
                            // Ticker
                            array( 'dashicons-rss', __( 'News Ticker Sources', 'blog-over' ), 'Latest Posts', '+ Category Filter' ),
                            array( 'dashicons-editor-insertmore', __( 'Ticker Layouts', 'blog-over' ), '1 Style', '5 Styles' ),
                            array( 'dashicons-leftright', __( 'Ticker Scroll Direction', 'blog-over' ), 'Left Only', 'Left + Right' ),
                            // Hero
                            array( 'dashicons-format-gallery', __( 'Hero Slide Effects', 'blog-over' ), '1 Effect', '3 Effects' ),
                            // Featured Links
                            array( 'dashicons-grid-view', __( 'Featured Links Layouts', 'blog-over' ), '3 Layouts', '4 Layouts' ),
                            array( 'dashicons-star-empty', __( 'Featured Links Limit', 'blog-over' ), '4 Links', '8 Links' ),
                            // Feature Story
                            array( 'dashicons-video-alt3', __( 'Feature Story Media', 'blog-over' ), 'Post Image Only', 'Image + Video Embeds' ),
                            // Tabbed Magazine
                            array( 'dashicons-category', __( 'Tabbed Magazine Max Tabs', 'blog-over' ), 'Max 3 Tabs', 'Max 15 Tabs' ),
                            array( 'dashicons-images-alt2', __( 'Tabbed Magazine Card Styles', 'blog-over' ), '1 Style', '3 Styles' ),
                            array( 'dashicons-table-row-after', __( 'Tabbed Magazine Grid Columns', 'blog-over' ), 'Fixed 2-Col', '2, 3 or 4 Cols' ),
                            array( 'dashicons-align-center', __( 'Tabbed Magazine Tabs Position', 'blog-over' ), false, true ),
                            // You Missed
                            array( 'dashicons-hidden', __( 'You Missed Layouts', 'blog-over' ), '1 Layout', '3 Layouts' ),
                            array( 'dashicons-columns', __( 'You Missed Column Options', 'blog-over' ), '4 Columns', '2, 3, 4 or 6 Cols' ),
                            // Trending Posts
                            array( 'dashicons-chart-line', __( 'Trending Posts Layouts', 'blog-over' ), '1 Layout', '3 Layouts (Grid/Strip)' ),
                            array( 'dashicons-filter', __( 'Trending Sorting & Period', 'blog-over' ), false, 'Views/Random/Recent' ),
                            // Newsletter / CTA
                            array( 'dashicons-email-alt', __( 'Newsletter/CTA Styles', 'blog-over' ), '1 Layout', '5 Layouts (Glass/Split)' ),
                            // Category Showcase
                            array( 'dashicons-networking', __( 'Category Showcase Layouts', 'blog-over' ), '1 Layout', '6 Layouts (Masonry/List)' ),
                            array( 'dashicons-marker', __( 'Category Custom Icons', 'blog-over' ), false, true ),
                            // Advertisement
                            array( 'dashicons-megaphone', __( 'Advertisement Banners', 'blog-over' ), '1 Basic Banner', 'Unlimited + 6 Layouts' ),
                            array( 'dashicons-editor-code', __( 'Google AdSense / HTML Ads', 'blog-over' ), false, true ),
                            array( 'dashicons-visibility', __( 'Ad Visibility Rules (per page)', 'blog-over' ), false, true ),
                            // Blog & Post Styles
                            array( 'dashicons-layout', __( 'Blog Listing Styles', 'blog-over' ), '2 Styles', '3+ Styles' ),
                            array( 'dashicons-images-alt', __( 'Blog Image Ratio Options', 'blog-over' ), '2 Ratios', '6 Ratios' ),
                            array( 'dashicons-admin-users', __( 'Author Box Styles', 'blog-over' ), '1 Style', '5 Styles' ),
                            array( 'dashicons-arrow-right-alt', __( 'Post Navigation Styles', 'blog-over' ), '1 Style', '6 Styles' ),
                            array( 'dashicons-admin-post', __( 'Related Posts Filtering', 'blog-over' ), 'Category Only', '5 Filter Options' ),
                            array( 'dashicons-media-document', __( 'Reading Progress Bar', 'blog-over' ), false, true ),
                            array( 'dashicons-clock', __( 'Est. Reading Time', 'blog-over' ), false, true ),
                            array( 'dashicons-share', __( 'Floating Social Share', 'blog-over' ), false, true ),
                            // Sidebar & UI
                            array( 'dashicons-heading', __( 'Widget Title Styles', 'blog-over' ), '1 Style', '5 Styles' ),
                            array( 'dashicons-update', __( 'Loading Screen Animations', 'blog-over' ), '1 Animation', '6 Animations' ),
                            array( 'dashicons-arrow-up-alt2', __( 'Go to Top Icons', 'blog-over' ), '1 Icon', 'Multiple Icons' ),
                            // Support & Extras
                            array( 'dashicons-download', __( 'Pro Demo Templates', 'blog-over' ), '1 Demo', '5+ Demos' ),
                            array( 'dashicons-sos', __( 'Priority Support', 'blog-over' ), false, true ),
                        );

                        $row_idx = 0;
                        foreach ($features as $f):
                            $icon = $f[0];
                            $label = $f[1];
                            $free = $f[2];
                            $pro = $f[3];
                            $row_class = (false === $free && true === $pro) ? ' blog-over-dash-row-pro' : '';
                            ?>
                            <tr class="<?php echo esc_attr($row_class); ?>">
                                <td class="blog-over-dash-td-feature">
                                    <span
                                        class="dashicons <?php echo esc_attr($icon); ?> blog-over-dash-feature-icon"></span>
                                    <?php echo esc_html($label); ?>
                                </td>
                                <td class="blog-over-dash-td-value">
                                    <?php if (true === $free): ?>
                                        <span class="dashicons dashicons-yes-alt blog-over-dash-check"></span>
                                    <?php elseif (false === $free): ?>
                                        <span class="blog-over-dash-dash">&mdash;</span>
                                    <?php else: ?>
                                        <?php echo esc_html($free); ?>
                                    <?php endif; ?>
                                </td>
                                <td class="blog-over-dash-td-value">
                                    <?php if (true === $pro): ?>
                                        <span class="dashicons dashicons-yes-alt blog-over-dash-check"></span>
                                    <?php else: ?>
                                        <?php echo esc_html($pro); ?>
                                    <?php endif; ?>
                                </td>
                            </tr>
                            <?php
                            $row_idx++;
                        endforeach;
                        ?>
                    </tbody>
                </table>

                <div class="blog-over-dash-table-cta">
                    <a href="https://awplife.com/wordpress-themes/blog-over/"
                        class="blog-over-dash-btn blog-over-dash-btn-primary" target="_blank" rel="noopener noreferrer">
                        <span class="dashicons dashicons-star-filled"></span>
                        <?php esc_html_e('Upgrade to Premium', 'blog-over'); ?>
                    </a>
                </div>
            </div>
        </div>

        <!-- Right Column: Sidebar widgets -->
        <div class="blog-over-dash-sidebar">

            <!-- Quick Actions -->
            <div class="blog-over-dash-card">
                <h2 class="blog-over-dash-card-title">
                    <span class="dashicons dashicons-admin-tools blog-over-dash-icon-accent"></span>
                    <?php esc_html_e('Quick Actions', 'blog-over'); ?>
                </h2>
                <ul class="blog-over-dash-links">
                    <li>
                        <a href="<?php echo esc_url(admin_url('customize.php')); ?>">
                            <span class="dashicons dashicons-admin-customizer"></span>
                            <?php esc_html_e('Customize Theme', 'blog-over'); ?>
                        </a>
                    </li>
                    <li>
                        <a href="<?php echo esc_url(admin_url('nav-menus.php')); ?>">
                            <span class="dashicons dashicons-menu"></span>
                            <?php esc_html_e('Setup Menus', 'blog-over'); ?>
                        </a>
                    </li>
                    <li>
                        <a href="<?php echo esc_url(admin_url('widgets.php')); ?>">
                            <span class="dashicons dashicons-screenoptions"></span>
                            <?php esc_html_e('Setup Widgets', 'blog-over'); ?>
                        </a>
                    </li>
                    <li>
                        <a href="<?php echo esc_url(admin_url('themes.php?page=blog-over-starter-sites')); ?>">
                            <span class="dashicons dashicons-download"></span>
                            <?php esc_html_e('Import Starter Demo', 'blog-over'); ?>
                        </a>
                    </li>
                    <li>
                        <a href="<?php echo esc_url(home_url('/')); ?>" target="_blank" rel="noopener noreferrer">
                            <span class="dashicons dashicons-admin-site-alt3"></span>
                            <?php esc_html_e('View Your Website', 'blog-over'); ?>
                        </a>
                    </li>
                </ul>
            </div>

            <!-- Theme Info -->
            <div class="blog-over-dash-card">
                <h2 class="blog-over-dash-card-title">
                    <span class="dashicons dashicons-info blog-over-dash-icon-accent"></span>
                    <?php esc_html_e('Theme Info', 'blog-over'); ?>
                </h2>
                <table class="blog-over-dash-info-table">
                    <tr>
                        <td><?php esc_html_e('Version', 'blog-over'); ?></td>
                        <td><?php echo esc_html($theme->get('Version')); ?></td>
                    </tr>
                    <tr>
                        <td><?php esc_html_e('Author', 'blog-over'); ?></td>
                        <td><?php echo esc_html($theme->get('Author')); ?></td>
                    </tr>
                    <tr>
                        <td><?php esc_html_e('Requires WP', 'blog-over'); ?></td>
                        <td><?php echo esc_html($theme->get('RequiresWP') ? $theme->get('RequiresWP') . '+' : '6.0+'); ?>
                        </td>
                    </tr>
                    <tr>
                        <td><?php esc_html_e('Requires PHP', 'blog-over'); ?></td>
                        <td><?php echo esc_html($theme->get('RequiresPHP') ? $theme->get('RequiresPHP') . '+' : '7.4+'); ?>
                        </td>
                    </tr>
                </table>
            </div>

            <!-- Rate This Theme -->
            <div class="blog-over-dash-card">
                <h2 class="blog-over-dash-card-title">
                    <span class="dashicons dashicons-star-filled blog-over-dash-icon-accent"></span>
                    <?php esc_html_e('Rate This Theme', 'blog-over'); ?>
                </h2>
                <div class="blog-over-dash-stars">
                    <?php for ($i = 0; $i < 5; $i++): ?>
                        <span class="dashicons dashicons-star-filled"></span>
                    <?php endfor; ?>
                </div>
                <p class="blog-over-dash-rate-text">
                    <?php esc_html_e('Enjoying Blog Over? Please rate it on WordPress.org!', 'blog-over'); ?>
                </p>
                <a href="https://wordpress.org/support/theme/blog-over/reviews/#new-post"
                    class="blog-over-dash-btn blog-over-dash-btn-outline" target="_blank" rel="noopener noreferrer">
                    <?php esc_html_e('Leave a Review', 'blog-over'); ?>
                </a>
            </div>

            <!-- Need Help? -->
            <div class="blog-over-dash-card">
                <h2 class="blog-over-dash-card-title">
                    <span class="dashicons dashicons-sos blog-over-dash-icon-accent"></span>
                    <?php esc_html_e('Need Help?', 'blog-over'); ?>
                </h2>
                <ul class="blog-over-dash-links">
                    <li>
                        <a href="https://wordpress.org/support/theme/blog-over/" target="_blank"
                            rel="noopener noreferrer">
                            <span class="dashicons dashicons-format-chat"></span>
                            <?php esc_html_e('Support Forum', 'blog-over'); ?>
                        </a>
                    </li>
                </ul>

                <!-- Changelog from readme.txt -->
                <h3 class="blog-over-dash-changelog-title">
                    <span class="dashicons dashicons-backup"></span>
                    <?php esc_html_e('Changelog', 'blog-over'); ?>
                </h3>
                <div class="blog-over-dash-changelog">
                    <?php
                    $readme_path = get_template_directory() . '/readme.txt';
                    if (file_exists($readme_path)) {
                        $readme_content = file_get_contents($readme_path); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
                        // Extract changelog section
                        $changelog_start = strpos($readme_content, '== Changelog ==');
                        if (false !== $changelog_start) {
                            $changelog_text = substr($readme_content, $changelog_start + strlen('== Changelog =='));
                            // Stop at next == section if any
                            $next_section = strpos($changelog_text, '==', 2);
                            if (false !== $next_section) {
                                $changelog_text = substr($changelog_text, 0, $next_section);
                            }
                            $changelog_text = trim($changelog_text);

                            // Parse each version block
                            $versions = preg_split('/^= /m', $changelog_text);
                            foreach ($versions as $version_block) {
                                $version_block = trim($version_block);
                                if (empty($version_block)) {
                                    continue;
                                }
                                // Extract version number
                                $lines = explode("\n", $version_block);
                                $version_line = trim(str_replace('=', '', array_shift($lines)));
                                echo '<div class="blog-over-dash-changelog-version">';
                                echo '<strong>' . esc_html($version_line) . '</strong>';
                                echo '<ul>';
                                foreach ($lines as $line) {
                                    $line = trim($line);
                                    $line = ltrim($line, '* -');
                                    $line = trim($line);
                                    if (!empty($line)) {
                                        echo '<li>' . esc_html($line) . '</li>';
                                    }
                                }
                                echo '</ul>';
                                echo '</div>';
                            }
                        }
                    }
                    ?>
                </div>
            </div>

        </div><!-- .blog-over-dash-sidebar -->

    </div><!-- .blog-over-dash-body -->

</div><!-- .blog-over-dashboard -->