<template>
  <div class="preview-contain">
    <div class="time-select" v-if="step == 1">
      <timeSelect />
      <div class="divider"></div>
      <div class="select-moon">
        <div class="morning-moon">
          <div class="next-btn" @click="goNext">
            下一步
          </div>
        </div>
      </div>
    </div>
    <div v-else>
      <activePeople />
    </div>
  </div>
</template>

<script>
import { defineComponent, ref } from 'vue'
import timeSelect from '@/components/timeSelect.vue'
import activePeople from './activePeople.vue'

export default defineComponent({
  components: { timeSelect, activePeople },
  setup() {
    const selectedTime = ref('')
    const step = ref(1)

    const selectTime = (time) => {
      selectedTime.value = time
    }

    const goNext = () => {
      step.value = 2;
    }

    return {
      selectedTime,
      activePeople,
      selectTime,
      goNext,
      step
    }
  }
})
</script>

<style lang="scss" scoped>
.preview-contain {
  height: 100vh;
  background: url('@/assets/indexPage/bg.png') no-repeat;
  background-size: cover;
  overflow: auto;

  .time-select {
    padding: 16px;
  }

  .divider {
    width: 349px;
    height: 2px;
    background: linear-gradient(90deg, #5B472E 0%, rgba(91, 71, 46, 0) 100%);
    opacity: 0.5;
    margin-top: 16px;
  }

  .select-moon {
    // position: fixed;
    // width: 90%;
    // bottom: 24px;
    margin-top: 16px;

    .moon-time {
      color: #584735;
      font-size: 16px;
      font-weight: bold;
      margin-bottom: 16px;
    }

    .morning-moon {
      display: flex;
      width: 100%; // 确保按钮占满父元素的宽度

      .time-card {
        position: relative;
        background: transparent;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        border: 1px solid #B1967B;
        border-radius: 8px;
        padding: 16px 20px;
        cursor: pointer;
        transition: all 0.3s ease;

        &.active {
          background: rgba(177, 150, 123, 0.4);
          border-color: #B1967B;
        }

        .time-period {
          font-size: 16px;
          font-weight: bold;
          color: #584735;
          margin-bottom: 4px;
        }

        .time-range {
          font-size: 16px;
          color: #5B472E;
          margin-bottom: 8px;
        }

        .availability {
          font-size: 12px;
          color: #5B472E;
        }

        .check-icon {
          position: absolute;
          top: 50%;
          right: 20px;
          transform: translateY(-50%);
          width: 24px;
          height: 24px;
          background: #B1967B;
          color: white;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 14px;
          font-weight: bold;
        }
      }

      .next-btn {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #B1967B;
        color: white;
        border: none;
        border-radius: 8px;
        padding: 16px;
        font-size: 16px;
        font-weight: bold;
        cursor: pointer;
        margin-top: 20px;
        transition: all 0.3s ease;


        &:disabled {
          background: #ccc;
          cursor: not-allowed;
        }

        &:not(:disabled):hover {
          background: #9A8169;
        }
      }
    }
  }
}

// @media (min-width: 1024px) {
//   .preview-contain {
//     width: 400px;
//   }
// }</style>