<template>
  <div class="container">
    <div class="gradient-card">
      <div class="card-header">
        <h1>籽粒移除输出通量计算器</h1>
        <p>评估作物镉含量及籽粒移除对镉的影响，助力农业安全生产</p>
      </div>

      <div class="instruction-section">
        <h2>使用说明</h2>
        <ol>
          <li>首次使用请点击"作物镉模型计算"按钮。</li>
          <li>点击"作物镉模型计算"按钮跳转到作物镉模型计算页面。</li>
          <li>在作物镉模型计算页面完成计算后返回此页面。</li>
        </ol>
      </div>

      <div class="crop-cd-model-section">
        <button class="calculate-btn" @click="openCropCdModelPage">
          <i class="fas fa-calculator"></i> 作物镉模型计算
        </button>
      </div>

      <div class="input-section">
        <div class="input-group">
          <label class="label">作物亩产量 (斤)</label>
          <input v-model="yieldPerMu" placeholder="800" class="custom-input" :disabled="!cropCdModelCalculated" />
        </div>

        <div class="info-panel">
          <div class="info-item">
            <i class="fas fa-chart-line"></i>
            <span>建议范围: 500 - 1500</span>
          </div>
        </div>
      </div>

      <div class="button-section">
        <button class="calculate-btn" :disabled="!cropCdModelCalculated || !yieldPerMu" @click="onCalculate">
          <i class="fas fa-calculator"></i> 籽粒移除计算
        </button>
      </div>

      <div class="card-footer">
        <p><i class="fas fa-lightbulb"></i> 提示: 输入数据后点击"籽粒移除计算"按钮获取详细分析</p>
      </div>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue';

export default {
  name: 'GrainRemovalCalculator',
  setup() {
    const cropCdModelCalculated = ref(false);
    const yieldPerMu = ref(null);

    const openCropCdModelPage = () => {
      // 这里可以实现跳转到作物镉模型计算页面的逻辑
      // 例如：window.location.href = '/crop-cd-model';
      alert('打开作物镉模型计算页面');
      cropCdModelCalculated.value = true;
    };

    const onCalculate = () => {
      if (!yieldPerMu.value) {
        alert('请输入作物亩产量');
        return;
      }
      alert(`计算完成！当前亩产量: ${yieldPerMu.value} 斤`);
    };

    return {
      cropCdModelCalculated,
      yieldPerMu,
      openCropCdModelPage,
      onCalculate
    };
  }
};
</script>

<style scoped>
body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden; /* 禁止页面滚动 */
}

.container {
  display: flex;
  justify-content: center;
  align-items: center; /* 居中对齐 */
  height: 100vh;
}

.gradient-card {
  background: linear-gradient(135deg,
      rgba(250, 253, 255, 0.8),
      rgba(137, 223, 252, 0.8));
  border-radius: 20px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  padding: 30px;
  width: 100%;
  max-width: 500px;
  backdrop-filter: blur(8px);
  border: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-header {
  text-align: center;
  margin-bottom: 20px;
}

.card-header h1 {
  font-size: 2rem;
  color: #006064;
  margin-bottom: 10px;
  font-weight: 700;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

.card-header p {
  font-size: 1.1rem;
  color: #00838f;
  opacity: 0.9;
}

.instruction-section {
  text-align: center;
  margin-bottom: 20px;
}

.instruction-section h2 {
  font-size: 1.5rem;
  color: #006064;
  margin-bottom: 10px;
}

.instruction-section ol {
  list-style-type: decimal;
  padding-left: 20px;
  margin-bottom: 20px;
}

.instruction-section li {
  font-size: 1rem;
  color: #00838f;
  margin-bottom: 5px;
}

.crop-cd-model-section {
  text-align: center;
  margin-bottom: 20px;
}

.input-section {
  margin: 20px 0;
}

.input-group {
  margin-bottom: 20px;
}

.label {
  display: block;
  font-weight: 600;
  font-size: 1.2rem;
  margin-bottom: 10px;
  color: #006064;
}

.custom-input {
  width: 100%;
  padding: 15px 10px;
  border-radius: 12px;
  border: 2px solid #80deea;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.7);
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.custom-input:focus {
  outline: none;
  border-color: #26c6da;
  box-shadow: 0 0 0 4px rgba(38, 198, 218, 0.3);
}

.custom-input:disabled {
  background: rgba(255, 255, 255, 0.3);
  border-color: #ccc;
  cursor: not-allowed;
}

.info-panel {
  background: rgba(178, 235, 242, 0.4);
  border-radius: 12px;
  padding: 15px;
  margin-top: 15px;
}

.info-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  font-size: 1rem;
  color: #006064;
}

.info-item i {
  margin-right: 10px;
  font-size: 1.2rem;
  color: #00838f;
}

.button-section {
  margin: 25px 0;
  text-align: center;
  flex-grow: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.calculate-btn {
  background: linear-gradient(to right, #8DF9F0, #26B046);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 15px 30px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.4s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 250px;
  position: relative;
  overflow: hidden;
}

.calculate-btn i {
  margin-right: 10px;
  font-size: 1.4rem;
}

.calculate-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.3);
  background: linear-gradient(to right, #7de8df, #20a03d);
}

.calculate-btn:active {
  transform: translateY(-2px);
}

.calculate-btn:disabled {
  background: gray;
  cursor: not-allowed;
}

.card-footer {
  text-align: center;
  font-size: 1rem;
  color: #00838f;
  font-style: italic;
  padding-top: 15px;
  border-top: 1px solid rgba(0, 150, 136, 0.2);
}

.card-footer i {
  margin-right: 10px;
}

/* 水波纹效果 */
.calculate-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.calculate-btn:active::after {
  width: 200px;
  height: 200px;
}

/* 响应式设计 */
@media (max-width: 480px) {
  .gradient-card {
    padding: 20px;
    width: 100%;
    max-width: 100%;
  }

  .card-header h1 {
    font-size: 1.8rem;
  }

  .instruction-section h2 {
    font-size: 1.4rem;
  }

  .label {
    font-size: 1rem;
  }

  .custom-input {
    padding: 12px;
    font-size: 0.9rem;
  }

  .calculate-btn {
    padding: 12px 25px;
    font-size: 1rem;
    min-width: 200px;
  }

  .info-item span {
    font-size: 0.9rem;
  }
}
</style>



