<template>
  <view class="container">
    <!-- 自定义导航栏 -->
    <view class="nav-bar">
      <view class="nav-left" @click="goBack">
        <text class="back-icon">‹</text>
      </view>
      <view class="nav-title">评分详情</view>
      <view class="nav-right">
        <view class="icon-menu">···</view>
        <view class="icon-close">⊗</view>
      </view>
    </view>

    <!-- 选手信息 -->
    <view class="player-info-section">
      <view class="player-name">张三</view>
      <view class="player-details">
        <view class="detail-item">身份证：123456789000000000</view>
        <view class="detail-item">队伍：少林寺武术大学院</view>
        <view class="detail-item">编号：123-45678​98275</view>
      </view>
    </view>

    <!-- 评分提示 -->
    <view class="score-tip">
      点击分数填写或拖动滑块打分（5-10分）
    </view>

    <!-- 分数调整 -->
    <view class="score-control">
      <view class="control-btn decrease" @click="decreaseScore">
        <text class="btn-symbol">－</text>
        <!-- <text class="btn-value">-0.001</text> -->
      </view>

      <view class="score-display">
        <text class="current-score">{{ currentScore.toFixed(3) }}</text>
      </view>

      <view class="control-btn increase" @click="increaseScore">
        <text class="btn-symbol">＋</text>
        <!-- <text class="btn-value">+0.001</text> -->
      </view>
    </view>

    <!-- <view class="judge-tip">
      裁判评分：保留3位小数点，超过上限或下限时，按钮置灰
    </view> -->

    <!-- 扣分项 -->
    <view class="deduction-section">
      <view class="deduction-header">
        <text class="deduction-label">扣分项：</text>
        <!-- <text class="deduction-hint">扣分项多选</text> -->
      </view>

      <view class="deduction-list">
        <view
          v-for="(item, index) in deductions"
          :key="index"
          class="deduction-item"
          @click="toggleDeduction(index)"
        >
          <view :class="['checkbox', item.checked ? 'checked' : '']">
            <text v-if="item.checked" class="check-icon">✓</text>
          </view>
          <text class="deduction-text">{{ item.text }}</text>
        </view>
      </view>
    </view>

    <!-- 备注 -->
    <view class="note-section">
      <view class="note-label">
        <text>备注：</text>
      </view>
      <view class="note-input-wrapper">
        <textarea
          class="note-input"
          placeholder="请输入修改备注"
          v-model="note"
          maxlength="200"
        />
        <!-- <text class="optional-text">可不填</text> -->
      </view>
    </view>

    <!-- 提交按钮 -->
    <button class="submit-btn" @click="handleSubmit">提交</button>
  </view>
</template>

<script>
export default {
  data() {
    return {
      currentScore: 8.907,
      note: '',
      minScore: 5.0,
      maxScore: 10.0,
      deductions: [
        { text: '扣分项描述', checked: false },
        { text: '扣分项描述', checked: false },
        { text: '扣分项描述', checked: true },
        { text: '扣分项描述', checked: false },
        { text: '扣分项描述', checked: false },
        { text: '扣分项描述', checked: true },
        { text: '扣分项描述', checked: true },
        { text: '扣分项描述', checked: false }
      ]
    }
  },
  methods: {
    goBack() {
      uni.navigateBack()
    },
    decreaseScore() {
      if (this.currentScore > this.minScore) {
        this.currentScore = parseFloat((this.currentScore - 0.001).toFixed(3))
      }
    },
    increaseScore() {
      if (this.currentScore < this.maxScore) {
        this.currentScore = parseFloat((this.currentScore + 0.001).toFixed(3))
      }
    },
    toggleDeduction(index) {
      this.deductions[index].checked = !this.deductions[index].checked
    },
    handleSubmit() {
      uni.showToast({
        title: '提交成功',
        icon: 'success'
      })
      setTimeout(() => {
        uni.navigateBack()
      }, 1500)
    }
  }
}
</script>

<style scoped>
.container {
  min-height: 100vh;
  background-color: #F5F5F5;
  padding-bottom: 40rpx;
}

/* 导航栏 */
.nav-bar {
  height: 90rpx;
  background: linear-gradient(135deg, #1B7C5E 0%, #2A9D7E 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 30rpx;
}

.nav-left {
  position: absolute;
  left: 30rpx;
  width: 60rpx;
  height: 60rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-icon {
  font-size: 60rpx;
  color: #FFFFFF;
  font-weight: 300;
  line-height: 1;
}

.nav-title {
  font-size: 36rpx;
  font-weight: 600;
  color: #FFFFFF;
  letter-spacing: 2rpx;
}

.nav-right {
  position: absolute;
  right: 30rpx;
  display: flex;
  align-items: center;
  gap: 30rpx;
}

.icon-menu,
.icon-close {
  width: 60rpx;
  height: 60rpx;
  background-color: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32rpx;
  color: #FFFFFF;
  font-weight: bold;
}

/* 选手信息 */
.player-info-section {
  margin: 30rpx;
}

.player-name {
  font-size: 34rpx;
  font-weight: 600;
  color: #333333;
  margin-bottom: 20rpx;
}

.player-details {
  display: flex;
  flex-direction: column;
  gap: 8rpx;
}

.detail-item {
  font-size: 26rpx;
  color: #CD8B6F;
  line-height: 1.5;
}

/* 评分提示 */
.score-tip {
  padding: 0 30rpx;
  font-size: 26rpx;
  color: #666666;
  margin-bottom: 30rpx;
}

/* 分数控制 */
.score-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 60rpx;
  margin-bottom: 20rpx;
}

.control-btn {
  width: 140rpx;
  height: 140rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #F5F5F5;
  border-radius: 12rpx;
}

.control-btn.decrease {
  background-color: #FFE5E5;
}

.control-btn.increase {
  background-color: #E5F5F0;
}

.btn-symbol {
  font-size: 48rpx;
  font-weight: 300;
}

.control-btn.decrease .btn-symbol {
  color: #FF4D6A;
}

.control-btn.increase .btn-symbol {
  color: #1B7C5E;
}

.btn-value {
  font-size: 24rpx;
  margin-top: 8rpx;
}

.control-btn.decrease .btn-value {
  color: #FF4D6A;
}

.control-btn.increase .btn-value {
  color: #1B7C5E;
}

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

.current-score {
  font-size: 80rpx;
  font-weight: 600;
  color: #1B7C5E;
}

.judge-tip {
  padding: 0 30rpx;
  font-size: 24rpx;
  color: #FF4D6A;
  text-align: center;
  line-height: 1.6;
  margin-bottom: 30rpx;
}

/* 扣分项 */
.deduction-section {
  margin: 30rpx;
}

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

.deduction-label {
  font-size: 28rpx;
  color: #333333;
  font-weight: 500;
}

.deduction-hint {
  font-size: 24rpx;
  color: #FF4D6A;
}

.deduction-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20rpx;
}

.deduction-item {
  display: flex;
  align-items: center;
  padding: 20rpx;
  background-color: #FFFFFF;
  border-radius: 12rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
}

.checkbox {
  width: 40rpx;
  height: 40rpx;
  border: 2rpx solid #CCCCCC;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16rpx;
  flex-shrink: 0;
  background-color: #F5F5F5;
}

.checkbox.checked {
  background-color: #1B7C5E;
  border-color: #1B7C5E;
}

.check-icon {
  color: #FFFFFF;
  font-size: 28rpx;
  font-weight: bold;
}

.deduction-text {
  font-size: 26rpx;
  color: #333333;
  line-height: 1.4;
  flex: 1;
}

/* 备注 */
.note-section {
  margin: 30rpx;
}

.note-label {
  font-size: 28rpx;
  color: #333333;
  margin-bottom: 20rpx;
}

.note-input-wrapper {
  background-color: #FFFFFF;
  border-radius: 16rpx;
  padding: 30rpx;
  box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
  position: relative;
}

.note-input {
  width: 100%;
  min-height: 120rpx;
  font-size: 28rpx;
  color: #333333;
  line-height: 1.6;
}

.note-input::placeholder {
  color: #CCCCCC;
}

.optional-text {
  position: absolute;
  right: 30rpx;
  bottom: 30rpx;
  font-size: 24rpx;
  color: #FF4D6A;
}

/* 提交按钮 */
.submit-btn {
  margin: 30rpx;
  height: 90rpx;
  background: linear-gradient(135deg, #1B7C5E 0%, #2A9D7E 100%);
  border-radius: 16rpx;
  font-size: 32rpx;
  font-weight: 600;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8rpx 20rpx rgba(27, 124, 94, 0.3);
}

.submit-btn:active {
  opacity: 0.9;
}
</style>
