<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
  <link rel="icon" href="{{ site_branding.favicon_url }}">
    <title>商家申请审核 - {{ site_branding.browser_title }}</title>
    <style>
        * { box-sizing: border-box; }
        body { margin:0; font-family:Arial, "Microsoft YaHei", sans-serif; background:#f5f5f7; color:#222; }
        a { text-decoration:none; color:inherit; }

        .topbar { background:#111; color:#fff; padding:14px 24px; }
        .topbar-inner {
            width:1200px; max-width:calc(100vw - 48px); margin:0 auto;
            display:flex; justify-content:space-between; align-items:center;
        }
        .topbar-brand a { color:#fff; font-size:20px; font-weight:800; }
        .topbar-links a { color:#f3f3f3; font-size:14px; margin-left:16px; }

        .container { width:1200px; max-width:calc(100vw - 48px); margin:24px auto; }
        .card {
            background:#fff; border-radius:18px; padding:20px 22px;
            box-shadow:0 2px 10px rgba(0,0,0,0.05); margin-bottom:18px;
        }
        .title { margin:0 0 16px; font-size:28px; font-weight:800; }
        .row { margin:8px 0; line-height:1.8; }
        .muted { color:#666; font-size:14px; }
        .status {
            display:inline-block; padding:6px 10px; border-radius:999px; font-size:13px; font-weight:700;
            background:#f5f5f5;
        }
        .actions { display:flex; gap:10px; margin-top:14px; }
        .btn {
            display:inline-block; padding:10px 16px; border:none; border-radius:10px;
            background:#111; color:#fff; font-size:14px; cursor:pointer;
        }
        .btn-light { background:#666; }
        .reject-box { margin-top:10px; }
        .reject-box input {
            width:320px; height:40px; padding:0 10px; border:1px solid #ddd; border-radius:10px;
        }
    </style>
</head>
<body>
    <div class="topbar">
        <div class="topbar-inner">
            <div class="topbar-brand"><a href="/">{{ site_branding.site_name }}</a></div>
            <div class="topbar-links">
                <a href="/account">用户主页</a>
                <a href="/logout">退出</a>
            </div>
        </div>
    </div>

    <div class="container">
        <div class="card">
            <h1 class="title">商家申请审核</h1>
            <div class="muted">管理员在此审核用户提交的商家入驻申请。</div>
        </div>

        {% for app in applications %}
        <div class="card">
            <div class="row"><strong>申请编号：</strong>{{ app.application_id }}</div>
            <div class="row"><strong>申请用户：</strong>{{ app.username }}（{{ app.email }}）</div>
            <div class="row"><strong>店铺名称：</strong>{{ app.shop_name }}</div>
            <div class="row"><strong>联系人：</strong>{{ app.contact_name }}</div>
            <div class="row"><strong>联系电话：</strong>{{ app.contact_phone }}</div>
            <div class="row"><strong>经营范围：</strong>{{ app.business_scope or '暂无' }}</div>
            <div class="row"><strong>申请理由：</strong>{{ app.application_reason or '暂无' }}</div>
            <div class="row">
                <strong>状态：</strong>
                <span class="status">
                    {% if app.status == 0 %}待审核{% elif app.status == 1 %}已通过{% else %}已拒绝{% endif %}
                </span>
            </div>
            <div class="row"><strong>审核备注：</strong>{{ app.review_remark or '暂无' }}</div>
            <div class="row"><strong>提交时间：</strong>{{ app.created_at }}</div>

            {% if app.status == 0 %}
            <div class="actions">
                <form method="post" action="/admin/merchant-applications/{{ app.application_id }}/approve">
                    <button class="btn" type="submit">审核通过</button>
                </form>

                <form method="post" action="/admin/merchant-applications/{{ app.application_id }}/reject">
                    <div class="reject-box">
                        <input type="text" name="review_remark" placeholder="填写拒绝原因">
                        <button class="btn btn-light" type="submit">审核拒绝</button>
                    </div>
                </form>
            </div>
            {% endif %}
        </div>
        {% endfor %}
    </div>
</body>
</html>
