<?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(
                            array('dashicons-layout', __('Blog Layouts & Image Ratios', 'blog-over'), 'Basic', 'Advanced'),
                            array('dashicons-slides', __('Hero Slider Effects', 'blog-over'), '1', '3'),
                            array('dashicons-rss', __('Ticker News Sources', 'blog-over'), '1', '2'),
                            array('dashicons-search', __('Search & Menu Styles', 'blog-over'), 'Basic', 'Advanced'),
                            array('dashicons-star-empty', __('Featured Links Limit', 'blog-over'), '4 Links', '8 Links'),
                            array('dashicons-hidden', __('You Missed Layouts & Cols', 'blog-over'), 'Basic', 'Advanced'),
                            array('dashicons-admin-users', __('Author Box Styles', 'blog-over'), '1', '5'),
                            array('dashicons-leftright', __('Post Navigation Styles', 'blog-over'), '1', '6'),
                            array('dashicons-admin-post', __('Related Posts Filtering', 'blog-over'), 'Category Only', 'Advanced (Tags, Custom)'),
                            array('dashicons-heading', __('Widget Title Styles', 'blog-over'), '1', '5'),
                            array('dashicons-update', __('Loading Screen Styles', 'blog-over'), '1', '6'),
                            array('dashicons-category', __('Tabbed Magazine Tabs', 'blog-over'), 'Max 3 Tabs', 'Max 8 Tabs'),
                            array('dashicons-images-alt', __('Tabbed Magazine Card Styles', 'blog-over'), '1', '3'),
                            array('dashicons-video-alt3', __('Feature Story Media', 'blog-over'), 'Image Only', 'Image + Video Embeds'),
                            array('dashicons-megaphone', __('Advertising Banners', 'blog-over'), '1 Basic Banner', 'Unlimited + 6 Layouts'),
                            array('dashicons-arrow-up-alt2', __('Go to Top Icons', 'blog-over'), '1', '4'),
                            array('dashicons-art', __('Advanced Color Customization', 'blog-over'), false, true),
                            array('dashicons-editor-textcolor', __('Typography Options', 'blog-over'), false, true),
                            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 -->