<?php
/**
 * Shared sidebar for admin app (icon + title + nav).
 * Include after <body>. Set $admin_current_nav = 'filter'|'search'|'metafield' to highlight active item.
 */
 
 header_remove('X-Frame-Options');
header('Content-Security-Policy: frame-ancestors https://admin.shopify.com https://*.myshopify.com');
 
if (!function_exists('h')) {
    function h($v) { return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8'); }
}
$admin_current_nav = $admin_current_nav ?? 'filter';
$admin_app_title = $admin_app_title ?? 'Door Configurator';
$admin_nav_items = [
    'filter'   => ['label' => 'Configurations', 'url' => 'configurations.php'],
    'folders'  => ['label' => 'Folders',        'url' => 'folders.php'],
    'search'   => ['label' => 'Search',         'url' => 'configurations.php?search=1'],
    'metafield'=> ['label' => 'Metafield',      'url' => 'configurations.php'],
];
?>
<aside class="admin-sidebar">
  <div class="admin-sidebar-header">
    <span class="admin-sidebar-icon" aria-hidden="true">
      <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg>
    </span>
    <span class="admin-sidebar-title"><?= h($admin_app_title) ?></span>
  </div>
  <nav class="admin-sidebar-nav">
    <?php foreach ($admin_nav_items as $key => $item): ?>
      <a href="<?= h($item['url']) ?>" class="admin-sidebar-link<?= $admin_current_nav === $key ? ' admin-sidebar-link-active' : '' ?>"><?= h($item['label']) ?></a>
    <?php endforeach; ?>
  </nav>
</aside>
