health-assistant / frontend /src /pages /AIFoodAnalyzer.css
yuting111222's picture
fix: 修正 FastAPI 導入與前端 UI 還原為原始設計
4199d74
/* 全局樣式 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
/* 主體樣式 */
body {
font-family: 'Arial', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 1rem;
}
.app-container {
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
padding: 2rem;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
max-width: 500px;
width: 100%;
max-height: 90vh;
overflow-y: auto;
}
.header {
text-align: center;
margin-bottom: 2rem;
}
.title {
color: #333;
font-size: 1.8rem;
font-weight: bold;
margin-bottom: 0.5rem;
}
.subtitle {
color: #666;
font-size: 0.9rem;
}
.tab-nav {
display: flex;
background: rgba(102, 126, 234, 0.1);
border-radius: 15px;
margin-bottom: 2rem;
padding: 0.3rem;
}
.tab-btn {
flex: 1;
padding: 0.8rem;
border: none;
background: transparent;
border-radius: 12px;
font-weight: bold;
cursor: pointer;
transition: all 0.3s;
color: #666;
}
.tab-btn.active {
background: linear-gradient(45deg, #667eea, #764ba2);
color: white;
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}
/* 個人資料表單 */
.profile-form {
display: grid;
gap: 1.5rem;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
font-weight: bold;
color: #333;
margin-bottom: 0.5rem;
font-size: 0.9rem;
}
.input-group input, .input-group select {
padding: 12px;
border: 2px solid #e0e0e0;
border-radius: 10px;
font-size: 1rem;
transition: border-color 0.3s;
}
.input-group input:focus, .input-group select:focus {
outline: none;
border-color: #667eea;
}
.input-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.save-profile-btn {
background: linear-gradient(45deg, #43cea2, #185a9d);
color: white;
border: none;
padding: 15px;
border-radius: 15px;
font-weight: bold;
cursor: pointer;
font-size: 1rem;
transition: transform 0.2s;
}
.save-profile-btn:hover {
transform: translateY(-2px);
}
/* 食物分析區域 */
.camera-container {
position: relative;
margin-bottom: 1.5rem;
text-align: center;
}
.controls {
display: flex;
gap: 1rem;
justify-content: center;
margin: 1.5rem 0;
flex-wrap: wrap;
}
button {
background: linear-gradient(45deg, #667eea, #764ba2);
color: white;
border: none;
padding: 12px 20px;
border-radius: 25px;
cursor: pointer;
font-weight: bold;
transition: transform 0.2s;
font-size: 0.9rem;
}
button:hover {
transform: translateY(-2px);
}
button:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.upload-btn {
background: linear-gradient(45deg, #43cea2, #185a9d);
}
.file-input {
display: none;
}
.loading {
display: none;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 1rem 0;
text-align: center;
}
.spinner {
border: 3px solid #f3f3f3;
border-top: 3px solid #667eea;
border-radius: 50%;
width: 30px;
height: 30px;
animation: spin 1s linear infinite;
margin: 0 auto 1rem;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.result {
margin-top: 2rem;
padding: 1.5rem;
background: rgba(102, 126, 234, 0.1);
border-radius: 15px;
display: none;
}
.food-info {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
}
.food-name {
font-size: 1.3rem;
font-weight: bold;
color: #333;
}
.add-to-diary {
background: linear-gradient(45deg, #ff6b6b, #ee5a24);
padding: 8px 16px;
border-radius: 20px;
font-size: 0.8rem;
}
.nutrition-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.8rem;
margin-bottom: 1.5rem;
}
.nutrition-item {
background: white;
padding: 0.8rem;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
text-align: center;
}
.nutrition-label {
font-size: 0.9rem;
color: #666;
margin-bottom: 0.3rem;
}
.nutrition-value {
font-size: 1.1rem;
font-weight: bold;
color: #333;
}
.daily-recommendation {
background: linear-gradient(45deg, rgba(255, 107, 107, 0.1), rgba(238, 90, 36, 0.1));
padding: 1rem;
border-radius: 10px;
border-left: 4px solid #ff6b6b;
margin-top: 1.5rem;
}
.recommendation-title {
font-weight: bold;
color: #333;
margin-bottom: 0.5rem;
font-size: 0.9rem;
}
.recommendation-text {
font-size: 0.8rem;
color: #666;
line-height: 1.4;
}
/* 健康指數樣式 */
.health-indices {
display: flex;
gap: 1rem;
margin: 1rem 0 1.5rem;
}
.health-index {
flex: 1;
background: white;
padding: 0.8rem;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.index-label {
font-size: 0.8rem;
color: #666;
margin-bottom: 0.5rem;
}
.index-meter {
height: 6px;
background: #f0f0f0;
border-radius: 3px;
margin-bottom: 0.5rem;
overflow: hidden;
}
.meter-fill {
height: 100%;
width: 0%;
border-radius: 3px;
transition: width 0.5s ease;
}
.index-value {
font-size: 0.8rem;
font-weight: bold;
color: #333;
text-align: right;
}
.food-description {
background: rgba(102, 126, 234, 0.1);
padding: 1rem;
border-radius: 10px;
font-size: 0.9rem;
color: #555;
line-height: 1.5;
margin-bottom: 1rem;
}
.benefits-tags {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-bottom: 1.5rem;
}
.benefit-tag {
background: rgba(67, 206, 162, 0.1);
color: #43cea2;
padding: 0.3rem 0.8rem;
border-radius: 20px;
font-size: 0.8rem;
font-weight: 500;
display: inline-block;
}
.nutrition-section-title {
color: #333;
font-size: 1rem;
margin: 1.5rem 0 0.8rem;
}
.nutrition-details {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
margin-top: 1.5rem;
}
.nutrition-section {
background: white;
padding: 1rem;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
/* 追蹤紀錄專用樣式 */
.tracking-tab {
padding: 1.5rem;
max-width: 1200px;
margin: 0 auto;
}
.overview-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
margin-bottom: 2rem;
}
.overview-card {
background: white;
border-radius: 12px;
padding: 1.5rem;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
display: flex;
align-items: center;
transition: transform 0.2s, box-shadow 0.2s;
}
.overview-card:hover {
transform: translateY(-3px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}
.overview-label {
font-size: 0.875rem;
color: #7f8c8d;
margin-bottom: 0.25rem;
}
.overview-value {
font-size: 1.5rem;
font-weight: 700;
color: #2c3e50;
margin-bottom: 0.25rem;
}
.overview-value span {
font-size: 1rem;
color: #7f8c8d;
}
/* 進度條樣式 */
.progress-section {
display: grid;
gap: 1.25rem;
margin-bottom: 2rem;
}
.progress-row {
margin-bottom: 1rem;
}
.progress-label {
font-weight: 600;
color: #2c3e50;
margin-bottom: 0.5rem;
font-size: 0.875rem;
}
.progress-bar-bg {
height: 8px;
background: #f0f2f5;
border-radius: 4px;
overflow: hidden;
margin-bottom: 0.5rem;
}
.progress-bar-fill {
height: 100%;
border-radius: 4px;
transition: width 0.5s ease;
}
.progress-value {
color: #7f8c8d;
font-size: 0.875rem;
}
/* 食物記錄 */
.food-diary-section {
background: white;
border-radius: 12px;
padding: 1.5rem;
margin-bottom: 1.5rem;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.food-diary-title {
margin-bottom: 1.5rem;
font-size: 1.25rem;
color: #2c3e50;
}
.no-diary {
text-align: center;
padding: 3rem 1rem;
color: #7f8c8d;
}
.food-diary-list {
display: grid;
gap: 1rem;
}
.food-diary-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;
background: #f8f9fa;
border-radius: 8px;
}
.food-diary-name {
font-weight: 600;
color: #2c3e50;
}
.food-diary-time {
color: #7f8c8d;
font-size: 0.875rem;
}
.food-diary-calories {
font-weight: 600;
color: #667eea;
}
/* 圖表卡片 */
.week-chart-section {
background: white;
border-radius: 12px;
padding: 1.5rem;
margin-bottom: 1.5rem;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.week-chart-title {
margin-bottom: 1.5rem;
font-size: 1.25rem;
color: #2c3e50;
}
.week-chart-wrapper {
height: 200px;
position: relative;
}
/* 響應式設計 */
@media (max-width: 768px) {
.app-container {
max-width: 100%;
margin: 0;
border-radius: 0;
max-height: 100vh;
}
.input-row {
grid-template-columns: 1fr;
}
.health-indices {
flex-direction: column;
}
.nutrition-grid {
grid-template-columns: 1fr;
}
.overview-cards {
grid-template-columns: 1fr;
}
.controls {
flex-direction: column;
align-items: center;
}
button {
width: 100%;
max-width: 200px;
}
}
@media (max-width: 480px) {
.app-container {
padding: 1rem;
}
.title {
font-size: 1.5rem;
}
.tab-nav {
flex-direction: column;
gap: 0.5rem;
}
.tab-btn {
border-radius: 8px;
}
}