<?php
declare(strict_types=1);
/** gov-portal-strip 메인 대시보드 본문 */
?>
<div class="kpi-strip">
  <div class="kpi-card">
    <div class="ico"><i class="fa-solid fa-boxes-stacked"></i></div>
    <div><div class="n ok">양호</div><div class="l">봉투 재고 상태</div></div>
  </div>
  <div class="kpi-card">
    <div class="ico"><i class="fa-solid fa-inbox"></i></div>
    <div><div class="n">12</div><div class="l">미처리 구매신청</div></div>
  </div>
  <div class="kpi-card">
    <div class="ico"><i class="fa-solid fa-user-check"></i></div>
    <div><div class="n">4</div><div class="l">승인 대기</div></div>
  </div>
  <div class="kpi-card">
    <div class="ico"><i class="fa-solid fa-location-dot"></i></div>
    <div><div class="n" style="font-size:.95rem;color:var(--text-dark);"><?= esc($lgLabel) ?></div><div class="l">담당 지자체</div></div>
  </div>
</div>

<section class="hero">
  <div class="hero-hd">
    <span><i class="fa-solid fa-map"></i> GIS 통합 현황판</span>
    <a href="<?= base_url('bag/flow') ?>">수불 조회 &gt;</a>
  </div>
  <div class="hero-body">
    <div class="hero-map">
      <?= view('home/_dashboard_gov_portal_map_panel', [
          'mapId'       => 'govPortalStripMap',
          'mapFill'     => true,
          'lgLabel'     => $lgLabel,
          'govMapPanel' => $govMapPanel,
      ]) ?>
    </div>
    <div class="hero-tl">
      <?php foreach ($timeline as $ev): ?>
      <div class="item">
        <span class="time"><?= esc($ev['time']) ?></span>
        <span class="txt"><?= esc($ev['text']) ?></span>
      </div>
      <?php endforeach; ?>
    </div>
  </div>
</section>

<div class="grid2 stock-pair">
  <?= view('home/_dashboard_gov_portal_stock_cards_pair', ['lowStock' => $lowStock, 'stockAlerts' => $stockAlerts]) ?>
</div>

<div class="grid2">
  <div class="card">
    <div class="card-hd"><i class="fa-regular fa-envelope"></i> 메시지</div>
    <div class="card-bd">
      <?php foreach ($notices as $n): ?>
      <div class="notice-row">
        <span class="notice-t"><?= esc($n['title']) ?></span>
        <span class="notice-d"><?= esc($n['date']) ?></span>
      </div>
      <?php endforeach; ?>
      <?= view('home/_dashboard_gov_portal_menu_search', [
          'variant'           => 'inline',
          'inputId'           => 'menuSearch',
          'menuSearchOptions' => $menuSearchOptions,
      ]) ?>
    </div>
  </div>
  <div class="card">
    <div class="card-hd"><i class="fa-solid fa-chart-column"></i> 최근 7일 신청 · 바로가기</div>
    <div class="card-bd">
      <div class="bars">
        <?php $maxReq = max($weeklyRequests); foreach ($weeklyRequests as $idx => $v): $h = (int) round(($v / $maxReq) * 100); ?>
        <div class="col"><span><?= esc((string) $v) ?></span><div class="bar" style="height:<?= $h ?>%"></div><span>D<?= 6 - $idx ?></span></div>
        <?php endforeach; ?>
      </div>
      <div class="quick-list" style="margin-top:.75rem;">
        <?php foreach ($quickLinks as $link): ?>
        <a href="<?= esc($link['url']) ?>">
          <i class="fa-solid <?= esc($link['icon'], 'attr') ?>"></i>
          <?= esc($link['label']) ?>
          <span><?= esc($link['desc']) ?></span>
        </a>
        <?php endforeach; ?>
      </div>
    </div>
  </div>
</div>
