<template>
  <transition name="slide-up">
    <div v-if="visible" class="remark-panel">
      <div class="remark-mask" @click="$emit('close')" />
      <div class="remark-content">
        <div class="remark-header">
          <div class="remark-title">{{ title }}</div>
          <div class="remark-close" @click="$emit('close')">×</div>
        </div>
        <div class="remark-body">
          <div class="remark-input">
            <textarea
              :value="remark"
              @input="$emit('update:remark', $event.target.value)"
              :placeholder="$t('checkin.punch.remark.placeholder')"
              maxlength="200"
              rows="4"
            />
            <div class="remark-count">{{ remark.length }}/200</div>
          </div>
        </div>
        <div class="remark-footer">
          <button class="remark-submit" @click="$emit('submit')">
            <!-- 确认打卡 -->
            {{ $t("checkin.button.confirmCheck") }}
          </button>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'RemarkDialog',
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ''
    },
    remark: {
      type: String,
      default: ''
    }
  },
  emits: ['close', 'submit', 'update:remark']
}
</script>

<style lang="scss" scoped>
.remark-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;

  .remark-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
  }

  .remark-content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-radius: 16px 16px 0 0;
    transform: translateY(0);
    transition: transform 0.3s ease-out;
  }

  .remark-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
  }

  .remark-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
  }

  .remark-close {
    font-size: 24px;
    color: #999;
    padding: 4px;
    cursor: pointer;
  }

  .remark-body {
    padding: 20px;
  }

  .remark-input {
    position: relative;

    textarea {
      width: 100%;
      border: 1px solid #eee;
      border-radius: 8px;
      padding: 12px;
      font-size: 14px;
      line-height: 1.5;
      resize: none;
      outline: none;

      &:focus {
        border-color: #2196f3;
      }
    }

    .remark-count {
      position: absolute;
      right: 12px;
      bottom: 12px;
      font-size: 12px;
      color: #999;
    }
  }

  .remark-footer {
    padding: 12px 20px 20px;

    .remark-submit {
      width: 100%;
      height: 44px;
      background: #2196f3;
      border: none;
      border-radius: 22px;
      color: #fff;
      font-size: 16px;
      font-weight: 500;

      &:active {
        opacity: 0.9;
      }
    }
  }
}

.slide-up-enter-active,
.slide-up-leave-active {
  transition: all 0.3s ease-out;
}

.slide-up-enter-from,
.slide-up-leave-to {
  .remark-mask {
    opacity: 0;
  }

  .remark-content {
    transform: translateY(100%);
  }
}
</style> 