<?php
// 0readme 폴더의 메인 인덱스 페이지
$currentDir = __DIR__;
$folders = array_filter(glob($currentDir . '/*'), 'is_dir');
$files = array_filter(glob($currentDir . '/*'), 'is_file');

// 현재 폴더에서 0readme 폴더명 제거
$folders = array_map(function($path) {
    return basename($path);
}, $folders);

$files = array_map(function($path) {
    return basename($path);
}, $files);

// index.php 파일 제거
$files = array_filter($files, function($file) {
    return $file !== 'index.php';
});
?>

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>📚 프로젝트 문서 센터</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
            color: #333;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 40px 20px;
        }
        
        .header {
            text-align: center;
            color: white;
            margin-bottom: 50px;
        }
        
        .header h1 {
            font-size: 3em;
            margin-bottom: 10px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
        }
        
        .header p {
            font-size: 1.3em;
            opacity: 0.9;
        }
        
        .content {
            background: white;
            border-radius: 15px;
            padding: 40px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }
        
        .section {
            margin-bottom: 40px;
        }
        
        .section h2 {
            color: #2c3e50;
            font-size: 2em;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 3px solid #3498db;
        }
        
        .folder-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }
        
        .folder-card {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 25px;
            border-radius: 12px;
            text-decoration: none;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
        
        .folder-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.2);
        }
        
        .folder-card h3 {
            font-size: 1.5em;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
        }
        
        .folder-card p {
            opacity: 0.9;
            line-height: 1.6;
        }
        
        .file-list {
            background: #f8f9fa;
            border-radius: 8px;
            padding: 20px;
            margin-top: 20px;
        }
        
        .file-list h3 {
            color: #2c3e50;
            margin-bottom: 15px;
        }
        
        .file-item {
            background: white;
            padding: 15px;
            margin-bottom: 10px;
            border-radius: 6px;
            border-left: 4px solid #3498db;
            transition: transform 0.2s ease;
        }
        
        .file-item:hover {
            transform: translateX(5px);
        }
        
        .file-item a {
            color: #2c3e50;
            text-decoration: none;
            font-weight: 500;
        }
        
        .file-item a:hover {
            color: #3498db;
        }
        
        .stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-top: 30px;
        }
        
        .stat-card {
            background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
            color: white;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
        }
        
        .stat-card h3 {
            font-size: 2em;
            margin-bottom: 5px;
        }
        
        .stat-card p {
            opacity: 0.9;
        }
        
        .footer {
            margin-top: 40px;
            text-align: center;
            color: #7f8c8d;
            padding: 20px;
            border-top: 1px solid #ecf0f1;
        }
        
        @media (max-width: 768px) {
            .container {
                padding: 20px 10px;
            }
            
            .header h1 {
                font-size: 2.5em;
            }
            
            .content {
                padding: 20px;
            }
            
            .folder-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>📚 프로젝트 문서 센터</h1>
            <p>Project Documentation Center</p>
        </div>
        
        <div class="content">
            <div class="section">
                <h2>📁 문서 폴더</h2>
                <div class="folder-grid">
                    <?php foreach ($folders as $folder): ?>
                        <a href="<?php echo $folder; ?>/" class="folder-card">
                            <h3>
                                📁 <?php echo ucfirst($folder); ?>
                            </h3>
                            <p>
                                <?php 
                                switch($folder) {
                                    case 'estimate':
                                        echo '방화셔터 견적 시스템 문서 - 스크린 및 철재 견적 관련 모든 파일과 기능에 대한 상세한 설명';
                                        break;
                                    default:
                                        echo '프로젝트 관련 문서들이 포함된 폴더입니다.';
                                }
                                ?>
                            </p>
                        </a>
                    <?php endforeach; ?>
                </div>
            </div>
            
            <?php if (!empty($files)): ?>
            <div class="section">
                <h2>📄 루트 파일</h2>
                <div class="file-list">
                    <h3>현재 폴더의 파일들</h3>
                    <?php foreach ($files as $file): ?>
                        <div class="file-item">
                            <a href="<?php echo $file; ?>">📄 <?php echo $file; ?></a>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>
            <?php endif; ?>
            
            <div class="stats">
                <div class="stat-card">
                    <h3><?php echo count($folders); ?></h3>
                    <p>문서 폴더</p>
                </div>
                <div class="stat-card">
                    <h3><?php echo count($files); ?></h3>
                    <p>루트 파일</p>
                </div>
                <div class="stat-card">
                    <h3><?php echo date('Y-m-d'); ?></h3>
                    <p>최근 업데이트</p>
                </div>
            </div>
        </div>
        
        <div class="footer">
            <p>📅 생성일: <?php echo date('Y-m-d H:i:s'); ?></p>
            <p>📁 경로: <?php echo realpath($currentDir); ?></p>
        </div>
    </div>
    
    <script>
        // 페이지 로드 시 애니메이션 효과
        document.addEventListener('DOMContentLoaded', function() {
            const cards = document.querySelectorAll('.folder-card, .file-item');
            cards.forEach((card, index) => {
                card.style.opacity = '0';
                card.style.transform = 'translateY(20px)';
                
                setTimeout(() => {
                    card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
                    card.style.opacity = '1';
                    card.style.transform = 'translateY(0)';
                }, index * 100);
            });
        });
    </script>
</body>
</html> 