<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><%= wallet ? wallet.address : 'Address not found' %> - <%= service.name %></title>
    <link rel="stylesheet" href="/css/admin.css">
  </head>
  <body>
    <main class="shell explorer-shell explorer-wide">
      <header class="topbar explorer-topbar">
        <div><p class="eyebrow"><%= service.mode %></p><h1>Address Detail</h1></div>
        <div class="top-actions"><a class="nav-button subtle" href="https://aisfor.kr/chain-wallet?next=/wallet">Wallet</a><a class="nav-button subtle" href="/explorer">Explorer</a><a class="nav-button subtle" href="/admin">Admin</a></div>
      </header>
      <% if (!wallet) { %>
        <section class="panel"><h2>Address not found</h2><p class="empty">요청한 지갑 주소를 찾을 수 없습니다.</p></section>
      <% } else { %>
        <section class="panel explorer-detail-hero">
          <div>
            <p class="eyebrow"><%= wallet.ownerType %></p>
            <h2><%= wallet.label %></h2>
            <code class="hash-block"><%= wallet.address %></code>
          </div>
          <div class="detail-status-stack"><span class="badge badge-ok"><%= wallet.status %></span><strong><%= toDisplayAmount(wallet.balance) %> <%= walletStats.coin.symbol %></strong></div>
        </section>
        <section class="grid metrics explorer-metrics">
          <article><strong><%= toDisplayAmount(wallet.balance) %></strong><span>Balance</span></article>
          <article><strong><%= toDisplayAmount((wallet.balance || 0) - (wallet.lockedBalance || 0)) %></strong><span>Available</span></article>
          <article><strong><%= toDisplayAmount(wallet.lockedBalance || 0) %></strong><span>Locked</span></article>
          <article><strong><%= toDisplayAmount(wallet.rewardBalance || 0) %></strong><span>Rewards</span></article>
          <article><strong><%= wallet.nonce || 0 %></strong><span>Nonce</span></article>
          <article><strong><%= transactions.length %></strong><span>Transactions</span></article>
        </section>
        <section class="panel">
          <div class="panel-title"><h2>Transactions</h2><span><%= transactions.length %> rows</span></div>
          <div class="table-wrap">
            <table>
              <thead><tr><th>Time</th><th>Type</th><th>From</th><th>To</th><th>Amount</th><th>Status</th><th>Hash</th></tr></thead>
              <tbody>
                <% if (transactions.length === 0) { %><tr><td colspan="7">No wallet transactions yet.</td></tr><% } %>
                <% transactions.forEach(function(tx) { %>
                  <tr>
                    <td><%= tx.confirmedAt || tx.createdAt || '-' %></td>
                    <td><%= tx.type %></td>
                    <td><code><%= shortHash(tx.fromAddress || 'GENESIS') %></code></td>
                    <td><code><%= shortHash(tx.toAddress || '-') %></code></td>
                    <td><strong><%= toDisplayAmount(tx.amount) %> <%= tx.symbol %></strong></td>
                    <td><span class="badge badge-ok"><%= tx.status %></span></td>
                    <td><a href="/explorer/tx/<%= encodeURIComponent(tx.txHash) %>"><code><%= shortHash(tx.txHash) %></code></a></td>
                  </tr>
                <% }) %>
              </tbody>
            </table>
          </div>
        </section>
      <% } %>
    </main>
  </body>
</html>

