<?php $assetBase =
    basename(rtrim(FCPATH, "\\/")) === "public"
        ? "assets/"
        : "public/assets/"; ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><?= esc($article["title"]) ?> · BrandSquare Admin</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="<?= base_url($assetBase . "css/admin.css") ?>">
</head>
<body class="admin-page">
<aside class="admin-sidebar">
    <a href="<?= base_url(
        "admin/leads",
    ) ?>" class="admin-logo">Brand<span>Square.</span></a>
    <nav><a href="<?= base_url(
        "admin/leads",
    ) ?>"><i>◎</i> Leads</a><a href="<?= base_url(
    "admin/clients",
) ?>"><i>◉</i> Clients</a><a href="<?= base_url(
    "admin/quotations",
) ?>"><i>₹</i> Quotations</a><a href="<?= base_url(
    "admin/invoices",
) ?>"><i>▤</i> Invoices</a><a href="<?= base_url(
    "admin/industries",
) ?>"><i>◆</i> Industries</a><a class="active" href="<?= base_url(
    "admin/articles",
) ?>"><i>¶</i> Articles</a><a href="<?= base_url(
    "admin/email-templates",
) ?>"><i>✦</i> Email templates</a><a href="<?= base_url(
    "admin/settings",
) ?>"><i>⚙</i> Settings</a></nav>
    <div class="admin-user"><span><?= esc(
        strtoupper(substr((string) session("admin_name"), 0, 2)),
    ) ?></span><div><b><?= esc(session("admin_name")) ?></b><small><?= esc(
    session("admin_email"),
) ?></small></div></div>
    <form action="<?= base_url(
        "admin/logout",
    ) ?>" method="post"><?= csrf_field() ?><button class="logout" type="submit">Sign out →</button></form>
</aside>
<main class="admin-main quotation-view-main article-show-main">
    <header class="admin-heading"><div><a class="back-to-templates" href="<?= base_url(
        "admin/articles",
    ) ?>">← Article library</a><h1><?= esc(
    $article["title"],
) ?></h1><p>Review the public presentation, search metadata, and publishing state.</p></div><div class="quotation-actions"><?php if (
    $article["is_published"]
): ?><a href="<?= base_url(
    "brand-guide/" . $article["slug"],
) ?>" target="_blank">Open article <span>↗</span></a><?php endif; ?><a class="edit-quotation-action" href="<?= base_url(
    "admin/articles/" . $article["id"] . "/edit",
) ?>">Edit article <span>→</span></a></div></header>
    <?php if (session("error")): ?><div class="alert error"><?= esc(
    session("error"),
) ?></div><?php endif; ?>
    <?php if (session("success")): ?><div class="alert success"><?= esc(
    session("success"),
) ?></div><?php endif; ?>
    <section class="article-admin-preview article-theme-<?= esc(
        $article["theme"],
    ) ?>">
        <div><span><?= esc(
            $article["category"],
        ) ?></span><b class="quote-status status-<?= $article["is_published"]
    ? "accepted"
    : "draft" ?>"><?= $article["is_published"]
    ? "Published"
    : "Draft" ?></b><h2><?= esc($article["title"]) ?></h2><p><?= esc(
    $article["excerpt"],
) ?></p><small><?= esc($article["author_name"]) ?> · <?= esc(
     $article["reading_minutes"],
 ) ?> min read</small></div><i><?= esc(
     strtoupper(substr($article["category"], 0, 1)),
 ) ?></i>
    </section>
    <section class="admin-panel industry-admin-details article-admin-details">
        <div><span>Public URL</span><a href="<?= base_url(
            "brand-guide/" . $article["slug"],
        ) ?>" target="_blank"><?= esc(
    base_url("brand-guide/" . $article["slug"]),
) ?> ↗</a></div>
        <div><span>SEO title</span><p><?= esc(
            $article["meta_title"],
        ) ?></p></div>
        <div><span>Meta description</span><p><?= esc(
            $article["meta_description"],
        ) ?></p></div>
        <div><span>Primary search phrase</span><p><?= esc(
            $article["focus_keyword"] ?: "Not set",
        ) ?></p></div>
        <div><span>Publishing</span><p><?= ($article["is_featured"]
            ? "Featured · "
            : "") .
            ($article["published_at"]
                ? date("d M Y, g:i a", strtotime($article["published_at"]))
                : "No publication date") ?></p></div>
    </section>
    <section class="article-admin-body admin-panel"><?= $article[
        "content"
    ] ?></section>
    <section class="article-danger-zone"><div><h2>Delete article</h2><p>Remove this article and its public URL permanently.</p></div><form method="post" action="<?= base_url(
        "admin/articles/" . $article["id"] . "/delete",
    ) ?>" onsubmit="return confirm('Delete this article permanently?');"><?= csrf_field() ?><button type="submit">Delete article</button></form></section>
</main>
</body>
</html>
