<?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>Industries · 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 class="active" href="<?= base_url(
    "admin/industries",
) ?>"><i>◆</i> Industries</a><a 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><a href="<?= base_url() ?>" target="_blank"><i>↗</i> View website</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 clients-main">
    <header class="admin-heading"><div><span>Organic & paid acquisition</span><h1>Industry landing pages</h1><p>Manage targeted logo-design pages, SEO content, publishing, and campaign URLs.</p></div><a class="primary-admin-action" href="<?= base_url(
        "admin/industries/new",
    ) ?>">Add industry <span>＋</span></a></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="client-metrics industry-metrics">
        <article><span>All industries</span><b><?= esc(
            $metrics["total"],
        ) ?></b><small>Landing page records</small></article>
        <article><span>Published</span><b><?= esc(
            $metrics["active"],
        ) ?></b><small>Visible to visitors</small></article>
        <article><span>Inactive</span><b><?= esc(
            $metrics["inactive"],
        ) ?></b><small>Hidden from public view</small></article>
    </section>
    <section class="admin-panel client-panel">
        <div class="panel-toolbar"><div><h2>Industry catalogue</h2><span>Ordered for related-page recommendations</span></div><form method="get" class="client-search"><input name="search" value="<?= esc(
            $search,
        ) ?>" placeholder="Search industry or URL..."><button type="submit">Search</button><?php if (
    $search
): ?><a href="<?= base_url(
    "admin/industries",
) ?>">Clear</a><?php endif; ?></form></div>
        <div class="table-wrap"><table class="client-table industry-table"><thead><tr><th>Industry</th><th>Landing page</th><th>SEO title</th><th>Status</th><th>Actions</th></tr></thead><tbody>
        <?php if (
            !$industries
        ): ?><tr><td colspan="5" class="empty-state"><b>No industries found.</b><span>Add an industry to create its landing page.</span></td></tr><?php endif; ?>
        <?php foreach ($industries as $industry): ?><tr>
            <td><a class="client-identity" href="<?= base_url(
                "admin/industries/" . $industry["id"],
            ) ?>"><span style="background:<?= esc(
    $industry["primary_color"],
) ?>;color:<?= esc($industry["accent_color"]) ?>"><?= esc(
    strtoupper(substr($industry["name"], 0, 2)),
) ?></span><div><b><?= esc($industry["name"]) ?></b><small>Order <?= esc(
    $industry["sort_order"],
) ?></small></div></a></td>
            <td><a href="<?= base_url(
                "logo-design-for-" . $industry["slug"],
            ) ?>" target="_blank">/logo-design-for-<?= esc(
    $industry["slug"],
) ?> ↗</a></td>
            <td><p class="client-address"><?= esc(
                $industry["meta_title"],
            ) ?></p></td>
            <td><span class="quote-status status-<?= $industry["is_active"]
                ? "accepted"
                : "cancelled" ?>"><?= $industry["is_active"]
    ? "Published"
    : "Inactive" ?></span></td>
            <td><div class="client-row-actions"><a href="<?= base_url(
                "admin/industries/" . $industry["id"],
            ) ?>">View</a><a href="<?= base_url(
    "admin/industries/" . $industry["id"] . "/edit",
) ?>">Edit</a></div></td>
        </tr><?php endforeach; ?>
        </tbody></table></div>
    </section>
</main>
</body>
</html>
