<!DOCTYPE html>
<html lang="ko">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Project Master Overseas 관리자</title>
    <link rel="stylesheet" as="style" crossorigin
        href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css" />
    <link rel="stylesheet" href="style/common.css">
    <link rel="stylesheet" href="style/dashboard.css">
</head>

<body>

    <nav class="topbar">
        <div class="topbar-header">
            <a href="/">
                <h2>Project Master Test</h2>
            </a>
        </div>
        <ul class="nav-list">
            <li class="nav-item active" onclick="location.href='/dashboard'">대시보드</li>
            <li class="nav-item" onclick="location.href='/inquiries'">문의사항</li>
            <li class="nav-item" onclick="alert('준비 중입니다.')">로그관리</li>
            <li class="nav-item" onclick="alert('준비 중입니다.')">파일관리</li>
            <li class="nav-item" onclick="alert('준비 중입니다.')">인원관리</li>
            <li class="nav-item" onclick="alert('준비 중입니다.')">공지사항</li>
        </ul>
    </nav>

    <main class="main-content">
        <header>
            <h2>프로젝트 현황</h2>
            <div class="header-actions" style="display: flex; align-items: center; gap: 15px;">
                <div class="base-date-info">기준날짜: <strong id="baseDate">-</strong></div>
                <button id="syncBtn" class="sync-btn" onclick="syncData()">
                    <span class="spinner"></span>
                    데이터 동기화
                </button>
                <div class="admin-info">접속자: <strong>이태훈[전체관리자]</strong></div>
            </div>
        </header>

        <!-- 프로젝트 활성도 대시보드 (전체 너비 래퍼) -->
        <div class="activity-dashboard-wrapper">
            <div id="activityDashboard" class="activity-dashboard">
                <!-- JS에서 동적 삽입 -->
            </div>
        </div>

        <!-- 실시간 로그 콘솔 (본문 내부로 복구) -->
        <div id="logConsole" class="log-console" style="display:none;">
            <div class="log-console-header">실시간 수집 로그 [PM Overseas]</div>
            <div id="logBody"></div>
        </div>

        <div id="projectAccordion">
            <!-- Multi-level Accordion items will be generated here -->
        </div>
    </main>

    <!-- 모달 레이어 (최외각 유지) -->
    <div id="authModal" class="activity-modal-overlay" style="display:none;">
        <div class="auth-modal-content">
            <div class="auth-header">
                <i class="fas fa-lock"></i>
                <h3>크롤링 권한 인증</h3>
                <p>시스템 동기화를 위해 관리자 계정으로 로그인하세요.</p>
            </div>
            <div class="auth-body">
                <div class="input-group">
                    <label>관리자 아이디</label>
                    <input type="text" id="authId" placeholder="아이디를 입력하세요">
                </div>
                <div class="input-group">
                    <label>비밀번호</label>
                    <input type="password" id="authPw" placeholder="비밀번호를 입력하세요"
                        onkeyup="if(event.key==='Enter') submitAuth()">
                </div>
                <div id="authErrorMessage" class="error-text" style="display:none;">크롤링을 할 수 없습니다.</div>
            </div>
            <div class="auth-footer">
                <button class="cancel-btn" onclick="closeAuthModal()">취소</button>
                <button class="login-btn" onclick="submitAuth()">인증 및 실행</button>
            </div>
        </div>
    </div>

    <div id="activityDetailModal" class="activity-modal-overlay" style="display:none;"
        onclick="closeActivityModal(event)">
        <div class="activity-modal-content" onclick="event.stopPropagation()">
            <div class="modal-header">
                <h3 id="modalTitle">상세 목록</h3>
                <button class="close-btn" onclick="closeActivityModal()">&times;</button>
            </div>
            <div class="modal-body">
                <table class="data-table">
                    <thead>
                        <tr>
                            <th>프로젝트명</th>
                            <th>담당부서</th>
                            <th>담당자</th>
                        </tr>
                    </thead>
                    <tbody id="modalTableBody">
                        <!-- JS에서 동적 삽입 -->
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <script src="js/common.js"></script>
    <script src="js/dashboard.js"></script>
</body>

</html>