
<template>
  <div style="display: flex;
  height: 100vh;">
    <Menu
        :initial-active="2"
    />
    <div class="medical-qa-container">
      <!-- 标题 -->
      <h2 class="title">医疗问答</h2>

      <!-- 搜索框 -->
      <div class="search-box">
        <el-input
            v-model="query"
            placeholder="请输入问题..."
            clearable
        />
        <el-button type="primary" @click="handleSearch" style="    background: #114FE6;">查询</el-button>
      </div>

      <!-- 主内容区 -->
      <div class="content-wrapper">
        <!-- 左侧：问答结果 -->
        <div class="answer-list">
          <div class="section-title">问答结果</div>
          <div v-if="answers.length === 0" class="empty-state">
            请输入问题进行查询...
          </div>
          <div v-else class="answer-items">
            <div
                v-for="(item, index) in answers"
                :key="index"
                class="answer-item"
                @click="selectGraph(index)"
                :class="{ 'highlight': selected === index }"
            >
              {{ item }}
            </div>
          </div>
        </div>

        <!-- 右侧：知识图谱 -->
        <div class="knowledge-graph">
          <KnowledgeGraph />
        </div>
      </div>
    </div>

  </div>
</template>

<script>
import Menu from "@/components/Menu.vue";
import {qaAnalyze} from "@/api/qa";


export default {
  name: 'GraghQA',
  components: {Menu},
  data() {
    return {
      query:"",
      answers:['糖尿病不能吃什么','糖尿病不能吃什么','糖尿病不能吃什么','糖尿病不能吃什么','糖尿病不能吃什么',],
      selected:0,

    };
  },
  methods: {
    selectGraph(index){
      this.selected=index
    },
    handleSearch(){
      let data={
        text:this.query
      }
      this.query=""
      qaAnalyze(data).then(res=>{

      })
    }
  },

};
</script>
<style scoped>


.medical-qa-container {
  padding: 25px;
  background-color: #F6F9FF;
  flex: 1;
  overflow: auto;
  height: 100vh;
  margin: 0 auto;
}

.title {
  font-size: 20px;
  margin-bottom: 20px;
  padding-left: 12px;
  position: relative;
  display: flex;
  align-items: center;
  color: #165DFF;
  margin-left: 15px;
}

.title::before {
  content: '';
  width: 6px;
  height: 16px;
  background-color: #165DFF;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 2px;
}

.search-box {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
  align-items: center;

}

.search-box .el-input {
  flex: 1;
  max-width: 94%;
  margin-right: 5px;
}

.content-wrapper {
  display: flex;
  gap: 20px;
  height: 37vw;
}

.answer-list {
  flex: 1;
  background-color: white;
  border-radius: 33px;
  padding: 25px;
  box-shadow: 3px 1px 12px 7px #ECF2FF;
  max-width: 32%;
}

.section-title {
  font-size: 16px;
  color: #165DFF;
  margin-bottom: 15px;
  padding-left: 12px;
  position: relative;
  display: flex;
  align-items: center;
  font-weight: 900;
}

.section-title::before {
  content: '';
  width: 6px;
  height: 12px;
  background-color: #165DFF;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 2px;
}

.answer-items {
 height: 30vw;
  overflow-y: auto;
  padding-right: 10px;
  cursor: pointer;

}
.answer-items::-webkit-scrollbar {
  width: 6px; /* 滚动条宽度 */
}

.answer-items::-webkit-scrollbar-track {
  background: #fff; /* 轨道背景 */
  border-radius: 4px;
}

.answer-items::-webkit-scrollbar-thumb {
  background: #B8C2D9; /* 滑块颜色 */
  border-radius: 4px;
  transition: background 0.2s ease;

}

.answer-items::-webkit-scrollbar-thumb:hover {
  background: #B8C2D9; /* 悬停时滑块颜色 */
}
.answer-item {
  padding: 12px;
  border: 1px solid #165DFF;
  border-radius: 15px;
  background-color: #f9f9f9;
  line-height: 1.5;
  word-wrap: break-word;
  color: #a2a5a7;
  font-weight: 400;
  font-size: 13px;
  text-align: left;
  height: 4.5vw;
  margin-bottom: 12px;
}

.answer-item.highlight {
  background-color: #165DFF;
  border-color: #0066cc;
  color: #fff;
}
.answer-item:hover {
  background-color: #165DFF;
  border-color: #0066cc;
  color: #fff;
}
.empty-state {
  text-align: center;
  color: #fff;
  padding: 40px 0;
  font-size: 14px;
}

.knowledge-graph {
  flex: 1;
  background-color: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
/deep/.el-input__wrapper{
  background-color: #EFF4FF;
  border: 1px solid #165DFF;
  border-radius: 8px;
}

</style>