<template>
  <div class="sidebar-logo-container" :class="{'collapse':collapse}">
    <transition name="sidebarLogoFade">
      <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/tools/comment-gen">
        <div class="logo-icon">
          <i class="el-icon-chat-line-round"></i>
        </div>
      </router-link>
      <router-link v-else key="expand" class="sidebar-logo-link" to="/tools/comment-gen">
        <div class="logo-icon">
          <i class="el-icon-chat-line-round"></i>
        </div>
        <h1 class="sidebar-title">{{ title }}</h1>
      </router-link>
    </transition>
  </div>
</template>

<script>
import logoImg from '@/assets/logo/logo.png'
import variables from '@/assets/styles/variables.scss'

export default {
  name: 'SidebarLogo',
  props: {
    collapse: {
      type: Boolean,
      required: true
    }
  },
  computed: {
    variables() {
      return variables
    },
    sideTheme() {
      return this.$store.state.settings.sideTheme
    }
  },
  data() {
    return {
      title: process.env.VUE_APP_TITLE,
      logo: logoImg
    }
  }
}
</script>

<style lang="scss" scoped>
.sidebarLogoFade-enter-active {
  transition: opacity 1.5s;
}

.sidebarLogoFade-enter,
.sidebarLogoFade-leave-to {
  opacity: 0;
}

.sidebar-logo-container {
  position: relative;
  width: 100%;
  height: 60px;
  line-height: 60px;
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  text-align: center;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  
  // 移动端优化
  @media (max-width: 768px) {
    height: 50px;
    line-height: 50px;
  }

  & .sidebar-logo-link {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    
    @media (max-width: 768px) {
      padding: 0 15px;
    }

    & .logo-icon {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 42px;
      height: 42px;
      background: rgba(255, 255, 255, 0.6);
      border: 2px solid rgba(25, 118, 210, 0.3);
      border-radius: 50%;
      margin-right: 15px;
      transition: all 0.3s ease;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      
      @media (max-width: 768px) {
        width: 36px;
        height: 36px;
        margin-right: 10px;
      }

      i {
        font-size: 22px;
        color: #1976d2;
        text-shadow: none;
        
        @media (max-width: 768px) {
          font-size: 18px;
        }
      }

      &:hover {
        background: rgba(255, 255, 255, 0.8);
        border-color: rgba(25, 118, 210, 0.5);
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(25, 118, 210, 0.2);
      }
      
      &:active {
        transform: scale(0.95);
      }
    }

    & .sidebar-title {
      display: inline-block;
      margin: 0;
      color: #1976d2;
      font-weight: 600;
      font-size: 16px;
      font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
      vertical-align: middle;
      text-shadow: none;
      
      @media (max-width: 768px) {
        font-size: 14px;
      }
    }
  }

  &.collapse {
    .logo-icon {
      margin-right: 0;
    }
    
    .sidebar-title {
      display: none;
    }
  }
}
</style>
