Add Gemini Chat: conversational AI assistant for kitchen help
- Gemini star icon button next to camera in header - Full chat page with message bubbles, typing indicator - Conversation history persisted in localStorage (last 50 messages) - System context includes: full inventory with expiry dates, appliances, dietary restrictions - Multi-turn conversation with Gemini 2.0 Flash - Pre-built suggestion chips: snack, juice/smoothie, light meal, use expiring items - Clear chat button for fresh conversations - Indigo/purple themed UI matching Gemini branding - PHP gemini_chat API endpoint with inventory context injection
This commit is contained in:
@@ -113,6 +113,30 @@ body {
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-gemini-btn {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
font-size: 1.4rem;
|
||||
animation: none;
|
||||
border-width: 2px;
|
||||
background: rgba(99, 102, 241, 0.35);
|
||||
border-color: rgba(199, 210, 254, 0.6);
|
||||
}
|
||||
|
||||
.header-gemini-btn:active {
|
||||
background: rgba(99, 102, 241, 0.55);
|
||||
}
|
||||
|
||||
.gemini-icon {
|
||||
filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
|
||||
}
|
||||
|
||||
.header-scan-btn:active {
|
||||
transform: scale(0.9);
|
||||
background: rgba(255,255,255,0.4);
|
||||
@@ -2710,3 +2734,220 @@ body {
|
||||
border-radius: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ===== GEMINI CHAT ===== */
|
||||
.chat-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: calc(100vh - var(--header-height) - var(--nav-height) - 24px);
|
||||
background: var(--bg);
|
||||
border-radius: var(--radius);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chat-header-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 14px;
|
||||
background: white;
|
||||
border-bottom: 1px solid var(--border);
|
||||
border-radius: var(--radius) var(--radius) 0 0;
|
||||
}
|
||||
|
||||
.chat-header-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.chat-title {
|
||||
font-weight: 700;
|
||||
font-size: 1rem;
|
||||
color: #4338ca;
|
||||
}
|
||||
|
||||
.btn-chat-clear {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.2rem;
|
||||
cursor: pointer;
|
||||
padding: 4px 8px;
|
||||
border-radius: 8px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.btn-chat-clear:active {
|
||||
background: var(--bg);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 16px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.chat-welcome {
|
||||
text-align: center;
|
||||
padding: 30px 16px;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
.chat-welcome h3 {
|
||||
margin: 12px 0 6px;
|
||||
color: var(--text);
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.chat-welcome p {
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.5;
|
||||
max-width: 300px;
|
||||
margin: 0 auto 20px;
|
||||
}
|
||||
|
||||
.gemini-icon-lg {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
.chat-suggestions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.chat-suggestion {
|
||||
background: white;
|
||||
border: 1.5px solid #e0e7ff;
|
||||
border-radius: 20px;
|
||||
padding: 8px 14px;
|
||||
font-size: 0.82rem;
|
||||
cursor: pointer;
|
||||
color: #4338ca;
|
||||
font-weight: 500;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.chat-suggestion:active {
|
||||
background: #e0e7ff;
|
||||
transform: scale(0.97);
|
||||
}
|
||||
|
||||
.chat-bubble {
|
||||
max-width: 85%;
|
||||
padding: 10px 14px;
|
||||
border-radius: 18px;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.5;
|
||||
word-break: break-word;
|
||||
animation: chatFadeIn 0.2s ease;
|
||||
}
|
||||
|
||||
@keyframes chatFadeIn {
|
||||
from { opacity: 0; transform: translateY(8px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.chat-user {
|
||||
align-self: flex-end;
|
||||
background: #4338ca;
|
||||
color: white;
|
||||
border-bottom-right-radius: 6px;
|
||||
}
|
||||
|
||||
.chat-gemini {
|
||||
align-self: flex-start;
|
||||
background: white;
|
||||
color: var(--text);
|
||||
border-bottom-left-radius: 6px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.06);
|
||||
}
|
||||
|
||||
.chat-gemini strong {
|
||||
color: #4338ca;
|
||||
}
|
||||
|
||||
.chat-gemini ul, .chat-gemini ol {
|
||||
margin: 4px 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.chat-gemini li {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.chat-input-bar {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
background: white;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.chat-input {
|
||||
flex: 1;
|
||||
border: 1.5px solid var(--border);
|
||||
border-radius: 24px;
|
||||
padding: 10px 16px;
|
||||
font-size: 0.9rem;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.chat-input:focus {
|
||||
border-color: #6366f1;
|
||||
}
|
||||
|
||||
.btn-chat-send {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: #4338ca;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.15s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.btn-chat-send:active {
|
||||
transform: scale(0.92);
|
||||
background: #3730a3;
|
||||
}
|
||||
|
||||
.btn-chat-send:disabled {
|
||||
background: #a5b4fc;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* Typing indicator */
|
||||
.chat-typing {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.chat-typing span {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background: #a5b4fc;
|
||||
border-radius: 50%;
|
||||
animation: chatTyping 1.4s infinite;
|
||||
}
|
||||
|
||||
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
|
||||
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
|
||||
|
||||
@keyframes chatTyping {
|
||||
0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
|
||||
30% { transform: translateY(-6px); opacity: 1; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user