<?php
use App\Industry\Catalog;
$industry = $industry ?? Catalog::current();
$industries = Catalog::all();
$meta = [
    'distribution' => ['bi-box-seam-fill', '#2563eb', '#eff6ff'],
    'software' => ['bi-laptop-fill', '#7c3aed', '#f3e8ff'],
    'contract' => ['bi-building-fill', '#ea580c', '#fff7ed'],
    'service' => ['bi-tools', '#0f766e', '#f0fdfa'],
];
?>
<div class="sup-page">
  <?php \App\Core\View::partial('setup_nav', compact('section', 'dirty', 'canUndo', 'publishedAt')); ?>

  <form class="set-section ajax-form" action="<?= e(url('settings/industry')) ?>" method="post">
    <?= csrf_field() ?>
    <div class="set-section-head">
      <div>
        <div class="set-section-title"><i class="bi bi-buildings"></i> 1. Pick industry</div>
        <p class="set-section-sub">This is the Phase 2 setup. Saving it updates deal stages now, then you can rename and add boxes below.</p>
      </div>
      <button class="btn btn-primary set-save" type="submit">Save setup</button>
    </div>
    <div class="set-industry-grid">
      <?php foreach ($industries as $code => $tpl):
          $m = $meta[$code] ?? ['bi-grid', '#2563eb', '#eff6ff'];
          $on = ($industry['code'] ?? '') === $code;
      ?>
        <label class="set-industry <?= $on ? 'is-on' : '' ?>" style="--set-accent: <?= e($m[1]) ?>; --set-tint: <?= e($m[2]) ?>">
          <input class="visually-hidden" type="radio" name="industry_code" value="<?= e($code) ?>" <?= $on ? 'checked' : '' ?>>
          <span class="set-industry-icon"><i class="bi <?= e($m[0]) ?>"></i></span>
          <span class="set-industry-body">
            <span class="set-industry-kicker">Setup <?= e($tpl['letter']) ?></span>
            <span class="set-industry-name"><?= e($tpl['name']) ?></span>
            <span class="set-industry-sum"><?= e($tpl['summary']) ?></span>
            <span class="set-industry-meta"><?= count($tpl['stages'] ?? []) ?> deal stages</span>
          </span>
          <?php if ($on): ?><span class="set-pill is-on">Current</span><?php endif; ?>
        </label>
      <?php endforeach; ?>
    </div>
  </form>

  <div class="sup-next">
    <a class="btn btn-primary" href="<?= e(url('setup/names')) ?>">Next: rename words</a>
  </div>
</div>
