<template>
  <div class="board-conclusion-card">
    <div class="board-conclusion-card__bar" />
    <div class="board-conclusion-card__body">
      <div class="board-conclusion-card__title">私董会结论</div>

      <div v-if="data.summary" class="board-conclusion-card__section">
        <div class="board-conclusion-card__section-title">总结</div>
        <div class="board-conclusion-card__text">{{ data.summary }}</div>
      </div>

      <div v-if="data.consensus_points && data.consensus_points.length > 0" class="board-conclusion-card__section">
        <div class="board-conclusion-card__section-title">共识</div>
        <ul class="board-conclusion-card__list">
          <li v-for="(point, idx) in data.consensus_points" :key="`c-${idx}`">
            {{ point }}
          </li>
        </ul>
      </div>

      <div
        v-if="data.dissent_points && data.dissent_points.length > 0"
        class="board-conclusion-card__section board-conclusion-card__section--collapsible"
      >
        <div class="board-conclusion-card__section-header" @click="showDissent = !showDissent">
          <span class="board-conclusion-card__section-title">分歧</span>
          <DownOutlined :class="{ 'board-conclusion-card__rotate': !showDissent }" />
        </div>
        <ul v-show="showDissent" class="board-conclusion-card__list">
          <li v-for="(point, idx) in data.dissent_points" :key="`d-${idx}`">
            {{ point }}
          </li>
        </ul>
      </div>

      <div
        v-if="data.decision_advice"
        class="board-conclusion-card__section board-conclusion-card__section--collapsible"
      >
        <div class="board-conclusion-card__section-header" @click="showAdvice = !showAdvice">
          <span class="board-conclusion-card__section-title">决策建议</span>
          <DownOutlined :class="{ 'board-conclusion-card__rotate': !showAdvice }" />
        </div>
        <div v-show="showAdvice" class="board-conclusion-card__text">{{ data.decision_advice }}</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { DownOutlined } from '@ant-design/icons-vue'
import type { IBoardConcludedData } from '@/api/types'

interface Props {
  data: IBoardConcludedData
}

defineProps<Props>()

const showDissent = ref(false)
const showAdvice = ref(false)
</script>

<style scoped>
.board-conclusion-card {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.board-conclusion-card__bar {
  height: 4px;
  background: var(--gradient-board);
}

.board-conclusion-card__body {
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.board-conclusion-card__title {
  font-size: var(--font-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.board-conclusion-card__section {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.board-conclusion-card__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.board-conclusion-card__section-title {
  font-size: var(--font-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
}

.board-conclusion-card__text {
  font-size: var(--font-sm);
  color: var(--text-primary);
  line-height: var(--leading-message);
}

.board-conclusion-card__list {
  margin: 0;
  padding-left: var(--space-4);
  font-size: var(--font-sm);
  color: var(--text-primary);
  line-height: var(--leading-message);
}

.board-conclusion-card__list li {
  margin-bottom: var(--space-1);
}

.board-conclusion-card__rotate {
  transform: rotate(-90deg);
  transition: transform var(--transition-fast);
}
</style>
