<?php
// pages/admin_settings.php — 시스템 설정 (시스템관리자 전용)
require_once __DIR__ . '/../config/database.php';
require_once __DIR__ . '/../includes/header.php';
$db = (new Database())->getConnection();

$staffCnt = $db->query("SELECT COUNT(*) FROM staff WHERE is_active=1")->fetchColumn();
$accountCnt = $db->query("SELECT COUNT(*) FROM user_account WHERE approval_status='승인'")->fetchColumn();
$teamCnt = $db->query("SELECT COUNT(DISTINCT team) FROM staff WHERE is_active=1")->fetchColumn();
?>

<div class="page-header"><h2>⚙️ 시스템 설정</h2></div>

<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(10rem,1fr));gap:1rem;margin-bottom:1.25rem;">
    <div class="card" style="padding:1rem;text-align:center;">
        <div style="font-size:var(--fs-xs);color:var(--text-tertiary);">전체 직원</div>
        <div style="font-size:var(--fs-xl);font-weight:800;color:var(--accent-text);"><?= $staffCnt ?></div>
    </div>
    <div class="card" style="padding:1rem;text-align:center;">
        <div style="font-size:var(--fs-xs);color:var(--text-tertiary);">활성 계정</div>
        <div style="font-size:var(--fs-xl);font-weight:800;"><?= $accountCnt ?></div>
    </div>
    <div class="card" style="padding:1rem;text-align:center;">
        <div style="font-size:var(--fs-xs);color:var(--text-tertiary);">운영 팀</div>
        <div style="font-size:var(--fs-xl);font-weight:800;"><?= $teamCnt ?></div>
    </div>
</div>

<div class="card">
    <div class="card-header"><h3>🔗 관리 바로가기</h3></div>
    <div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(14rem,1fr));gap:0.75rem;padding:1rem;">
        <a href="<?=BASE_URL?>pages/menu_manage.php" style="padding:1rem;border-radius:var(--radius-sm);background:rgba(var(--accent-rgb),0.06);text-decoration:none;text-align:center;">
            <div style="font-size:1.5rem;">📋</div><div style="font-size:var(--fs-sm);color:var(--text-primary);font-weight:600;">메뉴 권한 관리</div>
        </a>
        <a href="<?=BASE_URL?>pages/policy.php" style="padding:1rem;border-radius:var(--radius-sm);background:rgba(var(--accent-rgb),0.06);text-decoration:none;text-align:center;">
            <div style="font-size:1.5rem;">📜</div><div style="font-size:var(--fs-sm);color:var(--text-primary);font-weight:600;">규정/설정</div>
        </a>
        <a href="<?=BASE_URL?>pages/admin_accounts.php" style="padding:1rem;border-radius:var(--radius-sm);background:rgba(var(--accent-rgb),0.06);text-decoration:none;text-align:center;">
            <div style="font-size:1.5rem;">👤</div><div style="font-size:var(--fs-sm);color:var(--text-primary);font-weight:600;">계정 관리</div>
        </a>
        <a href="<?=BASE_URL?>pages/admin_audit.php" style="padding:1rem;border-radius:var(--radius-sm);background:rgba(var(--accent-rgb),0.06);text-decoration:none;text-align:center;">
            <div style="font-size:1.5rem;">🔍</div><div style="font-size:var(--fs-sm);color:var(--text-primary);font-weight:600;">로그 추적</div>
        </a>
    </div>
</div>
<?php require_once __DIR__.'/../includes/footer.php'; ?>
