<template>
  <div class="hydrology-forecast-container">
    <div class="secondary-title-container">
      <div 
        class="secondary-title" 
        :class="{ active: activeSecondaryTab === '水文预报' }"
        @click="selectSecondaryTab('水文预报')"
      >
        <span>水文预报</span>
      </div>
      <div 
        class="secondary-title" 
        :class="{ active: activeSecondaryTab === '水文预警' }"
        @click="selectSecondaryTab('水文预警')"
      >
        <span>水文预警</span>
      </div>
      <div 
        class="secondary-title" 
        :class="{ active: activeSecondaryTab === '水文预演' }"
        @click="selectSecondaryTab('水文预演')"
      >
        <span>水文预演</span>
      </div>
      <div 
        class="secondary-title" 
        :class="{ active: activeSecondaryTab === '水文预案' }"
        @click="selectSecondaryTab('水文预案')"
      >
        <span>水文预案</span>
      </div>
    </div>

    <HydrologyForecastPanel 
      v-if="activeSecondaryTab === '水文预报'" 
      @updateForecastData="handleUpdateForecastData"
    />
    <HydrologyWarningPanel 
      v-if="activeSecondaryTab === '水文预警'" 
      @loadEmbankmentWarning="handleLoadEmbankmentWarning"
    />
    <HydrologySimulationPanel 
      v-if="activeSecondaryTab === '水文预演'" 
      :simulationTime="simulationTime"
      :simulationData="simulationData"
      @updateSimulationTime="$emit('updateSimulationTime', $event)"
      @updateSimulationData="$emit('updateSimulationData', $event)"
      @updateScenarioAndRisk="handleUpdateScenarioAndRisk"
    />
    <HydrologyPlanPanel 
      v-if="activeSecondaryTab === '水文预案'" 
      :selectedScenario="selectedScenario"
      :riskLevel="riskLevel"
      :scenarioLabel="scenarioLabel"
    />
  </div>
</template>

<script>
import HydrologyForecastPanel from '../components/HydrologyForecastPanel.vue'
import HydrologyWarningPanel from '../components/HydrologyWarningPanel.vue'
import HydrologySimulationPanel from '../components/HydrologySimulationPanel.vue'
import HydrologyPlanPanel from '../components/HydrologyPlanPanel.vue'

export default {
  name: 'HydrologyForecastView',
  components: {
    HydrologyForecastPanel,
    HydrologyWarningPanel,
    HydrologySimulationPanel,
    HydrologyPlanPanel
  },
  props: {
    activeSecondaryTab: {
      type: String,
      default: '水文预报'
    },
    simulationTime: {
      type: Number,
      default: 0
    },
    simulationData: {
      type: Object,
      default: () => ({})
    },
    loadEmbankmentWarning: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      selectedScenario: 'light',
      scenarioLabel: '小雨情景（24h）',
      riskLevel: '正常'
    }
  },
  emits: ['selectSecondaryTab', 'updateSimulationTime', 'updateSimulationData', 'loadEmbankmentWarning', 'updateForecastData'],
  methods: {
    selectSecondaryTab(tab) {
      this.$emit('selectSecondaryTab', tab)
    },
    handleUpdateScenarioAndRisk({ scenario, riskLevel, selectedScenario }) {
      this.selectedScenario = selectedScenario
      this.scenarioLabel = scenario
      this.riskLevel = riskLevel
    },
    handleLoadEmbankmentWarning() {
      this.$emit('loadEmbankmentWarning')
    },
    handleUpdateForecastData(data) {
      this.$emit('updateSimulationData', data)
    }
  }
}
</script>

<style scoped>
.hydrology-forecast-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.secondary-title-container {
  position: absolute;
  bottom: 46px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  z-index: 4;
}

.secondary-title {
  width: 159px;
  height: 31px;
  background-image: url('/src/assets/images/未选中底部标题.png');
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.secondary-title span {
  background: linear-gradient(to bottom, #e2e8ff, #7bbef6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 5px rgba(0, 212, 255, 0.3);
}

.secondary-title:hover,
.secondary-title.active {
  background-image: url('/src/assets/images/选中底部标题.png');
}

.secondary-title:hover span,
.secondary-title.active span {
  background: linear-gradient(to bottom, #e2e8ff, #62f6fb);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
</style>
