/* ==================== CSS 变量 ==================== */
:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #d1fae5;
    --secondary: #6366f1;
    --accent: #f59e0b;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ==================== 导航栏 ==================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.navbar.scrolled {
    box-shadow: var(--shadow);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon {
    font-size: 28px;
}

.brand-text {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
    display: none;
}

@media (min-width: 640px) {
    .brand-subtitle {
        display: inline;
    }
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
}

/* ==================== 英雄区域 ==================== */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 120px 24px 80px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #f0fdf4 0%, #eef2ff 50%, #fefce8 100%);
}

.hero-content {
    text-align: center;
    max-width: 700px;
    position: relative;
    z-index: 2;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 24px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    line-height: 1.8;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}

/* 浮动食物图标 */
.hero-visual {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.floating-food {
    position: absolute;
    font-size: 48px;
    opacity: 0.3;
    animation: float 6s ease-in-out infinite;
}

#floatingFood1 { top: 15%; left: 10%; animation-delay: 0s; }
#floatingFood2 { top: 25%; right: 12%; animation-delay: 1s; }
#floatingFood3 { top: 60%; left: 8%; animation-delay: 2s; }
#floatingFood4 { top: 70%; right: 10%; animation-delay: 3s; }
#floatingFood5 { top: 40%; left: 5%; animation-delay: 4s; }
#floatingFood6 { top: 50%; right: 8%; animation-delay: 5s; }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

/* ==================== 通用区域 ==================== */
.section-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.section-title {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 12px;
}

.section-desc {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 40px;
    font-size: 16px;
}

/* ==================== 上传区域 ==================== */
.upload-section {
    padding: 80px 0;
}

.upload-zone {
    max-width: 600px;
    margin: 0 auto;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card);
    position: relative;
    overflow: hidden;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 16px;
    transition: var(--transition);
}

.upload-zone:hover .upload-icon {
    transform: translateY(-4px);
}

.upload-placeholder h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.upload-placeholder p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.upload-preview {
    position: relative;
    width: 100%;
    max-height: 400px;
    overflow: hidden;
    border-radius: var(--radius);
}

.upload-preview img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: var(--radius);
}

.preview-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.upload-preview:hover .preview-overlay {
    opacity: 1;
}

.upload-actions {
    text-align: center;
    margin-top: 24px;
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-large {
    padding: 16px 40px;
    font-size: 18px;
    border-radius: 14px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-icon {
    font-size: 20px;
}

/* ==================== 加载状态 ==================== */
.loading-section {
    padding: 60px 0;
}

.loading-container {
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.loading-spinner {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
}

.spinner-ring {
    position: absolute;
    inset: 0;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-food {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.loading-container h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.loading-text {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.loading-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    min-width: 40px;
}

/* ==================== 结果区域 ==================== */
.result-section {
    padding: 80px 0;
}

.result-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    margin-top: 32px;
}

@media (min-width: 1024px) {
    .result-layout {
        grid-template-columns: 1fr 1fr;
    }
}

.result-image-container {
    position: sticky;
    top: 80px;
    align-self: start;
}

.result-image-wrapper {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    background: var(--bg-card);
}

.result-image-wrapper img {
    width: 100%;
    height: auto;
    display: block;
}

.result-image-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
}

.result-image-badge span {
    color: var(--primary);
}

.result-image-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: center;
}

.result-image-actions .btn-outline {
    color: var(--text-secondary);
    border-color: var(--border);
}

.result-image-actions .btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* 食物卡片 */
.food-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.food-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
    animation: slideIn 0.5s ease forwards;
    opacity: 0;
    transform: translateY(20px);
}

.food-card:nth-child(1) { animation-delay: 0.1s; }
.food-card:nth-child(2) { animation-delay: 0.2s; }
.food-card:nth-child(3) { animation-delay: 0.3s; }
.food-card:nth-child(4) { animation-delay: 0.4s; }
.food-card:nth-child(5) { animation-delay: 0.5s; }

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.food-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.food-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.food-card-name {
    display: flex;
    align-items: center;
    gap: 10px;
}

.food-card-emoji {
    font-size: 28px;
}

.food-card-title {
    font-size: 18px;
    font-weight: 700;
}

.food-card-confidence {
    font-size: 13px;
    color: var(--text-light);
    background: var(--bg);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
}

.food-card-nutrition {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.nutrition-item {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 8px;
}

.nutrition-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.nutrition-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-top: 2px;
}

.food-card-description {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* 营养汇总 */
.nutrition-summary {
    margin-top: 40px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}

.summary-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.summary-item {
    text-align: center;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
    transition: var(--transition);
}

.summary-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.summary-item-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.summary-item-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.summary-item-label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
    margin-top: 4px;
}

/* ==================== 食物数据库 ==================== */
.database-section {
    padding: 80px 0;
    background: var(--bg-card);
}

.database-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.database-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.database-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.database-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.database-card-emoji {
    font-size: 32px;
}

.database-card-name {
    font-size: 18px;
    font-weight: 700;
}

.database-card-nutrition {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.database-nutrition-item {
    display: flex;
    flex-direction: column;
}

.database-nutrition-label {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
}

.database-nutrition-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.database-card-desc {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ==================== 模态框 ==================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: scaleIn 0.3s ease;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.7;
}

.modal-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ==================== 页脚 ==================== */
.footer {
    background: var(--text);
    color: white;
    padding: 32px 24px;
    text-align: center;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
}

.footer p {
    font-size: 14px;
    opacity: 0.8;
}

.footer-tech {
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.5;
}

/* ==================== Toast ==================== */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .hero-section {
        padding: 100px 16px 60px;
    }

    .hero-stats {
        gap: 24px;
    }

    .upload-zone {
        padding: 40px 20px;
    }

    .result-layout {
        grid-template-columns: 1fr;
    }

    .food-card-nutrition {
        grid-template-columns: 1fr;
    }

    .database-grid {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}