// 右键菜单样式
.context-menu {
  position: fixed;
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08),
    0 3px 6px -4px rgba(0, 0, 0, 0.12),
    0 9px 28px 8px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  max-width: 280px;
  padding: 4px 0;
  font-size: 14px;
  // overflow: hidden;
  top: 60px; // 默认位置，可根据实际需要调整
  // 动画相关
  &.context-menu-enter-active,
  &.context-menu-leave-active {
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  &.context-menu-enter-from {
    opacity: 0;
    transform: scale(0.9);
  }
  
  &.context-menu-leave-to {
    opacity: 0;
    transform: scale(0.95);
  }
}

.context-menu-item {
  display: flex;
  align-items: center;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  min-height: 32px;
  position: relative;
  
  &:hover:not(.disabled) {
    background-color: #F9FAFA;
  }
  
  &:active:not(.disabled) {
    background-color: #e6e6e6;
  }
  
  &.disabled {
    color: rgba(0, 0, 0, 0.25);
    cursor: not-allowed;
    
    .context-menu-icon {
      color: rgba(0, 0, 0, 0.25);
    }
  }
  
  &.danger {
    color: #ff4d4f;
    
    &:hover:not(.disabled) {
      background-color: #fff2f0;
      color: #ff7875;
    }
    
    .context-menu-icon {
      color: #ff4d4f;
    }
  }
  
  &.has-children {
    position: relative;
  }

  &.hovered {
    background-color: #F9FAFA;
  }
}

.context-menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  color: rgba(0, 0, 0, 0.65);
  flex-shrink: 0;
}

.context-menu-label {
  flex: 1;
  line-height: 1.5;
}

.context-menu-shortcut {
  margin-left: 16px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.45);
}

.context-menu-arrow {
  margin-left: 8px;
  color: rgba(0, 0, 0, 0.45);
  transition: transform 0.2s;
}

.context-menu-divider {
  height: 1px;
  margin: 4px 0;
  background-color: rgba(0, 0, 0, 0.06);
}

// 子菜单样式
.context-submenu {
  position: absolute;
  left: 100%;
  top: 0;
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08),
    0 3px 6px -4px rgba(0, 0, 0, 0.12),
    0 9px 28px 8px rgba(0, 0, 0, 0.05);
  z-index: 1001;
  min-width: 160px;
  max-width: 280px;
  padding: 4px 0;
  font-size: 14px;
  // overflow: hidden;

  &.submenu-left {
    left: auto;
    right: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

// 子菜单动画
.context-submenu-enter-active,
.context-submenu-leave-active {
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.context-submenu-enter-from {
  opacity: 0;
  transform: scale(0.9) translateY(-8px);
}

.context-submenu-leave-to {
  opacity: 0;
  transform: scale(0.95) translateY(-4px);
}

// 响应式优化
@media (max-width: 768px) {
  .context-menu {
    min-width: 140px;
    font-size: 13px;
  }
  
  .context-menu-item {
    min-height: 36px;
    padding: 6px 10px;
  }
  
  .context-menu-shortcut {
    display: none;
  }

  .context-submenu {
    min-width: 140px;
    font-size: 13px;
  }
}

// 暗色主题支持
@media (prefers-color-scheme: dark) {
  .context-menu {
    background-color: #1f1f1f;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.48),
      0 3px 6px -4px rgba(0, 0, 0, 0.32),
      0 9px 28px 8px rgba(0, 0, 0, 0.35);
  }
  
  .context-menu-item {
    color: rgba(255, 255, 255, 0.85);
    
    &:hover:not(.disabled) {
      background-color: rgba(255, 255, 255, 0.08);
    }
    
    &:active:not(.disabled) {
      background-color: rgba(255, 255, 255, 0.12);
    }
    
    &.disabled {
      color: rgba(255, 255, 255, 0.3);
    }

    &.hovered {
      background-color: rgba(255, 255, 255, 0.08);
    }
  }
  
  .context-menu-icon {
    color: rgba(255, 255, 255, 0.65);
  }
  
  .context-menu-shortcut {
    color: rgba(255, 255, 255, 0.45);
  }

  .context-menu-arrow {
    color: rgba(255, 255, 255, 0.45);
  }
  
  .context-menu-divider {
    background-color: rgba(255, 255, 255, 0.12);
  }

  .context-submenu {
    background-color: #1f1f1f;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.48),
      0 3px 6px -4px rgba(0, 0, 0, 0.32),
      0 9px 28px 8px rgba(0, 0, 0, 0.35);
  }
}
