<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head><meta charset="UTF-8"><title>WBX Admin - System Config</title><link rel="stylesheet" th:href="@{/admin/css/admin.css}"></head>
<body>
<div class="admin-layout">
    <div th:replace="~{admin/fragments :: sidebar('config')}"></div>
    <div class="admin-content">
        <div class="page-header"><h1>시스템 설정</h1><p>Key-Value 설정 관리</p></div>
        <div th:if="${message}" class="alert alert-success" th:text="${message}"></div>

        <!-- 설정 추가 폼 -->
        <div class="card" style="margin-bottom:20px; padding:16px;">
            <h3>설정 추가/수정</h3>
            <form th:action="@{/admin/config/save}" method="post" style="display:flex; gap:10px; align-items:end; flex-wrap:wrap;">
                <div><label>Key</label><input name="configKey" required style="display:block; padding:6px; border:1px solid #ddd; border-radius:4px;"></div>
                <div><label>Value</label><input name="configValue" required style="display:block; padding:6px; border:1px solid #ddd; border-radius:4px; min-width:200px;"></div>
                <div><label>설명</label><input name="description" style="display:block; padding:6px; border:1px solid #ddd; border-radius:4px;"></div>
                <button type="submit" class="btn btn-primary" style="padding:6px 16px;">저장</button>
            </form>
        </div>

        <!-- 기존 설정 목록 -->
        <div class="data-table">
            <table>
                <thead><tr><th>Key</th><th>Value</th><th>설명</th><th>수정일</th></tr></thead>
                <tbody>
                <tr th:each="cfg : ${configs}">
                    <td><code th:text="${cfg.configKey}"></code></td>
                    <td th:text="${cfg.configValue}"></td>
                    <td th:text="${cfg.description}"></td>
                    <td th:text="${cfg.updatedAt != null ? #temporals.format(cfg.updatedAt, 'yy-MM-dd HH:mm') : ''}"></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
</body>
</html>
