<?php
declare(strict_types=1);
// ==================================================
// Nuclear Fancy Pants Edition™ — NUCLEAR+++
// File: /home/ploi/automarketer-ai.com/public/wp-content/plugins/automarketer-ai/templates/link-checker.php
// Description: Link Checker admin page template - NUCLEAR+++
// Last Edited: 2026-05-04
// ==================================================

defined('ABSPATH') || exit;

$last_scan = (string) get_option('amai_link_checker_last_scan', '');
?>
<div class="wrap" id="amai-lc-wrap">
<div class="amai-lc-wrap">

    <div class="amai-lc-header">
        <div class="amai-lc-header__left">
            <h1 class="amai-lc-title">Link Checker</h1>
            <p class="amai-lc-subtitle">Broken outbound links found across your published posts. Scanned nightly.</p>
        </div>
        <div class="amai-lc-header__right">
            <?php if ($last_scan !== ''): ?>
                <span class="amai-lc-last-scan">Last scan: <?php echo esc_html(wp_date('M j, Y \a\t g:i a', strtotime($last_scan))); ?></span>
            <?php endif; ?>
            <button type="button" class="amai-lc-btn amai-lc-btn--secondary" id="amai-lc-scan-all">
                <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>
                Scan All Posts
            </button>
        </div>
    </div>

    <div class="amai-lc-progress" id="amai-lc-progress" style="display:none;">
        <div class="amai-lc-progress__bar">
            <div class="amai-lc-progress__fill" id="amai-lc-progress-fill"></div>
        </div>
        <span class="amai-lc-progress__label" id="amai-lc-progress-label">Scanning...</span>
    </div>

    <div class="amai-lc-summary" id="amai-lc-summary" style="display:none;">
        <div class="amai-lc-summary__stat">
            <span class="amai-lc-summary__num" id="amai-lc-total-broken">0</span>
            <span class="amai-lc-summary__label">Broken links</span>
        </div>
        <div class="amai-lc-summary__stat">
            <span class="amai-lc-summary__num" id="amai-lc-total-posts">0</span>
            <span class="amai-lc-summary__label">Posts affected</span>
        </div>
    </div>

    <div class="amai-lc-loading" id="amai-lc-loading">
        <div class="amai-lc-spinner"></div>
        <span>Loading broken links...</span>
    </div>

    <div class="amai-lc-empty" id="amai-lc-empty" style="display:none;">
        <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="#D97757" stroke-width="1.5"><path d="M9 12l2 2 4-4m6 2a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"/></svg>
        <p>No broken links found across your published posts.</p>
        <span>Run a scan to check for issues.</span>
    </div>

    <div class="amai-lc-table-wrap" id="amai-lc-table-wrap" style="display:none;">
        <table class="amai-lc-table" id="amai-lc-table">
            <thead>
                <tr>
                    <th class="amai-lc-col--post">Post</th>
                    <th class="amai-lc-col--anchor">Anchor Text</th>
                    <th class="amai-lc-col--url">Broken URL</th>
                    <th class="amai-lc-col--status">Status</th>
                    <th class="amai-lc-col--actions">Actions</th>
                </tr>
            </thead>
            <tbody id="amai-lc-tbody">
            </tbody>
        </table>
    </div>

    <!-- AI suggestion panel — cloned per row by JS -->
    <div class="amai-lc-suggestion" id="amai-lc-suggestion" style="display:none;">
        <div class="amai-lc-suggestion__inner">
            <div class="amai-lc-suggestion__label">AI Suggestion</div>
            <div class="amai-lc-suggestion__source" id="amai-lc-suggestion-source"></div>
            <div class="amai-lc-suggestion__reason" id="amai-lc-suggestion-reason"></div>
            <div class="amai-lc-suggestion__url-row">
                <input type="url" class="amai-lc-url-input" id="amai-lc-suggestion-url" placeholder="https://..." />
                <button type="button" class="amai-lc-btn amai-lc-btn--primary" id="amai-lc-apply-suggestion">Update Link</button>
                <button type="button" class="amai-lc-btn amai-lc-btn--ghost" id="amai-lc-dismiss-suggestion">Cancel</button>
            </div>
        </div>
    </div>

</div>
</div>