<!DOCTYPE html>

<html lang="ko">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Goshen AI Food Analyzer</title>

    <script src="https://cdn.tailwindcss.com"></script>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">

    <style>

        @import url('https://fonts.googleapis.com/css2?family=Pretendard:wght@400;600;800&display=swap');

        body { font-family: 'Pretendard', sans-serif; }

        .gradient-brand { background: linear-gradient(135deg, #8e2de2 0%, #4a00e0 100%); }

        .btn-active { border-color: #4a00e0 !important; background-color: #f5f3ff !important; color: #4a00e0 !important; font-weight: 800; }

        @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

        .animate-fadeIn { animation: fadeIn 0.5s ease-out forwards; }

    </style>

</head>

<body class="bg-slate-100 min-h-screen flex justify-center items-start sm:items-center p-0 sm:p-4">


    <div class="w-full max-w-md bg-white min-h-screen sm:min-h-[850px] sm:rounded-[40px] shadow-2xl overflow-hidden flex flex-col relative">

        

        <header class="gradient-brand text-white p-8 pb-12 rounded-b-[40px]">

            <div class="flex justify-between items-center mb-4">

                <span class="text-xs bg-white/20 px-3 py-1 rounded-full backdrop-blur-md italic">Powered by Goshen AI</span>

                <i class="fas fa-ellipsis-h opacity-70"></i>

            </div>

            <h1 class="text-3xl font-extrabold tracking-tight">AI 칼로리 분석</h1>

            <p class="text-white/70 text-sm mt-2 font-light">오늘의 식단을 기록하고 뷰티 밸런스를 맞추세요.</p>

        </header>


        <main class="px-6 -mt-8 flex-1 space-y-8 pb-10">

            

            <div class="bg-white rounded-3xl p-4 shadow-xl border border-gray-50">

                <p class="text-sm font-bold text-gray-800 mb-3 flex items-center gap-2">

                    <span class="w-1.5 h-1.5 rounded-full bg-purple-600"></span> 음식 사진 첨부

                </p>

                <div id="dropzone" class="relative group h-52 w-full border-2 border-dashed border-gray-200 rounded-2xl flex flex-col items-center justify-center cursor-pointer transition-all hover:border-purple-400 hover:bg-purple-50">

                    <input type="file" id="fileInput" class="hidden" accept="image/*">

                    

                    <div id="uploadPlaceholder" class="text-center">

                        <div class="w-14 h-14 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-3 group-hover:scale-110 transition-transform">

                            <i class="fas fa-camera text-purple-600 text-xl"></i>

                        </div>

                        <p class="text-sm text-gray-500 font-medium">사진을 터치하여 업로드</p>

                    </div>


                    <div id="previewContainer" class="hidden absolute inset-0 p-2">

                        <img id="imagePreview" class="w-full h-full object-cover rounded-xl shadow-inner">

                        <button onclick="resetUpload(event)" class="absolute top-4 right-4 bg-black/50 text-white w-8 h-8 rounded-full text-xs backdrop-blur-md">

                            <i class="fas fa-times"></i>

                        </button>

                    </div>

                </div>

            </div>


            <div class="space-y-3">

                <p class="text-sm font-bold text-gray-800 flex items-center gap-2">

                    <span class="w-1.5 h-1.5 rounded-full bg-purple-600"></span> 식사 시간

                </p>

                <div class="grid grid-cols-3 gap-3">

                    <button data-type="아침" onclick="selectMeal(this)" class="meal-btn h-14 rounded-2xl border border-gray-200 bg-white text-gray-500 transition-all active:scale-95">아침</button>

                    <button data-type="점심" onclick="selectMeal(this)" class="meal-btn h-14 rounded-2xl border border-gray-200 bg-white text-gray-500 transition-all active:scale-95">점심</button>

                    <button data-type="저녁" onclick="selectMeal(this)" class="meal-btn h-14 rounded-2xl border border-gray-200 bg-white text-gray-500 transition-all active:scale-95">저녁</button>

                </div>

            </div>


            <button id="analyzeBtn" onclick="startAnalysis()" disabled class="w-full h-16 rounded-2xl bg-gray-200 text-gray-400 font-bold text-lg transition-all shadow-lg shadow-purple-200/50 disabled:cursor-not-allowed">

                분석 시작하기

            </button>


            <div id="resultArea" class="hidden animate-fadeIn pb-10">

                <div class="bg-gradient-to-br from-slate-900 to-slate-800 rounded-[30px] p-6 text-white shadow-2xl relative overflow-hidden">

                    <div class="absolute top-0 right-0 w-32 h-32 bg-white/5 rounded-full -mr-16 -mt-16"></div>

                    <div class="flex justify-between items-start mb-6">

                        <div>

                            <p id="resTag" class="text-[10px] uppercase tracking-widest text-purple-400 font-bold mb-1">Diet Analysis Report</p>

                            <h2 class="text-xl font-bold" id="resTitle">아침 식사 분석 결과</h2>

                        </div>

                        <i class="fas fa-check-circle text-green-400"></i>

                    </div>

                    

                    <div class="flex items-baseline gap-2 mb-4">

                        <span id="resKcal" class="text-5xl font-black italic tracking-tighter">520</span>

                        <span class="text-xl opacity-60">kcal</span>

                    </div>


                    <div class="grid grid-cols-3 gap-2 text-center text-[11px]">

                        <div class="bg-white/10 p-2 rounded-xl">탄수화물<br><span class="font-bold text-sm">42g</span></div>

                        <div class="bg-white/10 p-2 rounded-xl">단백질<br><span class="font-bold text-sm">28g</span></div>

                        <div class="bg-white/10 p-2 rounded-xl">지방<br><span class="font-bold text-sm">12g</span></div>

                    </div>

                    

                    <p class="mt-6 text-sm text-gray-300 leading-relaxed italic border-l-2 border-purple-500 pl-3">

                        "고단백 식단입니다! 피부 탄력 유지에 아주 좋은 선택이네요."

                    </p>

                </div>

            </div>


        </main>

    </div>


    <script>

        const fileInput = document.getElementById('fileInput');

        const dropzone = document.getElementById('dropzone');

        const previewContainer = document.getElementById('previewContainer');

        const imagePreview = document.getElementById('imagePreview');

        const uploadPlaceholder = document.getElementById('uploadPlaceholder');

        const analyzeBtn = document.getElementById('analyzeBtn');

        const resultArea = document.getElementById('resultArea');

        

        let selectedType = "";


        // 이미지 파일 처리

        dropzone.onclick = () => fileInput.click();


        fileInput.onchange = (e) => {

            const file = e.target.files[0];

            if (file && file.type.startsWith('image/')) {

                const reader = new FileReader();

                reader.onload = (event) => {

                    imagePreview.src = event.target.result;

                    previewContainer.classList.remove('hidden');

                    uploadPlaceholder.classList.add('hidden');

                    validateForm();

                };

                reader.readAsDataURL(file);

            }

        };


        // 업로드 리셋

        function resetUpload(e) {

            e.stopPropagation();

            fileInput.value = "";

            previewContainer.classList.add('hidden');

            uploadPlaceholder.classList.remove('hidden');

            validateForm();

        }


        // 식사 선택 기능

        function selectMeal(btn) {

            document.querySelectorAll('.meal-btn').forEach(b => b.classList.remove('btn-active'));

            btn.classList.add('btn-active');

            selectedType = btn.getAttribute('data-type');

            validateForm();

        }


        // 분석 버튼 활성화 체크

        function validateForm() {

            if (fileInput.files.length > 0 && selectedType !== "") {

                analyzeBtn.disabled = false;

                analyzeBtn.classList.remove('bg-gray-200', 'text-gray-400');

                analyzeBtn.classList.add('gradient-brand', 'text-white');

            } else {

                analyzeBtn.disabled = true;

                analyzeBtn.classList.add('bg-gray-200', 'text-gray-400');

                analyzeBtn.classList.remove('gradient-brand', 'text-white');

            }

        }


        // 분석 시뮬레이션

        function startAnalysis() {

            analyzeBtn.disabled = true;

            analyzeBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> AI 인식 중...';

            

            // 결과 창 가리고 시작 (재분석 시 대비)

            resultArea.classList.add('hidden');


            setTimeout(() => {

                analyzeBtn.innerHTML = '분석 완료';

                document.getElementById('resTitle').innerText = `${selectedType} 식사 분석 결과`;

                

                // 임의의 칼로리 생성 (테스트용)

                const randomKcal = Math.floor(Math.random() * (700 - 300 + 1)) + 300;

                document.getElementById('resKcal').innerText = randomKcal;


                resultArea.classList.remove('hidden');

                

                // 결과창으로 부드럽게 스크롤

                window.scrollTo({

                    top: document.body.scrollHeight,

                    behavior: 'smooth'

                });

            }, 1800);

        }

    </script>

</body>

</html>