<template>
  <div class="platform-config-container">
    <div class="sub-tabs-header">
      <div v-for="item in subTabs" :key="item.key"
        :class="['sub-tab-item', { active: activeSubTab === item.key }]"
        @click="activeSubTab = item.key">
        {{ item.label }}
      </div>
    </div>

    <div class="sub-content-body">
      <transition name="fade-transform" mode="out-in">
        <div :key="activeSubTab">
          <OrderConfig v-if="activeSubTab === 'order'" />
          <MapConfig v-if="activeSubTab === 'map'" />
          <CustomerConfig v-if="activeSubTab === 'customer'" />
        </div>
      </transition>
    </div>
  </div>
</template>

<script setup name="PlatformConfig" lang="ts">
import { ref } from 'vue';
import OrderConfig from './components/OrderConfig.vue';
import MapConfig from './components/MapConfig.vue';
import CustomerConfig from './components/CustomerConfig.vue';

const activeSubTab = ref('order');

const subTabs = [
  // { label: '订单配置', key: 'order' },
  { label: '地图key配置', key: 'map' },
  { label: '客服配置', key: 'customer' }
];
</script>

<style scoped lang="scss">
.platform-config-container {
  padding: 8px 0;
}

.sub-tabs-header {
  display: flex;
  margin-bottom: 24px;
  border-bottom: 2px solid #f0f2f5;
  gap: 32px;

  .sub-tab-item {
    padding: 12px 4px;
    font-size: 15px;
    color: #4e5969;
    cursor: pointer;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;

    &::after {
      content: '';
      position: absolute;
      bottom: -2px;
      left: 0;
      width: 0;
      height: 2px;
      background-color: #409eff;
      transition: all 0.3s;
    }

    &:hover {
      color: #1d2129;
    }

    &.active {
      color: #409eff;
      font-weight: 600;

      &::after {
        width: 100%;
      }
    }
  }
}

.sub-content-body {
  padding-left: 8px;
}

/* 切换动画 */
.fade-transform-enter-active,
.fade-transform-leave-active {
  transition: all 0.25s;
}

.fade-transform-enter-from {
  opacity: 0;
  transform: translateY(10px);
}

.fade-transform-leave-to {
  opacity: 0;
  transform: translateY(-10px);
}
</style>
