<?php
declare(strict_types=1);
/**
 * 메뉴검색 + 하단 바로가기 칩
 *
 * @var string $variant teal|inline
 * @var string $inputId
 * @var list<array{label:string,url:string,keyword:string}> $menuSearchOptions
 */
$variant = $variant ?? 'teal';
$inputId = $inputId ?? 'menuSearch';
$menuSearchOptions = $menuSearchOptions ?? [];
?>
<?php if ($variant === 'inline'): ?>
<div class="search-inline portal-menu-search-block">
  <div class="search-inline-row">
    <label for="<?= esc($inputId, 'attr') ?>"><i class="fa-solid fa-magnifying-glass"></i> 메뉴검색</label>
    <input type="search" id="<?= esc($inputId, 'attr') ?>" placeholder="메뉴명 (예: 재고, 발주)" autocomplete="off"/>
  </div>
  <?php if ($menuSearchOptions !== []): ?>
  <div class="portal-menu-search-options" aria-label="자주 찾는 메뉴">
    <?php foreach ($menuSearchOptions as $opt): ?>
    <a href="#" class="menu-search-chip" data-url="<?= esc($opt['url'], 'attr') ?>" data-keyword="<?= esc($opt['keyword'], 'attr') ?>" title="<?= esc($opt['label']) ?>"><?= esc($opt['label']) ?></a>
    <?php endforeach; ?>
  </div>
  <?php endif; ?>
</div>
<?php else: ?>
<div class="search-teal portal-menu-search-block">
  <strong><i class="fa-solid fa-magnifying-glass"></i> 메뉴검색</strong>
  <div class="search-wrap">
    <input type="search" id="<?= esc($inputId, 'attr') ?>" placeholder="메뉴명 입력 (예: 재고, 발주, 통계)" autocomplete="off"/>
    <i class="fa-solid fa-magnifying-glass"></i>
  </div>
  <?php if ($menuSearchOptions !== []): ?>
  <div class="portal-menu-search-options" aria-label="자주 찾는 메뉴">
    <?php foreach ($menuSearchOptions as $opt): ?>
    <a href="#" class="menu-search-chip" data-url="<?= esc($opt['url'], 'attr') ?>" data-keyword="<?= esc($opt['keyword'], 'attr') ?>" title="<?= esc($opt['label']) ?>"><?= esc($opt['label']) ?></a>
    <?php endforeach; ?>
  </div>
  <?php endif; ?>
</div>
<?php endif; ?>
