<template>
  <div class="preview-contain">
    <div class="time-select" v-if="step == 1">
      <timeSelect/>
      <div class="divider"></div>
      <div class="select-moon">
        <p class="moon-time">请选择进馆时间</p>
        <div class="morning-moon">
          <div class="time-card" :class="{ active: selectedTime === 'morning' }" @click="selectTime('morning')">
            <div class="time-period">上午</div>
            <div class="time-range">(10:00-14:00)</div>
            <div class="availability">余票充足</div>
            <div class="check-icon" v-if="selectedTime === 'morning'">✓</div>
          </div>
          
          <div class="time-card" :class="{ active: selectedTime === 'afternoon' }" @click="selectTime('afternoon')">
            <div class="time-period">下午</div>
            <div class="time-range">(14:00-18:00)</div>
            <div class="availability">余票充足</div>
            <div class="check-icon" v-if="selectedTime === 'afternoon'">✓</div>
          </div>
          
          <button class="next-btn" :disabled="!selectedTime" @click="goNext">
            下一步
          </button>
        </div>
      </div>
    </div>
    <div v-else>
      <visitPeople/>
    </div>
  </div>
</template>

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

export default defineComponent({
  components: { timeSelect, visitPeople },
  setup() {
    const selectedTime = ref('')
    const step = ref(1)
    
    const selectTime = (time) => {
      selectedTime.value = time
    }
    
    const goNext = () => {
      if (selectedTime.value) {
        console.log('选择的时间段:', selectedTime.value)
        step.value = 2;
        // 这里可以添加跳转到下一页的逻辑
      }
    }
    
    return {
      selectedTime,
      visitPeople,
      selectTime,
      goNext,
      step
    }
  }
})
</script>

<style lang="scss" scoped>
.preview-contain{
  height: 100vh;
  background: url('@/assets/indexPage/bg.png') no-repeat center center;
  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{
    margin-top: 16px;
    
    .moon-time{
      color: #584735;
      font-size: 16px;
      font-weight: bold;
      margin-bottom: 16px;
    }
    
    .morning-moon {
      display: flex;
      flex-direction: column;
      gap: 12px;
      
      .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 {
        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;
        }
      }
    }
  }
}
</style>