/* 配料先知 PC端样式 */

/* CSS变量 */
:root {
  --primary-color: #2ECC71;
  --primary-dark: #27AE60;
  --primary-light: #58D68D;
  --danger-color: #E74C3C;
  --warning-color: #F39C12;
  --info-color: #3498DB;
  --success-color: #2ECC71;
  
  --text-primary: #2C3E50;
  --text-secondary: #7F8C8D;
  --text-muted: #95A5A6;
  
  --bg-primary: #F8FAFB;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F1F3F5;
  
  --border-color: #E9ECEF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input, textarea {
  font-family: inherit;
  border: none;
  outline: none;
}

/* 布局 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* 头部导航 */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 18px;
}

.logo-text {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.nav-item {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.user-name {
  font-size: 14px;
  color: var(--text-primary);
}

.login-btn {
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* 主内容区 */
.main {
  padding: 40px 0;
  min-height: calc(100vh - 64px - 80px);
}

/* 卡片样式 */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* 按钮样式 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-outline {
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  background: transparent;
}

.btn-outline:hover {
  background: var(--primary-color);
  color: white;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background: #C0392B;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
}

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

/* 表单样式 */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  transition: all 0.2s;
}

.form-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

/* 上传区域 */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-tertiary);
}

.upload-area:hover {
  border-color: var(--primary-color);
  background: rgba(46, 204, 113, 0.05);
}

.upload-area.dragover {
  border-color: var(--primary-color);
  background: rgba(46, 204, 113, 0.1);
}

.upload-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-icon svg {
  width: 40px;
  height: 40px;
  color: white;
}

.upload-text {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 14px;
  color: var(--text-muted);
}

/* 识别结果 */
.result-card {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-radius: var(--radius-xl);
  padding: 40px;
  color: white;
  margin-bottom: 24px;
}

.result-score {
  text-align: center;
  margin-bottom: 24px;
}

.score-value {
  font-size: 72px;
  font-weight: bold;
  line-height: 1;
}

.score-label {
  font-size: 18px;
  opacity: 0.9;
  margin-top: 8px;
}

.result-level {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.level-badge {
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-xl);
  font-size: 16px;
  font-weight: 500;
}

.risk-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(231, 76, 60, 0.8);
  border-radius: var(--radius-md);
  font-size: 14px;
}

/* 配料列表 */
.ingredient-list {
  display: grid;
  gap: 12px;
}

.ingredient-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.ingredient-item:hover {
  background: var(--border-color);
  transform: translateX(4px);
}

.ingredient-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ingredient-icon.safe {
  background: rgba(46, 204, 113, 0.1);
  color: var(--success-color);
}

.ingredient-icon.warning {
  background: rgba(243, 156, 18, 0.1);
  color: var(--warning-color);
}

.ingredient-icon.danger {
  background: rgba(231, 76, 60, 0.1);
  color: var(--danger-color);
}

.ingredient-info {
  flex: 1;
}

.ingredient-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.ingredient-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* 历史记录列表 */
.record-list {
  display: grid;
  gap: 16px;
}

.record-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s;
}

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

.record-score {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
}

.record-score.excellent {
  background: linear-gradient(135deg, var(--success-color), #27AE60);
}

.record-score.good {
  background: linear-gradient(135deg, var(--info-color), #2980B9);
}

.record-score.normal {
  background: linear-gradient(135deg, var(--warning-color), #D68910);
}

.record-score.caution {
  background: linear-gradient(135deg, var(--danger-color), #C0392B);
}

.record-info {
  flex: 1;
}

.record-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.record-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.record-tag {
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.record-date {
  font-size: 13px;
  color: var(--text-muted);
}

.record-collect {
  color: var(--text-muted);
  transition: all 0.2s;
}

.record-collect.active {
  color: var(--primary-color);
}

/* 百科搜索 */
.search-box {
  position: relative;
  max-width: 600px;
  margin: 0 auto 32px;
}

.search-input {
  width: 100%;
  padding: 16px 20px 16px 50px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-xl);
  font-size: 16px;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* 健康模式选择 */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.mode-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
}

.mode-item:hover {
  background: var(--border-color);
}

.mode-item.active {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
}

.mode-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.mode-name {
  font-size: 14px;
  font-weight: 500;
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 36px;
  font-weight: bold;
  color: var(--primary-color);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 14px;
  color: var(--text-muted);
}

/* 登录页面 */
.login-container {
  max-width: 400px;
  margin: 80px auto;
}

.login-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 36px;
}

.login-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.code-input-group {
  display: flex;
  gap: 12px;
}

.code-input-group .form-input {
  flex: 1;
}

.code-btn {
  white-space: nowrap;
  min-width: 120px;
}

.code-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 底部 */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 24px 0;
  text-align: center;
}

.footer-text {
  font-size: 14px;
  color: var(--text-muted);
}

/* 加载动画 */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 40px;
}

.empty-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--text-muted);
}

.empty-text {
  font-size: 16px;
  color: var(--text-muted);
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--text-primary);
  color: white;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 1000;
  animation: fadeInDown 0.3s ease;
}

.toast.success {
  background: var(--success-color);
}

.toast.error {
  background: var(--danger-color);
}

.toast.warning {
  background: var(--warning-color);
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* 图片预览 */
.preview-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.image-preview-container {
  position: relative;
  display: inline-block;
}

.remove-image {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 28px;
  height: 28px;
  background: var(--danger-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

/* 响应式 */
@media (max-width: 768px) {
  .header .container {
    flex-wrap: wrap;
    height: auto;
    padding: 16px 24px;
  }
  
  .nav {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
  }
  
  .mode-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
