<!doctype html>
<html lang="ko"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="${siteInfo.adminTitle}">국제오토텍 관리자</title>
    <link rel="stylesheet" th:href="@{/resources/kr/iotdoor/comn/site/layout/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/resources/kr/iotdoor/comn/site/layout/css/iotdoor.css?v=202404021718}">
    <link rel="stylesheet" th:href="@{/resources/kr/iotdoor/comn/site/layout/css/custom.css?v=202404021718}">
</head>
<body class="bg-light">
<div class="container py-5">
    <div class="d-flex flex-column flex-lg-row justify-content-between align-items-lg-center gap-3 mb-4">
        <div>
            <p class="text-primary fw-semibold mb-2">ADMIN DASHBOARD</p>
            <h1 class="mb-2" th:text="${siteInfo.adminTitle}">국제오토텍 관리자</h1>
            <p class="text-secondary mb-0">현재 관리자/포트폴리오/문의저장 기능은 MariaDB 기준으로 연결된 상태입니다.</p>
        </div>
        <div class="d-flex flex-wrap gap-2">
            <a class="btn btn-outline-secondary" th:href="@{/}">공개 사이트</a>
            <a class="btn btn-outline-primary" th:href="@{/mfuc/portfolio/list.do}">포트폴리오 관리</a>
            <a class="btn btn-outline-primary" th:href="@{/mfuc/contact/list.do}">문의 내역</a>
            <form method="post" th:action="@{/comn/user/login/logout.do}">
                <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
                <button class="btn btn-primary" type="submit">로그아웃</button>
            </form>
        </div>
    </div>

    <div class="row g-4 mb-4">
        <div class="col-md-3">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <p class="text-secondary mb-2">문의 건수</p>
                    <h2 class="mb-0" th:text="${contactCount}">0</h2>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <p class="text-secondary mb-2">포트폴리오 건수</p>
                    <h2 class="mb-0" th:text="${portfolioCount}">0</h2>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <p class="text-secondary mb-2">이행 항목 수</p>
                    <h2 class="mb-0" th:text="${migrationFeatures.size()}">0</h2>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <p class="text-secondary mb-2">로그인 관리자</p>
                    <h2 class="mb-0" th:text="${currentAdminName}">관리자</h2>
                </div>
            </div>
        </div>
    </div>

    <div class="row g-4">
        <div class="col-lg-7">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <h3 class="h5 mb-3">마이그레이션 진행 현황</h3>
                    <div class="table-responsive">
                        <table class="table align-middle">
                            <thead>
                            <tr>
                                <th>영역</th>
                                <th>상태</th>
                                <th>요약</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="feature : ${migrationFeatures}">
                                <td class="fw-semibold" th:text="${feature.name()}">영역</td>
                                <td><span class="badge text-bg-primary" th:text="${feature.status()}">상태</span></td>
                                <td>
                                    <div th:text="${feature.summary()}">요약</div>
                                    <small class="text-secondary" th:text="${feature.routes()}">라우트</small>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-5">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center mb-3">
                        <h3 class="h5 mb-0">최근 문의</h3>
                        <a class="btn btn-sm btn-outline-primary" th:href="@{/mfuc/contact/list.do}">전체 보기</a>
                    </div>
                    <div th:if="${#lists.isEmpty(recentContacts)}" class="text-secondary">
                        아직 접수된 문의가 없습니다.
                    </div>
                    <div th:unless="${#lists.isEmpty(recentContacts)}" class="d-flex flex-column gap-3">
                        <div class="border rounded p-3 bg-white" th:each="contact : ${recentContacts}">
                            <div class="d-flex justify-content-between align-items-start gap-3">
                                <div>
                                    <div class="fw-semibold" th:text="${contact.subject}">문의 제목</div>
                                    <div class="small text-secondary">
                                        <span th:text="${contact.name}">이름</span>
                                        <span>·</span>
                                        <span th:text="${contact.phone}">연락처</span>
                                    </div>
                                </div>
                                <small class="text-secondary" th:text="${#temporals.format(contact.submittedAt, 'MM-dd HH:mm')}">04-16 10:30</small>
                            </div>
                            <p class="mb-0 mt-2 text-secondary" th:text="${contact.message}">문의 내용</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
