<template>
  <u-popup
    v-model="visible"
    mode="center"
    border-radius="24"
    width="640rpx"
    :mask-close-able="true"
    @close="handleClose"
  >
    <view class="mode-modal">
      <view class="mode-header">
        <text class="mode-title">选择传方方式</text>
        <text class="mode-sub">请选择适合您的传方方式</text>
      </view>
      <view class="mode-cards">
        <view class="mode-card photo" hover-class="mode-card-hover" @click="handleSelect('photo')">
          <view class="mode-icon-wrap photo-bg">
            <u-icon name="camera-fill" size="48" color="#10B981"></u-icon>
          </view>
          <text class="mode-name">拍照一键传方</text>
          <text class="mode-desc">拍摄处方照片，快速提交</text>
        </view>
        <view class="mode-card manual" hover-class="mode-card-hover" @click="handleSelect('manual')">
          <view class="mode-icon-wrap manual-bg">
            <u-icon name="edit-pen-fill" size="48" color="#0EA5E9"></u-icon>
          </view>
          <text class="mode-name">输入药方</text>
          <text class="mode-desc">手动选择中药并填写信息</text>
        </view>
      </view>
      <view class="mode-cancel" @click="handleClose">取消</view>
    </view>
  </u-popup>
</template>

<script>
export default {
  name: 'TransferModeModal',
  props: {
    value: { type: Boolean, default: false },
  },
  computed: {
    visible: {
      get() { return this.value },
      set(v) { this.$emit('input', v) },
    },
  },
  methods: {
    handleClose() {
      this.visible = false
      this.$emit('close')
    },
    /** 选择传方方式：photo=拍照 manual=手动输入药方 */
    handleSelect(mode) {
      this.$emit('select', mode)
      this.visible = false
    },
  },
}
</script>

<style lang="scss" scoped>
.mode-modal {
  padding: 48rpx 40rpx 32rpx;
  background: #fff;
}
.mode-header {
  text-align: center;
  margin-bottom: 40rpx;
}
.mode-title {
  display: block;
  font-size: 36rpx;
  font-weight: 700;
  color: #1d2129;
}
.mode-sub {
  display: block;
  font-size: 26rpx;
  color: #86909c;
  margin-top: 12rpx;
}
.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 24rpx;
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36rpx 32rpx;
  border-radius: 20rpx;
  border: 2rpx solid #f0f0f0;
  background: #fafafa;
}
.mode-card-hover {
  opacity: 0.85;
  transform: scale(0.98);
}
.mode-icon-wrap {
  width: 96rpx;
  height: 96rpx;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20rpx;
}
.photo-bg { background: linear-gradient(135deg, #ecfdf5, #d1fae5); }
.manual-bg { background: linear-gradient(135deg, #f0f9ff, #e0f2fe); }
.mode-name {
  font-size: 32rpx;
  font-weight: 600;
  color: #1d2129;
}
.mode-desc {
  font-size: 24rpx;
  color: #86909c;
  margin-top: 8rpx;
}
.mode-cancel {
  text-align: center;
  padding: 28rpx;
  margin-top: 16rpx;
  font-size: 28rpx;
  color: #86909c;
}
</style>
