/* ════════════════════════════════════════
   PN Personalized Nutrition Platform - Main Stylesheet
   Theme: Medical Health / Teal-Green Primary
   ════════════════════════════════════════ */

:root {
  --primary: #00A896;
  --primary-dark: #007F73;
  --primary-light: #02C39A;
  --secondary: #F6AA1C;
  --secondary-light: #FFD166;
  --accent: #E85D75;
  --bg: #F0F5F4;
  --bg-white: #FFFFFF;
  --text: #2D3436;
  --text-secondary: #636E72;
  --text-light: #B2BEC3;
  --border: #DFE6E9;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ─── Layout ─── */
.app-container { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: linear-gradient(180deg, #00A896 0%, #007F73 100%); color: white; position: fixed; height: 100vh; overflow-y: auto; z-index: 100; transition: var(--transition); }
.sidebar-header { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.15); text-align: center; }
.sidebar-logo { font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.sidebar-logo small { display: block; font-size: 11px; opacity: 0.7; margin-top: 4px; letter-spacing: 2px; }
.sidebar-nav { padding: 16px 0; }
.nav-section-title { padding: 10px 20px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.5; font-weight: 600; }
.nav-item { display: flex; align-items: center; padding: 10px 20px; color: rgba(255,255,255,0.8); text-decoration: none; transition: var(--transition); cursor: pointer; font-size: 14px; gap: 10px; border-left: 3px solid transparent; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.12); color: white; border-left-color: var(--secondary); }
.nav-item .icon { width: 20px; text-align: center; font-size: 16px; }

.main-content { flex: 1; margin-left: 260px; min-height: 100vh; }
.topbar { background: var(--bg-white); padding: 16px 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 18px; font-weight: 600; color: var(--text); }
.breadcrumb { font-size: 13px; color: var(--text-secondary); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; cursor: pointer; }

.content-area { padding: 28px; max-width: 1400px; }

/* ─── Cards ─── */
.card { background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 16px; font-weight: 600; }
.card-body { padding: 24px; }

/* ─── Stats Cards ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card { background: var(--bg-white); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; transition: var(--transition); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.stat-icon.blue { background: #E3F2FD; color: #1976D2; }
.stat-icon.green { background: #E8F5E9; color: #388E3C; }
.stat-icon.orange { background: #FFF3E0; color: #F57C00; }
.stat-icon.red { background: #FFEBEE; color: #D32F2F; }
.stat-info h3 { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-info p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Tables ─── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: #FAFBFC; padding: 12px 16px; text-align: left; font-size: 13px; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.data-table tr:hover td { background: #FAFCFD; }
.table-actions { display: flex; gap: 6px; }

/* ─── Buttons ─── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; cursor: pointer; border: none; transition: var(--transition); text-decoration: none; line-height: 1.5; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-accent { background: var(--secondary); color: var(--text); }
.btn-danger { background: var(--accent); color: white; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-label .required { color: var(--accent); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; transition: var(--transition); outline: none; background: var(--bg-white);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,168,150,0.12); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* ─── Tags & Badges ─── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-success { background: #E8F5E9; color: #2E7D32; }
.badge-warning { background: #FFF3E0; color: #E65100; }
.badge-danger { background: #FFEBEE; color: #C62828; }
.badge-info { background: #E3F2FD; color: #1565C0; }
.tag { display: inline-block; padding: 3px 10px; background: #F0F5F4; border-radius: 6px; font-size: 12px; color: var(--text-secondary); margin: 2px; }

/* ─── Steps / Progress ─── */
.steps-container { display: flex; align-items: center; margin: 28px 0; padding: 20px; background: var(--bg-white); border-radius: var(--radius); }
.step { flex: 1; text-align: center; position: relative; }
.step:not(:last-child)::after { content: ''; position: absolute; top: 22px; left: 60%; width: 80%; height: 2px; background: var(--border); }
.step.completed:not(:last-child)::after { background: var(--primary); }
.step-number { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; font-weight: 600; font-size: 16px; border: 2px solid var(--border); background: var(--bg-white); color: var(--text-secondary); transition: var(--transition); }
.step.active .step-number { background: var(--primary); border-color: var(--primary); color: white; }
.step.completed .step-number { background: var(--primary); border-color: var(--primary); color: white; }
.step-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.step.active .step-label { color: var(--primary); }
/* 可点击返回的步骤（已完成步骤） */
.step.clickable { cursor: pointer; }
.step.clickable:hover .step-number { transform: scale(1.08); box-shadow: 0 0 0 4px rgba(0,168,150,0.15); border-color: var(--primary); }
.step.clickable:hover .step-label { color: var(--primary); }

/* ─── Modal ─── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: var(--bg-white); border-radius: var(--radius); width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-light); line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Landing Page ─── */
.landing-hero { background: linear-gradient(135deg, #00A896 0%, #007F73 50%, #005F56 100%); color: white; padding: 100px 40px 80px; text-align: center; position: relative; overflow: hidden; }
.landing-hero::before { content: ''; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); }
.landing-hero h1 { font-size: 42px; font-weight: 800; margin-bottom: 16px; letter-spacing: -0.5px; }
.landing-hero p { font-size: 20px; opacity: 0.9; max-width: 650px; margin: 0 auto 32px; line-height: 1.7; }
.landing-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; padding: 60px 40px; max-width: 1200px; margin: 0 auto; }
.feature-card { background: var(--bg-white); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); transition: var(--transition); }
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.feature-icon { font-size: 40px; margin-bottom: 16px; }
.feature-card h3 { font-size: 18px; margin-bottom: 10px; }
.feature-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.7; }

/* ─── Login Page ─── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #00A896 0%, #007F73 100%); padding: 20px; }
.login-card { background: var(--bg-white); border-radius: 16px; padding: 48px 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 26px; color: var(--primary); }
.login-logo p { color: var(--text-secondary); font-size: 14px; margin-top: 6px; }

/* ─── Tabs ─── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab { padding: 12px 24px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition); }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Risk Indicators ─── */
.risk-high { color: var(--accent); font-weight: 600; }
.risk-medium { color: var(--secondary); font-weight: 600; }
.risk-low { color: var(--primary); font-weight: 600; }
.abnormal-up { color: var(--accent); }
.abnormal-down { color: #2980B9; }

/* ─── Formula Table ─── */
.formula-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.formula-table th { background: #F8FAFA; padding: 12px 16px; text-align: left; font-size: 13px; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--primary); }
.formula-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.formula-table tr:last-child td { border-bottom: none; }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .sidebar.open { transform: translateX(0); }
}
@media (max-width: 768px) {
  .content-area { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .landing-hero h1 { font-size: 28px; }
  .landing-hero { padding: 60px 20px 50px; }
}

/* ─── Utilities ─── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; } .flex-col { flex-direction: column; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.hidden { display: none !important; }
.text-sm { font-size: 13px; } .text-xs { font-size: 12px; } .text-lg { font-size: 18px; } .text-xl { font-size: 22px; }
.font-bold { font-weight: 700; } .font-medium { font-weight: 500; }
.text-primary { color: var(--primary); } .text-secondary { color: var(--text-secondary); } .text-muted { color: var(--text-light); }
.w-full { width: 100%; }

/* ─── Loading & Empty States ─── */
.loading-spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-secondary); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }

/* ─── Toast Notification ─── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 14px 20px; border-radius: var(--radius-sm); color: white; font-size: 14px; box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; min-width: 280px; }
.toast.success { background: #2E7D32; }
.toast.error { background: #C62828; }
.toast.info { background: #1565C0; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Pagination ─── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 20px; }
.pagination button { padding: 7px 14px; border: 1px solid var(--border); background: var(--bg-white); border-radius: 6px; cursor: pointer; font-size: 13px; transition: var(--transition); }
.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Search Bar ─── */
.search-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.search-bar input { flex: 1; max-width: 360px; }

/* ─── OCR identifying mask ─── */
#ocrMask {
  position: fixed; inset: 0; z-index: 9999;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.82); backdrop-filter: blur(4px);
}
#ocrMask .ocr-spinner {
  width: 54px; height: 54px; border: 5px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin-bottom: 18px;
}
#ocrMask .ocr-text { font-size: 18px; font-weight: 600; color: var(--primary); }
#ocrMask .ocr-sub { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* ─── OCR identify button pulse ─── */
.btn.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 25, 118, 110), 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(var(--primary-rgb, 25, 118, 110), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb, 25, 118, 110), 0); }
}
