<template>
  <div class="portal-nav">
    <div class="navbar-box">
      <div class="navbar-top">
        <div class="top-container">
          <div class="top-left">
            <span class="top-text"></span>
          </div>
                    <div class="top-center">
            <span class="top-text"></span>
          </div>
          <div class="top-right">
            <a href="#" class="top-link">English</a>
          </div>
        </div>
      </div>
      <div class="navbar-main">
        <div class="main-container">
          <div class="nav-left">
            <div class="logo">
              <!-- <img src="@/assets/logo/logo.png" alt="Logo" /> -->
            </div>
            <div class="site-title">
              <h1>国际大科学计划</h1>
            </div>
          </div>
          <div class="nav-right">
            <ul class="nav-menu">
              <li v-for="item in navItems" :key="item.path" :class="{ active: currentPath === item.path }">
                <router-link :to="item.path">{{ item.title }}</router-link>
              </li>
            </ul>
          </div>
        </div>
        <div class="nav-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>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PortalNav',
  data() {
    return {
      navItems: [
        { path: '/portal/home', title: '首页' },
        { path: '/portal/about', title: '关于STS' },
        { path: '/portal/science-plan', title: '科学计划与国际合作' },
        { path: '/portal/progress', title: '计划进展' },
        { path: '/portal/achievement', title: '科研成果' },
        { path: '/portal/application', title: '应用与示范' },
        { path: '/portal/sdgsat1', title: 'SDGSAT-1专区' },
        { path: '/portal/notice', title: '通知公告' }
      ]
    }
  },
  computed: {
    currentPath() {
      return this.$route.path
    }
  }
}
</script>

<style lang="scss" scoped>
.portal-nav {
  width: 100%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar-box {
  width: 100%;
}

.navbar-top {
  width: 100%;
  background: #1a3a5c;
  height: 110px;
  background-image: url("../assets/images/top-container-bg.png");
  background-size: cover;
}

.top-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  height: 100%;
}

.top-left {
  .top-text {
    display: inline-block;
    width: 333px;
    height: 58px;
    background-image: url("../assets/images/navbar-top-left-bg.png");
    background-size: cover;
  }
}

.top-center {
  .top-text {
    display: inline-block;
    width: 490px;
    height: 66px;
    background-image: url("../assets/images/navbar-top-center-bg.png");
    background-size: cover;
  }
}

.top-right {
  display: flex;
  align-items: center;

  .top-link {
    color: #ffffff;
    font-size: 14px;
    text-decoration: none;
    transition: opacity 0.3s ease;
    cursor: pointer;

    &:hover {
      opacity: 0.8;
    }
  }
}

.navbar-main {
  width: 100%;
  background: #ffffff;
  height: 72px;
  position: relative;
}

.main-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  height: 100%;
}

.nav-decorator {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 6px;
  display: flex;
  overflow: hidden;

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

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

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

.nav-left {
  display: none;
}

.nav-right {
  .nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0;
    justify-content: center;

    li {
      position: relative;
      width: 168px;
      text-align: center;

      a {
        display: block;
        padding: 0;
        color: #333333;
        text-decoration: none;
        font-size: 16px;
        font-weight: 500;
        line-height: 72px;
        transition: all 0.3s ease;
        white-space: nowrap;

        &:hover {
          color: #1a3a5c;
        }

        &.router-link-active {
          background: #1EA8C5;
          border-radius: 12px 12px 0px 0px;
          color: #ffffff;
          font-weight: 600;
          position: relative;
        }
      }

      &.active {
        a {
          background: #1EA8C5;
          border-radius: 12px 12px 0px 0px;
          color: #ffffff;
          font-weight: 600;
          position: relative;
        }
      }
    }
  }
}

@media (max-width: 1200px) {
  .top-container,
  .main-container {
    padding: 0 15px;
  }

  .nav-right .nav-menu li a {
    padding: 0 18px;
    font-size: 15px;
  }

  .nav-left .site-title h1 {
    font-size: 22px;
  }

  .top-left .top-text,
  .top-right .top-link {
    font-size: 13px;
  }

  .navbar-main {
    height: 80px;
  }

  .nav-right .nav-menu li a {
    line-height: 80px;
  }
}

@media (max-width: 992px) {
  .navbar-main {
    height: auto;
  }

  .main-container {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
    height: auto;
  }

  .nav-right .nav-menu {
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;

    li a {
      line-height: 40px;
      padding: 0 15px;
      font-size: 14px;

      &.router-link-active::after,
      &.active a::after {
        bottom: 0;
        width: 30px;
        height: 2px;
      }
    }
  }

  .navbar-top {
    .top-container {
      flex-direction: column;
      gap: 8px;
      height: auto;
      padding: 10px 15px;
    }
  }

  .nav-left {
    .logo img {
      height: 50px;
    }

    .site-title h1 {
      font-size: 20px;
    }
  }
}
</style>
