* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 
    'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

/* 头部样式 */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 40px 30px;
  text-align: center;
}

.header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
  font-weight: 700;
}

.subtitle {
  font-size: 1.1em;
  opacity: 0.95;
  font-weight: 300;
}

/* 标签页导航 */
.tabs {
  display: flex;
  background: #f8f9fa;
  border-bottom: 2px solid #e9ecef;
  padding: 0 20px;
}

.tab-btn {
  flex: 1;
  padding: 15px 20px;
  background: none;
  border: none;
  font-size: 1em;
  font-weight: 600;
  color: #6c757d;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

.tab-btn:hover {
  color: #667eea;
  background: rgba(102, 126, 234, 0.05);
}

.tab-btn.active {
  color: #667eea;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: #667eea;
}

/* 标签页内容 */
.tab-content {
  display: none;
  padding: 30px;
  animation: fadeIn 0.3s;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 搜索栏 */
.search-section {
  margin-bottom: 20px;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 15px 20px;
  font-size: 1em;
  border: 2px solid #e9ecef;
  border-radius: 50px;
  outline: none;
  transition: all 0.3s;
}

.search-box input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

/* 分类筛选 */
.category-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.category-btn {
  padding: 8px 20px;
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 25px;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 500;
}

.category-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.category-btn.active {
  background: #667eea;
  border-color: #667eea;
  color: white;
}

/* 排序按钮 */
.sort-btns {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
}

.sort-btn {
  padding: 10px 25px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 25px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.sort-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.sort-btn:active {
  transform: translateY(0);
}

/* GI和GL值说明 */
.gi-info {
  display: flex;
  justify-content: center;
  gap: 40px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.info-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.info-section strong {
  color: #495057;
  font-size: 1em;
  white-space: nowrap;
}

.gi-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
}

.gi-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.gi-low .gi-dot {
  background: #52c41a;
}

.gi-medium .gi-dot {
  background: #faad14;
}

.gi-high .gi-dot {
  background: #f5222d;
}

/* 食物列表 */
.food-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.food-card {
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 15px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.food-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  border-color: #667eea;
}

.food-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.food-name {
  font-size: 1.3em;
  font-weight: 700;
  color: #212529;
}

.food-category {
  background: #667eea;
  color: white;
  padding: 4px 12px;
  border-radius: 15px;
  font-size: 0.85em;
  font-weight: 500;
}

.food-gi {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.food-gl {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.gi-badge {
  padding: 6px 15px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.95em;
  color: white;
}

.gl-badge {
  padding: 6px 15px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.95em;
  color: white;
}

.gi-badge.low, .gl-badge.low {
  background: #52c41a;
}

.gi-badge.medium, .gl-badge.medium {
  background: #faad14;
}

.gi-badge.high, .gl-badge.high {
  background: #f5222d;
}

.gi-value {
  font-size: 1.1em;
  font-weight: 600;
  color: #495057;
}

.gl-value {
  font-size: 1.1em;
  font-weight: 600;
  color: #495057;
}

.food-nutrients {
  display: flex;
  gap: 15px;
  margin-top: 10px;
  font-size: 0.9em;
  color: #6c757d;
}

.nutrient-item {
  display: flex;
  flex-direction: column;
}

.nutrient-label {
  font-size: 0.85em;
  color: #adb5bd;
}

.nutrient-value {
  font-weight: 600;
  color: #495057;
}

/* 计算器部分 */
.calculator-section {
  max-width: 600px;
  margin: 0 auto;
}

.calculator-section h2 {
  text-align: center;
  color: #212529;
  margin-bottom: 10px;
  font-size: 2em;
}

.calc-desc {
  text-align: center;
  color: #6c757d;
  margin-bottom: 20px;
}

.calc-form {
  background: #f8f9fa;
  padding: 30px;
  border-radius: 15px;
  margin-bottom: 30px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #495057;
}

.food-select {
  width: 100%;
  padding: 12px 15px;
  font-size: 1em;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  background: white;
  cursor: pointer;
  outline: none;
  transition: all 0.3s;
}

.food-select:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.food-select:disabled {
  background: #f8f9fa;
  cursor: not-allowed;
  opacity: 0.6;
}

/* 可搜索输入框样式 */
.food-input {
  cursor: text;
  transition: all 0.3s;
}

.food-input::placeholder {
  color: #adb5bd;
  opacity: 1;
}

.food-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(0.5);
  transition: all 0.3s;
}

.food-input::-webkit-calendar-picker-indicator:hover {
  filter: invert(0.3);
}

/* 输入验证状态 */
.food-input:valid {
  border-color: #52c41a;
}

.food-input:invalid {
  border-color: #f5222d;
}

/* datalist样式优化 */
datalist {
  display: none;
}

/* 输入提示效果 */
.food-input:focus::-webkit-calendar-picker-indicator {
  animation: bounce 0.5s ease;
}

@keyframes bounce {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

.input-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-group input {
  flex: 1;
  padding: 12px 15px;
  font-size: 1em;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  outline: none;
  transition: all 0.3s;
}

.input-group input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.input-group .unit {
  font-weight: 600;
  color: #6c757d;
}

.divider {
  text-align: center;
  margin: 25px 0;
  font-size: 1.2em;
  color: #667eea;
  font-weight: 600;
}

.calc-btn {
  width: 100%;
  padding: 15px;
  font-size: 1.1em;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s;
}

.calc-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.calc-btn:active {
  transform: translateY(0);
}

/* 换算结果 */
.calc-result {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 40px;
  border-radius: 20px;
  animation: slideIn 0.5s;
  box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.calc-result h3 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 1.1em;
  opacity: 0.85;
  font-weight: 500;
  letter-spacing: 1px;
}

.result-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  margin-bottom: 30px;
}

.result-item {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  padding: 30px 25px;
  border-radius: 15px;
  text-align: center;
  flex: 1;
  max-width: 220px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s;
}

.result-item:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.05);
}

.result-label {
  font-size: 0.85em;
  opacity: 0.85;
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.result-value {
  font-size: 2.2em;
  font-weight: 800;
  line-height: 1.3;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.result-value .food-name-display {
  display: block;
  font-size: 0.6em;
  font-weight: 600;
  margin-bottom: 8px;
  opacity: 0.95;
}

.result-value .weight-display {
  display: block;
  font-size: 1em;
  font-weight: 800;
}

.result-value .portion-display {
  display: block;
  font-size: 0.5em;
  opacity: 0.8;
  margin-top: 8px;
  font-weight: 500;
}

.result-arrow {
  font-size: 2.5em;
  opacity: 0.9;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.result-details {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: 20px;
  border-radius: 12px;
  margin-top: 25px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.result-details p {
  margin: 8px 0;
  font-size: 0.9em;
  opacity: 0.9;
  line-height: 1.6;
}

.result-details strong {
  font-weight: 600;
  opacity: 1;
}

/* 热量信息显示 */
.energy-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.energy-icon {
  font-size: 3.5em;
  animation: flicker 1.5s infinite alternate;
}

@keyframes flicker {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  100% {
    transform: scale(1.1);
    filter: brightness(1.2);
  }
}

.energy-text {
  text-align: left;
}

.energy-label {
  font-size: 0.85em;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
  margin-bottom: 8px;
}

.energy-value {
  font-size: 2em;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  margin-bottom: 5px;
}

.energy-note {
  font-size: 0.85em;
  opacity: 0.8;
  font-style: italic;
}

/* 换算总结突出显示 */
.result-summary {
  background: rgba(255, 255, 255, 0.25) !important;
  backdrop-filter: blur(10px);
  padding: 15px 20px !important;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  font-size: 1.05em !important;
  margin-bottom: 15px !important;
}

.result-summary strong {
  font-size: 1.1em;
}

/* 使用说明 */
.about-section {
  max-width: 800px;
  margin: 0 auto;
}

.about-section h2 {
  color: #212529;
  margin-bottom: 30px;
  font-size: 2em;
  text-align: center;
}

.info-card {
  background: #f8f9fa;
  padding: 25px;
  border-radius: 15px;
  margin-bottom: 20px;
  border-left: 4px solid #667eea;
}

.info-card h3 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 1.4em;
  font-weight: 700;
  border-bottom: 2px solid #667eea;
  padding-bottom: 10px;
}

.info-card h4 {
  color: #495057;
  margin: 20px 0 12px 0;
  font-size: 1.1em;
  font-weight: 600;
}

.info-card p {
  color: #495057;
  margin-bottom: 15px;
  line-height: 1.8;
}

.info-card ul,
.info-card ol {
  padding-left: 25px;
  color: #495057;
}

.info-card li {
  margin: 10px 0;
  line-height: 1.8;
}

.info-card ul ul,
.info-card ol ul {
  margin-top: 8px;
  margin-bottom: 8px;
}

/* 公式显示框 */
.formula {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  border-radius: 12px;
  margin: 15px 0;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.formula p {
  color: white;
  font-size: 1.1em;
  margin: 0;
  text-align: center;
  font-weight: 600;
}

.formula-note {
  font-size: 0.9em !important;
  opacity: 0.9;
  margin-top: 10px !important;
  font-weight: 400 !important;
  line-height: 1.6 !important;
}

/* 原理显示框 */
.principle {
  background: linear-gradient(135deg, #52c41a 0%, #73d13d 100%);
  color: white;
  padding: 20px;
  border-radius: 12px;
  margin: 15px 0;
  text-align: center;
  box-shadow: 0 4px 15px rgba(82, 196, 26, 0.3);
}

.principle p {
  color: white;
  font-size: 1.2em;
  margin: 5px 0;
  font-weight: 600;
}

.principle p:first-child {
  font-size: 1.5em;
  font-weight: 800;
}

.tip {
  background: rgba(102, 126, 234, 0.1);
  padding: 15px;
  border-radius: 8px;
  margin-top: 15px;
  border-left: 4px solid #667eea;
}

.tip strong {
  color: #667eea;
}

/* 页脚 */
.footer {
  background: #f8f9fa;
  padding: 20px;
  text-align: center;
  color: #6c757d;
  font-size: 0.9em;
  border-top: 1px solid #e9ecef;
}

/* 弹窗 */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s;
}

.modal-content {
  background: white;
  margin: 50px auto;
  padding: 30px;
  border-radius: 15px;
  max-width: 500px;
  position: relative;
  animation: slideIn 0.3s;
}

.close-btn {
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 2em;
  font-weight: 300;
  color: #adb5bd;
  cursor: pointer;
  transition: color 0.3s;
}

.close-btn:hover {
  color: #495057;
}

/* 响应式设计 */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .header h1 {
    font-size: 1.8em;
  }

  .subtitle {
    font-size: 0.95em;
  }

  .tabs {
    padding: 0 10px;
  }

  .tab-btn {
    padding: 12px 10px;
    font-size: 0.9em;
  }

  .tab-content {
    padding: 20px 15px;
  }

  .food-list {
    grid-template-columns: 1fr;
  }

  .sort-btns {
    flex-direction: column;
    gap: 10px;
  }

  .sort-btn {
    width: 100%;
  }

  .gi-info {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
  }

  .info-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .category-filter {
    justify-content: center;
  }

  .result-content {
    flex-direction: column;
    gap: 20px;
  }

  .result-item {
    max-width: 100%;
  }

  .result-value {
    font-size: 1.8em;
  }

  .result-arrow {
    transform: rotate(90deg);
    font-size: 2em;
  }

  .calc-result {
    padding: 25px 20px;
  }

  .calc-result h3 {
    font-size: 1em;
  }

  .energy-info {
    flex-direction: column;
    gap: 15px;
    padding: 20px 15px;
  }

  .energy-icon {
    font-size: 2.5em;
  }

  .energy-text {
    text-align: center;
  }

  .energy-value {
    font-size: 1.5em;
  }

  .energy-note {
    font-size: 0.8em;
  }

  .about-section {
    padding: 0 10px;
  }

  .about-section h2 {
    font-size: 1.5em;
  }

  .info-card {
    padding: 20px 15px;
  }

  .info-card h3 {
    font-size: 1.2em;
  }

  .info-card h4 {
    font-size: 1em;
  }

  .formula {
    padding: 15px;
  }

  .formula p {
    font-size: 1em;
  }

  .principle {
    padding: 15px;
  }

  .principle p {
    font-size: 1em;
  }

  .principle p:first-child {
    font-size: 1.3em;
  }

  .tip {
    padding: 12px;
    font-size: 0.95em;
  }
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #adb5bd;
}

.empty-state-icon {
  font-size: 4em;
  margin-bottom: 20px;
}

.empty-state-text {
  font-size: 1.2em;
} 