﻿@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #10B981;
    --primary-glow: rgba(16, 185, 129, 0.4);
    --dark: #111827;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --blur: blur(12px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: #F3F4F6;
    color: var(--dark);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- ANIMATED BACKGROUND --- */
.mesh-bg {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: -1;
    background: 
        radial-gradient(at 0% 0%, hsla(150,60%,85%,1) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(200,60%,85%,1) 0, transparent 50%), 
        radial-gradient(at 100% 100%, hsla(30,60%,85%,1) 0, transparent 50%),
        radial-gradient(at 0% 100%, hsla(180,60%,85%,1) 0, transparent 50%);
    background-size: 200% 200%;
    filter: blur(60px);
    animation: moveBg 15s ease infinite alternate;
}
@keyframes moveBg { 
    0% { background-position: 0% 0%; } 
    100% { background-position: 100% 100%; } 
}

/* --- APP CONTAINER --- */
#app-container {
    width: 100%;
    max-width: 480px;
    height: 90vh;
    background: var(--glass-bg);
    backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1); /* Stronger shadow */
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* --- VIEWS --- */
.view {
    display: none;
    flex-direction: column;
    height: 100%;
    padding: 24px;
    overflow-y: auto;
    animation: fadeIn 0.5s ease;
}
.view.active { display: flex; }

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

/* --- LOGIN SCREEN --- */
.login-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}
.logo-icon { 
    font-size: 64px; 
    margin-bottom: 16px; 
    color: var(--primary);
    animation: float 3s ease-in-out infinite; 
    filter: drop-shadow(0 10px 10px rgba(16, 185, 129, 0.3)); /* Logo shadow */
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
p.subtitle { color: #6B7280; margin-bottom: 32px; }

.input-group {
    position: relative;
    margin-bottom: 16px;
}
.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #9CA3AF;
    z-index: 10;
}
input {
    width: 100%;
    padding: 16px 16px 16px 48px; /* Added padding for icon */
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    background: rgba(255,255,255,0.5);
    font-size: 16px;
    transition: all 0.3s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); /* Inner shadow */
}
input:focus { 
    outline: none; 
    border-color: var(--primary); 
    background: white; 
    box-shadow: 0 0 0 4px var(--primary-glow), 0 4px 12px rgba(0,0,0,0.05); 
}

button {
    width: 100%;
    padding: 16px;
    background: var(--dark);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Button shadow */
}
button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15); /* Hover shadow */
}
button:active { transform: scale(0.96); }

/* --- DASHBOARD --- */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.avatar { 
    width: 40px; height: 40px; 
    background: white; 
    border-radius: 12px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 20px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.stats-card {
    background: white;
    padding: 20px;
    border-radius: 20px;
    margin-bottom: 24px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1); /* Deep shadow */
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.3s;
}
.stats-card:hover { transform: translateY(-2px); }
.stat-item { text-align: center; }
.stat-val { font-size: 24px; font-weight: 800; color: var(--primary); text-shadow: 0 2px 4px rgba(16, 185, 129, 0.2); }
.stat-label { font-size: 12px; color: #6B7280; text-transform: uppercase; letter-spacing: 1px; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.action-btn {
    background: rgba(255,255,255,0.8);
    padding: 16px;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}
.action-btn:hover { 
    background: white; 
    border-color: var(--primary); 
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.15); 
}
.action-icon { font-size: 24px; margin-bottom: 8px; display: block; }

.meal-list { flex: 1; overflow-y: auto; padding-bottom: 20px; }
.meal-item {
    background: white;
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    animation: slideIn 0.4s ease forwards;
    opacity: 0; transform: translateY(20px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}
.meal-item:hover { transform: scale(1.02); }

/* --- VIEWS --- */
.view {
    display: none;
    flex-direction: column;
    height: 100%;
    padding: 24px;
    overflow-y: auto;
    animation: fadeIn 0.5s ease;
}
.view.active { display: flex; }

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

/* --- LOGIN SCREEN --- */
.login-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}
.logo-icon { 
    font-size: 64px; 
    margin-bottom: 16px; 
    color: var(--primary);
    animation: float 3s ease-in-out infinite; 
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
p.subtitle { color: #6B7280; margin-bottom: 32px; }

.input-group {
    position: relative;
    margin-bottom: 16px;
}
.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #9CA3AF;
    z-index: 10;
}
input {
    width: 100%;
    padding: 16px 16px 16px 48px; /* Added padding for icon */
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    background: rgba(255,255,255,0.5);
    font-size: 16px;
    transition: all 0.3s;
}
input:focus { outline: none; border-color: var(--primary); background: white; box-shadow: 0 0 0 4px var(--primary-glow); }

button {
    width: 100%;
    padding: 16px;
    background: var(--dark);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
button:active { transform: scale(0.96); }

/* --- DASHBOARD --- */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.avatar { width: 40px; height: 40px; background: white; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; }

.stats-card {
    background: white;
    padding: 20px;
    border-radius: 20px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.stat-item { text-align: center; }
.stat-val { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 12px; color: #6B7280; text-transform: uppercase; letter-spacing: 1px; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.action-btn {
    background: rgba(255,255,255,0.6);
    padding: 16px;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}
.action-btn:hover { background: white; border-color: var(--primary); transform: translateY(-2px); }
.action-icon { font-size: 24px; margin-bottom: 8px; display: block; }

.meal-list { flex: 1; overflow-y: auto; }
.meal-item {
    background: white;
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    animation: slideIn 0.4s ease forwards;
    opacity: 0; transform: translateY(20px);
}
@keyframes slideIn { to { opacity: 1; transform: translateY(0); } }

.meal-icon { font-size: 24px; margin-right: 16px; }
.meal-info { flex: 1; }
.meal-name { font-weight: 600; }
.meal-cals { font-weight: 700; color: var(--primary); }
.meal-insight { font-size: 12px; color: #F59E0B; font-weight: 600; margin-top: 4px; }

/* --- LOADING OVERLAY --- */
#loading-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.spinner { font-size: 48px; animation: spin 1s infinite linear; margin-bottom: 16px; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* --- SEARCH RESULTS (Spotlight Style) --- */
.search-container {
    position: relative;
    z-index: 30;
}

#searchResults {
    position: absolute; /* Float above content */
    top: 100%; /* Right below input */
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    z-index: 50;
    max-height: 0; /* Hidden by default */
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(-10px);
}

#searchResults.active {
    max-height: 300px;
    opacity: 1;
    transform: translateY(0);
    padding: 8px;
    margin-top: 8px;
    border: 1px solid rgba(0,0,0,0.05);
    overflow-y: auto; /* Allow scrolling inside results */
    pointer-events: all;
}

.search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--dark);
}

.search-item:hover {
    background: rgba(16, 185, 129, 0.1); /* Light green tint */
    transform: translateX(4px);
}

.search-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-icon {
    color: #9CA3AF;
    font-size: 14px;
}

.search-add-btn {
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s;
}

.search-item:hover .search-add-btn {
    opacity: 1;
    transform: scale(1);
}

/* --- FLOATING FOOD PATTERN --- */
.floating-pattern {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 0; 
    pointer-events: none;
    overflow: hidden;
}

.float-icon {
    position: absolute;
    color: #065F46;
    opacity: 0.15;
    font-size: 60px;
    bottom: -100px;
    animation: floatUp linear infinite;
    will-change: transform;
}

/* Randomize Positions & Speeds */
.p1 { left: 10%; animation-duration: 15s; animation-delay: 0s; }
.p2 { left: 25%; animation-duration: 18s; animation-delay: -5s; font-size: 40px; }
.p3 { left: 40%; animation-duration: 12s; animation-delay: -10s; }
.p4 { left: 55%; animation-duration: 20s; animation-delay: -2s; font-size: 70px; }
.p5 { left: 70%; animation-duration: 25s; animation-delay: -15s; }
.p6 { left: 85%; animation-duration: 14s; animation-delay: -8s; }
.p7 { left: 15%; animation-duration: 22s; animation-delay: -20s; font-size: 30px; }
.p8 { left: 80%; animation-duration: 16s; animation-delay: -12s; }
.p9 { left: 5%; animation-duration: 19s; animation-delay: -3s; font-size: 50px; }
.p10 { left: 35%; animation-duration: 23s; animation-delay: -18s; }
.p11 { left: 60%; animation-duration: 17s; animation-delay: -7s; font-size: 45px; }
.p12 { left: 90%; animation-duration: 21s; animation-delay: -11s; }

@keyframes floatUp {
    0% { 
        transform: translate(0, 0) rotate(0deg); 
        opacity: 0; 
    }
    10% { opacity: 0.15; }
    25% { transform: translate(30px, -30vh) rotate(45deg); }
    50% { transform: translate(-30px, -60vh) rotate(180deg); }
    75% { transform: translate(30px, -90vh) rotate(315deg); }
    90% { opacity: 0.15; }
    100% { 
        transform: translate(0, -120vh) rotate(360deg); 
        opacity: 0; 
    }
}
