<template>
  <div class="about-sts-container">
    <div class="about-sts-content">
      <div class="left-sidebar">
        <div class="sidebar-card">
          <div class="sidebar-header">
            <span class="title">关于STS</span>
          </div>
          <div class="sidebar-decorator">
            <div class="decorator-segment" style="background-color: #4B9F37"></div>
            <div class="decorator-segment" style="background-color: #C51A2D"></div>
            <div class="decorator-segment" style="background-color: #E37221"></div>
            <div class="decorator-segment" style="background-color: #0298DB"></div>
            <div class="decorator-segment" style="background-color: #F8C72E"></div>
            <div class="decorator-segment" style="background-color: #D0103A"></div>
            <div class="decorator-segment" style="background-color: #028542"></div>
            <div class="decorator-segment" style="background-color: #BF8B2E"></div>
            <div class="decorator-segment" style="background-color: #0B97D9"></div>
          </div>
          <div class="sidebar-menu">
            <div 
              v-for="(item, index) in titleList" 
              :key="item.id"
              class="menu-item"
              :class="{ active: activeIndex === index }"
              @click="switchContent(index)"
            >
              {{ item.title || '未设置' }}
            </div>
          </div>
        </div>
      </div>

      <div class="right-content">
        <div class="content-card" v-loading="loading">
          <div class="content-header">
            <span class="title">{{ activeTitle }}</span>
          </div>
          <div class="content-body" v-html="activeContent || '<p>暂无内容</p>'"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getAboutSts } from '@/api/portal/about'

export default {
  name: 'AboutSTS',
  data() {
    return {
      loading: true,
      aboutStsList: [],
      activeIndex: 0,
      titleList: []
    }
  },
  computed: {
    activeTitle() {
      return this.titleList[this.activeIndex]?.title || '未设置'
    },
    activeContent() {
      return this.titleList[this.activeIndex]?.content || ''
    }
  },
  created() {
    this.getAboutStsData()
  },
  methods: {
    getAboutStsData() {
      this.loading = true
      getAboutSts().then(response => {
        if (response.data && Array.isArray(response.data)) {
          this.aboutStsList = response.data
          this.initTitleList()
        }
        this.loading = false
      }).catch(() => {
        this.loading = false
      })
    },
    initTitleList() {
      this.titleList = this.aboutStsList.filter(item => item.title || item.content)
    },
    switchContent(index) {
      this.activeIndex = index
    }
  }
}
</script>

<style lang="scss" scoped>
.about-sts-container {
  width: 100%;
  min-height: 100vh;
  background-color: #f5f7fa;
  padding: 40px 0;
}

.about-sts-content {
  max-width: 1390px;
  margin: 0 auto;
  padding: 0 30px;
  display: grid;
  grid-template-columns: 300px 1060px;
  gap: 30px;
  align-items: start;
}

.left-sidebar {
  .sidebar-card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
  }

  .sidebar-header {
    background: #1EA8C5;
    height: 58px;
    display: flex;
    align-items: center;
    padding-left: 19px;

    .title {
font-family: Microsoft YaHei, Microsoft YaHei;
font-weight: bold;
font-size: 18px;
color: #FFFFFF;
line-height: 18px;
text-align: left;
font-style: normal;
text-transform: none;
    }
  }

  .sidebar-decorator {
    width: 100%;
    height: 6px;
    display: flex;
    overflow: hidden;

    .decorator-segment {
      width: 80px;
      height: 100%;

      &:first-child {
        margin-left: -40px;
      }

      &:last-child {
        margin-right: -40px;
      }
    }
  }

  .sidebar-menu {
    padding: 16px 0;

    .menu-item {
font-family: Microsoft YaHei, Microsoft YaHei;
font-weight: 600;
font-size: 18px;
color: #090909;
line-height: 51px;
text-align: left;
font-style: normal;
text-transform: none;
      padding: 16px 24px;
      cursor: pointer;
      transition: all 0.3s ease;
      font-size: 16px;
      color: #666666;
      border-left: 3px solid transparent;

      &:hover {
        background-color: #f5f7fa;
        color: #1e3c72;
      }

      &.active {
        background-color: #f0f2f5;
        color: #0080A5;
        font-weight: 600;
        border-left-color: #1e3c72;
      }
    }
  }
}

.right-content {
  .content-card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    min-height: 600px;
  }

  .content-header {
    height: 100px;
    padding: 30px 30px 0;

    .title {
      font-family: Microsoft YaHei, Microsoft YaHei;
      font-weight: bold;
      font-size: 24px;
      color: #090909;
      line-height: 34px;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }
  }

  .content-body {
    padding: 30px;
    padding-top: 0;
    line-height: 1.8;
    color: #333333;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;

    :deep(h1),
    :deep(h2),
    :deep(h3),
    :deep(h4),
    :deep(h5),
    :deep(h6) {
      color: #1e3c72;
      margin-top: 24px;
      margin-bottom: 16px;
    }

    ::v-deep p{
      margin-bottom: 16px;
      max-width: 100%;
      overflow: hidden;
      font-family: Microsoft YaHei, Microsoft YaHei;
      font-weight: 400;
      font-size: 18px;
      color: #090909;
      line-height: 30px;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }

    ::v-deep img {
      margin: 0 auto ;
      width: 606px !important;
      height: auto !important;
      border-radius: 4px;
      display: block;
      box-sizing: border-box;
    }

    :deep(a) {
      color: #1e3c72;
      text-decoration: none;

      &:hover {
        text-decoration: underline;
      }
    }

    :deep(ul),
    :deep(ol) {
      margin-left: 24px;
      margin-bottom: 16px;
    }

    :deep(li) {
      margin-bottom: 8px;
    }
  }
}

@media (max-width: 992px) {
  .about-sts-content {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .left-sidebar {
    order: 2;

    .sidebar-menu {
      display: flex;
      overflow-x: auto;
      white-space: nowrap;

      .menu-item {
        border-left: none;
        border-bottom: 3px solid transparent;
        display: inline-block;
        margin-right: 8px;
        border-radius: 4px 4px 0 0;

        &.active {
          border-left: none;
          border-bottom-color: #1e3c72;
        }
      }
    }
  }

  .right-content {
    order: 1;
  }
}

@media (max-width: 768px) {
  .about-sts-content {
    padding: 0 20px;
  }

  .right-content {
    .content-card {
      min-height: 500px;
    }

    .content-header {
      padding: 20px 20px 0;
    }

    .content-body {
      padding: 20px;
    }
  }

  .left-sidebar {
    .sidebar-header {
      padding: 20px 20px;

      h2 {
        font-size: 20px;
      }
    }

    .sidebar-menu {
      .menu-item {
        padding: 12px 20px;
        font-size: 14px;
      }
    }
  }
}
</style>
